Client's userTime related code ported over to XCB

At same time variable user_time renamed to m_userTime to follow naming
scheme.
icc-effect-5.14.5
Martin Gräßlin 2013-05-03 11:29:50 +02:00
parent dc1496f731
commit b39965ec27
4 changed files with 30 additions and 39 deletions

View File

@ -658,38 +658,29 @@ void Workspace::clientAttentionChanged(Client* c, bool set)
that qualifies for user interaction (clicking on it, activate it
externally, etc.).
*/
void Client::updateUserTime(Time time)
void Client::updateUserTime(xcb_timestamp_t time)
{
// copied in Group::updateUserTime
if (time == CurrentTime)
if (time == XCB_TIME_CURRENT_TIME)
time = xTime();
if (time != -1U
&& (user_time == CurrentTime
|| timestampCompare(time, user_time) > 0)) { // time > user_time
user_time = time;
&& (m_userTime == XCB_TIME_CURRENT_TIME
|| timestampCompare(time, m_userTime) > 0)) { // time > user_time
m_userTime = time;
shade_below = NULL; // do not hover re-shade a window after it got interaction
}
group()->updateUserTime(user_time);
group()->updateUserTime(m_userTime);
}
Time Client::readUserCreationTime() const
xcb_timestamp_t Client::readUserCreationTime() const
{
long result = -1; // Time == -1 means none
Atom type;
int format, status;
unsigned long nitems = 0;
unsigned long extra = 0;
unsigned char *data = 0;
KXErrorHandler handler; // ignore errors?
status = XGetWindowProperty(display(), window(),
atoms->kde_net_wm_user_creation_time, 0, 10000, false, XA_CARDINAL,
&type, &format, &nitems, &extra, &data);
if (status == Success) {
if (data && nitems > 0)
result = *((long*) data);
XFree(data);
const xcb_get_property_cookie_t cookie = xcb_get_property_unchecked(connection(), false, window(),
atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 0, 10000);
ScopedCPointer<xcb_get_property_reply_t> property(xcb_get_property_reply(connection(), cookie, NULL));
if (property.isNull() || xcb_get_property_value_length(property.data()) == 0) {
return -1;
}
return result;
return *(reinterpret_cast<xcb_timestamp_t*>(xcb_get_property_value(property.data())));
}
void Client::demandAttention(bool set)
@ -711,10 +702,10 @@ KWIN_COMPARE_PREDICATE(SameApplicationActiveHackPredicate, Client, const Client*
!cl->isSplash() && !cl->isToolbar() && !cl->isUtility() && !cl->isMenu()
&& Client::belongToSameApplication(cl, value, true) && cl != value);
Time Client::readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
bool session) const
xcb_timestamp_t Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id, const KStartupInfoData *asn_data,
bool session) const
{
Time time = info->userTime();
xcb_timestamp_t time = info->userTime();
//kDebug( 1212 ) << "User timestamp, initial:" << time;
//^^ this deadlocks kwin --replace sometimes.
@ -778,9 +769,9 @@ Time Client::readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStart
return time;
}
Time Client::userTime() const
xcb_timestamp_t Client::userTime() const
{
Time time = user_time;
xcb_timestamp_t time = m_userTime;
if (time == 0) // doesn't want focus after showing
return 0;
assert(group() != NULL);

View File

@ -114,7 +114,7 @@ Client::Client()
, in_layer(UnknownLayer)
, ping_timer(NULL)
, m_killHelperPID(0)
, user_time(CurrentTime) // Not known yet
, m_userTime(XCB_TIME_CURRENT_TIME) // Not known yet
, allowed_actions(0)
, block_geometry_updates(0)
, pending_geometry_update(PendingGeometryNone)

View File

@ -503,8 +503,8 @@ public:
void gotPing(Time timestamp);
void checkWorkspacePosition(QRect oldGeometry = QRect(), int oldDesktop = -2);
void updateUserTime(Time time = CurrentTime);
Time userTime() const;
void updateUserTime(xcb_timestamp_t time = XCB_TIME_CURRENT_TIME);
xcb_timestamp_t userTime() const;
bool hasUserTimeSupport() const;
/// Does 'delete c;'
@ -821,9 +821,9 @@ private:
void updateInputShape();
Time readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
xcb_timestamp_t readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
bool session) const;
Time readUserCreationTime() const;
xcb_timestamp_t readUserCreationTime() const;
void startupIdChanged();
void checkOffscreenPosition (QRect* geom, const QRect& screenArea);
@ -940,7 +940,7 @@ private:
QTimer* ping_timer;
qint64 m_killHelperPID;
Time ping_timestamp;
Time user_time;
xcb_timestamp_t m_userTime;
unsigned long allowed_actions;
QSize client_size;
int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set

View File

@ -523,8 +523,8 @@ bool Client::manage(xcb_window_t w, bool isMapped)
updateAllowedActions(true);
// Set initial user time directly
user_time = readUserTimeMapTimestamp(asn_valid ? &asn_id : NULL, asn_valid ? &asn_data : NULL, session);
group()->updateUserTime(user_time); // And do what Client::updateUserTime() does
m_userTime = readUserTimeMapTimestamp(asn_valid ? &asn_id : NULL, asn_valid ? &asn_data : NULL, session);
group()->updateUserTime(m_userTime); // And do what Client::updateUserTime() does
// This should avoid flicker, because real restacking is done
// only after manage() finishes because of blocking, but the window is shown sooner
@ -598,11 +598,11 @@ bool Client::manage(xcb_window_t w, bool isMapped)
m_managed = true;
blockGeometryUpdates(false);
if (user_time == CurrentTime || user_time == -1U) {
if (m_userTime == XCB_TIME_CURRENT_TIME || m_userTime == -1U) {
// No known user time, set something old
user_time = xTime() - 1000000;
if (user_time == CurrentTime || user_time == -1U) // Let's be paranoid
user_time = xTime() - 1000000 + 10;
m_userTime = xTime() - 1000000;
if (m_userTime == XCB_TIME_CURRENT_TIME || m_userTime == -1U) // Let's be paranoid
m_userTime = xTime() - 1000000 + 10;
}
//sendSyntheticConfigureNotify(); // Done when setting mapping state