diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 45615765..6950a78b 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -464,6 +464,13 @@ extern struct wmaker_global_variables { /* locale to use. NULL==POSIX or C */ const char *locale; + /* Tracking of X events timestamps */ + struct { + /* ts of the last event we received */ + Time last_event; + + } timestamp; + } w_global; extern unsigned int ValidModMask; diff --git a/src/actions.c b/src/actions.c index 5ceb9d57..0b4f4503 100644 --- a/src/actions.c +++ b/src/actions.c @@ -53,7 +53,6 @@ /****** Global Variables ******/ int ignore_wks_change = 0; -extern Time LastTimestamp; extern Time LastFocusChange; extern Atom _XA_WM_TAKE_FOCUS; @@ -112,7 +111,7 @@ void wSetFocusTo(WScreen *scr, WWindow *wwin) WWindow *old_focused; WWindow *focused = scr->focused_window; - Time timestamp = LastTimestamp; + Time timestamp = w_global.timestamp.last_event; WApplication *oapp = NULL, *napp = NULL; int wasfocused; diff --git a/src/appmenu.c b/src/appmenu.c index 539f0564..ceb6c9a1 100644 --- a/src/appmenu.c +++ b/src/appmenu.c @@ -38,7 +38,6 @@ /******** Global Variables **********/ extern Atom _XA_WINDOWMAKER_MENU; -extern Time LastTimestamp; typedef struct { short code; @@ -67,7 +66,7 @@ static void sendMessage(Window window, int what, int tag) event.xclient.format = 32; event.xclient.display = dpy; event.xclient.window = window; - event.xclient.data.l[0] = LastTimestamp; + event.xclient.data.l[0] = w_global.timestamp.last_event; event.xclient.data.l[1] = what; event.xclient.data.l[2] = tag; event.xclient.data.l[3] = 0; diff --git a/src/event.c b/src/event.c index 95b437b2..aa4c92ab 100644 --- a/src/event.c +++ b/src/event.c @@ -84,7 +84,6 @@ extern Cursor wCursor[WCUR_LAST]; extern WShortKey wKeyBindings[WKBD_LAST]; extern int wScreenCount; -extern Time LastTimestamp; extern Time LastFocusChange; #define MOD_MASK wPreferences.modifier_mask @@ -527,30 +526,30 @@ static void saveTimestamp(XEvent * event) switch (event->type) { case ButtonRelease: case ButtonPress: - LastTimestamp = event->xbutton.time; + w_global.timestamp.last_event = event->xbutton.time; break; case KeyPress: case KeyRelease: - LastTimestamp = event->xkey.time; + w_global.timestamp.last_event = event->xkey.time; break; case MotionNotify: - LastTimestamp = event->xmotion.time; + w_global.timestamp.last_event = event->xmotion.time; break; case PropertyNotify: - LastTimestamp = event->xproperty.time; + w_global.timestamp.last_event = event->xproperty.time; break; case EnterNotify: case LeaveNotify: - LastTimestamp = event->xcrossing.time; + w_global.timestamp.last_event = event->xcrossing.time; break; case SelectionClear: - LastTimestamp = event->xselectionclear.time; + w_global.timestamp.last_event = event->xselectionclear.time; break; case SelectionRequest: - LastTimestamp = event->xselectionrequest.time; + w_global.timestamp.last_event = event->xselectionrequest.time; break; case SelectionNotify: - LastTimestamp = event->xselection.time; + w_global.timestamp.last_event = event->xselection.time; #ifdef XDND wXDNDProcessSelection(event); #endif diff --git a/src/main.c b/src/main.c index c7c8d407..1f75e165 100644 --- a/src/main.c +++ b/src/main.c @@ -128,8 +128,6 @@ Atom _XA_WM_IGNORE_FOCUS_EVENTS; /* cursors */ Cursor wCursor[WCUR_LAST]; -/* last event timestamp for XSetInputFocus */ -Time LastTimestamp = CurrentTime; /* timestamp on the last time we did XSetInputFocus() */ Time LastFocusChange = CurrentTime; @@ -596,6 +594,7 @@ int main(int argc, char **argv) memset(&w_global, 0, sizeof(w_global)); w_global.program.state = WSTATE_NORMAL; w_global.program.signal_state = WSTATE_NORMAL; + w_global.timestamp.last_event = CurrentTime; /* setup common stuff for the monitor and wmaker itself */ WMInitializeApplication("WindowMaker", &argc, argv); diff --git a/src/session.c b/src/session.c index c4ba5af0..20fc8fb3 100644 --- a/src/session.c +++ b/src/session.c @@ -89,7 +89,6 @@ extern Atom _XA_WM_SAVE_YOURSELF; -extern Time LastTimestamp; static WMPropList *sApplications = NULL; static WMPropList *sCommand; diff --git a/src/shutdown.c b/src/shutdown.c index 23f02ac0..163fe71b 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -39,7 +39,6 @@ #include "shutdown.h" extern Atom _XA_WM_DELETE_WINDOW; -extern Time LastTimestamp; extern int wScreenCount; static void wipeDesktop(WScreen * scr); @@ -197,7 +196,7 @@ static void wipeDesktop(WScreen * scr) wwin = scr->focused_window; while (wwin) { if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, w_global.timestamp.last_event); else wClientKill(wwin); wwin = wwin->prev; diff --git a/src/window.c b/src/window.c index a5de8a9c..be3796a1 100644 --- a/src/window.c +++ b/src/window.c @@ -86,7 +86,6 @@ extern XContext wWinContext; extern Atom _XA_WM_DELETE_WINDOW; extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW; extern Atom _XA_WINDOWMAKER_STATE; -extern Time LastTimestamp; /***** Local Stuff *****/ static WWindowState *windowState = NULL; @@ -2918,7 +2917,7 @@ static void windowCloseClick(WCoreWindow *sender, void *data, XEvent *event) } else { if (wwin->protocols.DELETE_WINDOW && event->xbutton.state == 0) { /* send delete message */ - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, w_global.timestamp.last_event); } } } @@ -2934,7 +2933,7 @@ static void windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event) /* send delete message */ if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, w_global.timestamp.last_event); else wClientKill(wwin); } @@ -2974,7 +2973,7 @@ static void windowIconifyClick(WCoreWindow *sender, void *data, XEvent *event) return; if (wwin->protocols.MINIATURIZE_WINDOW && event->xbutton.state == 0) { - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, w_global.timestamp.last_event); } else { WApplication *wapp; if ((event->xbutton.state & ControlMask) || (event->xbutton.button == Button3)) { diff --git a/src/winmenu.c b/src/winmenu.c index a8a7bb8e..16d67857 100644 --- a/src/winmenu.c +++ b/src/winmenu.c @@ -69,7 +69,6 @@ #define WO_ENTRIES 3 /**** Global data ***/ -extern Time LastTimestamp; extern Atom _XA_WM_DELETE_WINDOW; extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW; @@ -113,7 +112,7 @@ static void execMenuCommand(WMenu * menu, WMenuEntry * entry) switch (entry->order) { case MC_CLOSE: /* send delete message */ - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, w_global.timestamp.last_event); break; case MC_KILL: @@ -134,7 +133,7 @@ static void execMenuCommand(WMenu * menu, WMenuEntry * entry) wDeiconifyWindow(wwin); } else { if (wwin->protocols.MINIATURIZE_WINDOW) { - wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, w_global.timestamp.last_event); } else { wIconifyWindow(wwin); } diff --git a/src/wmspec.c b/src/wmspec.c index e71265b0..d2b945fc 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -52,7 +52,6 @@ /* Global variables */ extern Atom _XA_WM_DELETE_WINDOW; -extern Time LastTimestamp; /* Root Window Properties */ static Atom net_supported; @@ -1406,7 +1405,7 @@ Bool wNETWMProcessClientMessage(XClientMessageEvent *event) } else if (event->message_type == net_close_window) { if (!WFLAGP(wwin, no_closable)) { if (wwin->protocols.DELETE_WINDOW) - wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp); + wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, w_global.timestamp.last_event); } } else if (event->message_type == net_wm_state) { int maximized = wwin->flags.maximized;