fix for ignoring NumLock on Alt-windowclick (previous NumLock fix was only

2001-10-26  Havoc Pennington  <hp@pobox.com>

	* src/display.c (meta_display_grab_window_buttons): fix for
	ignoring NumLock on Alt-windowclick (previous NumLock fix
	was only for key grabs not button grabs)
This commit is contained in:
Havoc Pennington 2001-10-26 04:00:38 +00:00 committed by Havoc Pennington
parent 3e92e3b1df
commit f663a511b3
3 changed files with 75 additions and 60 deletions

View File

@ -1,3 +1,9 @@
2001-10-26 Havoc Pennington <hp@pobox.com>
* src/display.c (meta_display_grab_window_buttons): fix for
ignoring NumLock on Alt-windowclick (previous NumLock fix
was only for key grabs not button grabs)
2001-10-25 Havoc Pennington <hp@redhat.com> 2001-10-25 Havoc Pennington <hp@redhat.com>
* src/window.c (meta_window_new): set the current workspace hint * src/window.c (meta_window_new): set the current workspace hint

View File

@ -88,7 +88,6 @@ meta_display_open (const char *name)
Display *xdisplay; Display *xdisplay;
GSList *screens; GSList *screens;
GSList *tmp; GSList *tmp;
int i;
/* Remember to edit code that assigns each atom to display struct /* Remember to edit code that assigns each atom to display struct
* when adding an atom name here. * when adding an atom name here.
*/ */
@ -1601,6 +1600,56 @@ meta_display_end_grab_op (MetaDisplay *display,
display->grab_op = META_GRAB_OP_NONE; display->grab_op = META_GRAB_OP_NONE;
} }
#define IGNORED_MODIFIERS (LockMask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
#define INTERESTING_MODIFIERS (~IGNORED_MODIFIERS)
static void
meta_change_button_grab (MetaDisplay *display,
Window xwindow,
gboolean grab,
int button,
int modmask)
{
int ignored_mask;
g_return_if_fail ((modmask & INTERESTING_MODIFIERS) == modmask);
ignored_mask = 0;
while (ignored_mask < IGNORED_MODIFIERS)
{
int result;
if (ignored_mask & INTERESTING_MODIFIERS)
{
/* Not a combination of IGNORED_MODIFIERS
* (it contains some non-ignored modifiers)
*/
++ignored_mask;
continue;
}
meta_error_trap_push (display);
if (grab)
XGrabButton (display->xdisplay, button, modmask | ignored_mask,
xwindow, False,
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | PointerMotionHintMask,
GrabModeAsync, GrabModeAsync,
False, None);
else
XUngrabButton (display->xdisplay, button, modmask | ignored_mask,
xwindow);
result = meta_error_trap_pop (display);
if (result != Success)
meta_warning ("Failed to grab button %d with mask 0x%x for window 0x%lx error code %d\n",
button, modmask | ignored_mask, xwindow, result);
++ignored_mask;
}
}
void void
meta_display_grab_window_buttons (MetaDisplay *display, meta_display_grab_window_buttons (MetaDisplay *display,
Window xwindow) Window xwindow)
@ -1616,48 +1665,23 @@ meta_display_grab_window_buttons (MetaDisplay *display,
*/ */
{ {
gboolean debug = g_getenv ("METACITY_DEBUG_BUTTON_GRABS") != NULL;
int i = 1; int i = 1;
while (i < 4) while (i < 4)
{ {
int result; meta_change_button_grab (display,
xwindow,
TRUE,
i, Mod1Mask);
/* Note: changing the modifier for this keybinding also
* requires a change to the button press handling /* This is for debugging, since I end up moving the Xnest
* in the display event handler * otherwise ;-)
*/ */
if (debug)
meta_error_trap_push (display); meta_change_button_grab (display, xwindow,
XGrabButton (display->xdisplay, i, Mod1Mask, TRUE,
xwindow, False, i, ControlMask);
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | PointerMotionHintMask,
GrabModeAsync, GrabModeAsync,
False, None);
result = meta_error_trap_pop (display);
if (result != Success)
meta_warning ("Failed to grab button %d with Mod1Mask for window 0x%lx error code %d\n",
i, xwindow, result);
if (g_getenv ("METACITY_DEBUG_BUTTON_GRABS"))
{
/* This is just for debugging, since I end up moving
* the Xnest otherwise ;-)
*/
meta_error_trap_push (display);
result = XGrabButton (display->xdisplay, i, ControlMask,
xwindow, False,
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | PointerMotionHintMask,
GrabModeAsync, GrabModeAsync,
False, None);
result = meta_error_trap_pop (display);
if (result != Success)
meta_warning ("Failed to grab button %d with ControlMask for window 0x%lx error code %d\n",
i, xwindow, result);
}
++i; ++i;
} }
@ -1668,30 +1692,15 @@ void
meta_display_ungrab_window_buttons (MetaDisplay *display, meta_display_ungrab_window_buttons (MetaDisplay *display,
Window xwindow) Window xwindow)
{ {
/* FIXME If we ignored errors here instead of spewing, we could gboolean debug = g_getenv ("METACITY_DEBUG_BUTTON_GRABS") != NULL;
* put one big error trap around the loop and avoid a bunch of
* XSync()
*/
int i = 1; int i = 1;
while (i < 4) while (i < 4)
{ {
int result; meta_change_button_grab (display, xwindow,
FALSE, i, Mod1Mask);
meta_error_trap_push (display); if (debug)
XUngrabButton (display->xdisplay, i, Mod1Mask, xwindow); meta_change_button_grab (display, xwindow,
result = meta_error_trap_pop (display); FALSE, i, ControlMask);
if (result != Success)
meta_warning ("Failed to ungrab button %d with Mod1Mask for window 0x%lx error code %d\n",
i, xwindow, result);
meta_error_trap_push (display);
XUngrabButton (display->xdisplay, i, ControlMask, xwindow);
result = meta_error_trap_pop (display);
if (result != Success)
meta_warning ("Failed to ungrab button %d with ControlMask for window 0x%lx error code %d\n",
i, xwindow, result);
++i; ++i;
} }

View File

@ -55,5 +55,5 @@ if test -z "$ONLY_WM"; then
fi fi
if test -z "$ONLY_SETUP"; then if test -z "$ONLY_SETUP"; then
METACITY_DEBUG_BUTTON_GRABS=1 METACITY_DISPLAY=:1 exec unst libtool --mode=execute $DEBUG ./metacity $OPTIONS METACITY_DEBUG_BUTTON_GRABS=1 METACITY_DISPLAY=:1 exec libtool --mode=execute $DEBUG ./metacity $OPTIONS
fi fi