From e74cf49cdadd496609300fdfbb9caf66a2ce5679 Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Mon, 8 Jul 2013 20:46:07 +0000 Subject: [PATCH] * Source/x11/XGServerWindow.m (-setIgnoreMouse::): New method that allows to ignore mouse events for a window. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@36855 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 +++- Source/x11/XGServerWindow.m | 93 ++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e6ef65..0400bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-07-08 Fred Kiefer + + * Source/x11/XGServerWindow.m (-setIgnoreMouse::): New method that + allows to ignore mouse events for a window. + 2013-07-04 Richard Frith-Macdonald * Tools/GNUmakefile.preamble: @@ -9,7 +14,7 @@ * Source/x11/XGGLFormat.m: * Headers/x11/XGOpenGL.h: ARGB visual is only picked if NSOpenGLPFAAlphaSize is - specified in the pixel format. + specified in the pixel format. 2013-07-03 Ivan Vucica @@ -6341,4 +6346,3 @@ Thu Apr 11 22:24:01 2002 Nicola Pero 2002-03-27 Adam Fedor * Version: Initial version (most code extracted from xgps). - diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 45b25d7..4890bb3 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -658,6 +658,47 @@ static void setWindowHintsForStyle (Display *dpy, Window window, return NO; } +static void +select_input(Display *display, Window w, BOOL ignoreMouse) +{ + long event_mask; + + if (!ignoreMouse) + { + event_mask = ExposureMask + | KeyPressMask + | KeyReleaseMask + | ButtonPressMask + | ButtonReleaseMask + | ButtonMotionMask + | StructureNotifyMask + | PointerMotionMask + | EnterWindowMask + | LeaveWindowMask + | FocusChangeMask + /* enable property notifications to detect window (de)miniaturization */ + | PropertyChangeMask + // | ColormapChangeMask + | KeymapStateMask + | VisibilityChangeMask; + } + else + { + event_mask = ExposureMask + | KeyPressMask + | KeyReleaseMask + | StructureNotifyMask + | FocusChangeMask + /* enable property notifications to detect window (de)miniaturization */ + | PropertyChangeMask + // | ColormapChangeMask + | KeymapStateMask + | VisibilityChangeMask; + } + + XSelectInput(display, w, event_mask); +} + Bool _get_next_prop_new_event(Display *display, XEvent *event, char *arg) { @@ -819,24 +860,8 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg) valuemask = (GCForeground | GCBackground | GCFunction); window->gc = XCreateGC(dpy, window->ident, valuemask, &values); - /* Set the X event mask - */ - XSelectInput(dpy, window->ident, ExposureMask - | KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - | ButtonMotionMask - | StructureNotifyMask - | PointerMotionMask - | EnterWindowMask - | LeaveWindowMask - | FocusChangeMask - | PropertyChangeMask -// | ColormapChangeMask - | KeymapStateMask - | VisibilityChangeMask - ); + /* Set the X event mask */ + select_input(dpy, window->ident, YES); /* * Initial attributes for any GNUstep window tell Window Maker not to @@ -2044,25 +2069,8 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg) valuemask = (GCForeground | GCBackground | GCFunction); window->gc = XCreateGC(dpy, window->ident, valuemask, &values); - /* Set the X event mask - */ - XSelectInput(dpy, window->ident, ExposureMask - | KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - | ButtonMotionMask - | StructureNotifyMask - | PointerMotionMask - | EnterWindowMask - | LeaveWindowMask - | FocusChangeMask - /* enable property notifications to detect window (de)miniaturization */ - | PropertyChangeMask -// | ColormapChangeMask - | KeymapStateMask - | VisibilityChangeMask - ); + /* Set the X event mask */ + select_input(dpy, window->ident, NO); /* * Initial attributes for any GNUstep window tell Window Maker not to @@ -5007,4 +5015,15 @@ _computeDepth(int class, int bpp) XSetTransientForHint(dpy, cwindow->ident, p); } +- (void) setIgnoreMouse: (BOOL)ignoreMouse : (int)win +{ + gswindow_device_t *window; + + window = WINDOW_WITH_TAG(win); + if (!window) + return; + + select_input(dpy, window->ident, ignoreMouse); +} + @end