Small cleanup related to timestamp handling.
svn path=/trunk/kdebase/kwin/; revision=257715
This commit is contained in:
parent
0deb5fa09d
commit
83835a8757
5 changed files with 18 additions and 40 deletions
|
@ -132,7 +132,7 @@ void RootInfo::moveResize(Window w, int x_root, int y_root, unsigned long direct
|
|||
Client* c = workspace->findClient( WindowMatchPredicate( w ));
|
||||
if ( c )
|
||||
{
|
||||
kwin_updateTime(); // otherwise grabbing may have old timestamp - this message should include timestamp
|
||||
updateXTime(); // otherwise grabbing may have old timestamp - this message should include timestamp
|
||||
c->NETMoveResize( x_root, y_root, (Direction)direction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ QCString getStringProperty(WId w, Atom prop, char separator)
|
|||
Use this function only when really necessary. Keep in mind that it's
|
||||
a roundtrip to the X-Server.
|
||||
*/
|
||||
void kwin_updateTime()
|
||||
void updateXTime()
|
||||
{
|
||||
static QWidget* w = 0;
|
||||
if ( !w )
|
||||
|
|
8
utils.h
8
utils.h
|
@ -130,7 +130,7 @@ class KWinSelectionOwner
|
|||
|
||||
|
||||
QCString getStringProperty(WId w, Atom prop, char separator=0);
|
||||
void kwin_updateTime();
|
||||
void updateXTime();
|
||||
|
||||
// the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
|
||||
#ifndef UrgencyHint
|
||||
|
@ -169,6 +169,12 @@ int timestampCompare( Time time1, Time time2 ) // like strcmp()
|
|||
return ( time1 - time2 ) < 1000000000 ? 1 : -1; // time1 > time2 -> 1, handle wrapping
|
||||
}
|
||||
|
||||
inline
|
||||
Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1
|
||||
{ // no need to handle wrapping?
|
||||
return time2 - time1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -92,8 +92,6 @@ Workspace::Workspace( bool restore )
|
|||
electric_bottom_border(None),
|
||||
electric_left_border(None),
|
||||
electric_right_border(None),
|
||||
electric_time_first(0),
|
||||
electric_time_last(0),
|
||||
layoutOrientation(Qt::Vertical),
|
||||
layoutX(-1),
|
||||
layoutY(2),
|
||||
|
@ -110,6 +108,9 @@ Workspace::Workspace( bool restore )
|
|||
|
||||
updateXTime(); // needed for proper initialization of user_time in Client ctor
|
||||
|
||||
electric_time_first = qt_x_time;
|
||||
electric_time_last = qt_x_time;
|
||||
|
||||
if ( restore )
|
||||
loadSessionInfo();
|
||||
|
||||
|
@ -1650,16 +1651,7 @@ void Workspace::destroyBorderWindows()
|
|||
electric_right_border = None;
|
||||
}
|
||||
|
||||
// Do we have a proper timediff function??
|
||||
static int TimeDiff(unsigned long a, unsigned long b)
|
||||
{
|
||||
if (a > b)
|
||||
return a-b;
|
||||
else
|
||||
return b-a;
|
||||
}
|
||||
|
||||
void Workspace::clientMoved(const QPoint &pos, unsigned long now)
|
||||
void Workspace::clientMoved(const QPoint &pos, Time now)
|
||||
{
|
||||
if (options->electricBorders() == Options::ElectricDisabled)
|
||||
return;
|
||||
|
@ -1670,8 +1662,8 @@ void Workspace::clientMoved(const QPoint &pos, unsigned long now)
|
|||
(pos.y() != electricBottom))
|
||||
return;
|
||||
|
||||
int treshold_set = options->electricBorderDelay(); // set timeout
|
||||
int treshold_reset = 250; // reset timeout
|
||||
Time treshold_set = options->electricBorderDelay(); // set timeout
|
||||
Time treshold_reset = 250; // reset timeout
|
||||
int distance_reset = 10; // Mouse should not move more than this many pixels
|
||||
|
||||
int border = 0;
|
||||
|
@ -1685,12 +1677,12 @@ void Workspace::clientMoved(const QPoint &pos, unsigned long now)
|
|||
border = 4;
|
||||
|
||||
if ((electric_current_border == border) &&
|
||||
(TimeDiff(electric_time_last, now) < treshold_reset) &&
|
||||
(timestampDiff(electric_time_last, now) < treshold_reset) &&
|
||||
((pos-electric_push_point).manhattanLength() < distance_reset))
|
||||
{
|
||||
electric_time_last = now;
|
||||
|
||||
if (TimeDiff(electric_time_first, now) > treshold_set)
|
||||
if (timestampDiff(electric_time_first, now) > treshold_set)
|
||||
{
|
||||
electric_current_border = 0;
|
||||
|
||||
|
@ -1836,25 +1828,6 @@ QString Workspace::desktopName( int desk ) const
|
|||
return QString::fromUtf8( rootInfo->desktopName( desk ) );
|
||||
}
|
||||
|
||||
/*!
|
||||
Updates qt_x_time by receiving a current timestamp from the server.
|
||||
|
||||
Use this function only when really necessary. Keep in mind that it's
|
||||
a roundtrip to the X-Server.
|
||||
*/
|
||||
void Workspace::updateXTime()
|
||||
{
|
||||
static QWidget* w = 0;
|
||||
if ( !w )
|
||||
w = new QWidget;
|
||||
long data = 1;
|
||||
XChangeProperty(qt_xdisplay(), w->winId(), atoms->kwin_running, atoms->kwin_running, 32,
|
||||
PropModeAppend, (unsigned char*) &data, 1);
|
||||
XEvent ev;
|
||||
XWindowEvent( qt_xdisplay(), w->winId(), PropertyChangeMask, &ev );
|
||||
qt_x_time = ev.xproperty.time;
|
||||
}
|
||||
|
||||
bool Workspace::checkStartupNotification( const Client* c, KStartupInfoData& data )
|
||||
{
|
||||
return startup->checkStartup( c->window(), data ) == KStartupInfo::Match;
|
||||
|
|
|
@ -150,7 +150,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
|
|||
void clientHidden( Client* );
|
||||
void clientAttentionChanged( Client* c, bool set );
|
||||
|
||||
void clientMoved(const QPoint &pos, unsigned long time);
|
||||
void clientMoved(const QPoint &pos, Time time);
|
||||
|
||||
/**
|
||||
* Returns the current virtual desktop of this workspace
|
||||
|
@ -327,7 +327,6 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine
|
|||
void initShortcuts();
|
||||
void readShortcuts();
|
||||
void initDesktopPopup();
|
||||
void updateXTime();
|
||||
|
||||
bool startKDEWalkThroughWindows();
|
||||
bool startWalkThroughDesktops( int mode ); // TabBox::Mode::DesktopMode | DesktopListMode
|
||||
|
|
Loading…
Reference in a new issue