1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2008-03-24 04:12:40 -07:00
|
|
|
* Copyright (C) 2004-2008 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "cursors.h"
|
|
|
|
#include "grabs.h"
|
2008-03-30 05:13:16 -07:00
|
|
|
#include "xwin.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-06-30 05:37:43 -07:00
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
GrabKeyboardSet(Win win)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2005-06-30 05:37:43 -07:00
|
|
|
int rc;
|
2004-08-14 08:06:26 -07:00
|
|
|
|
2006-08-07 13:47:12 -07:00
|
|
|
rc =
|
|
|
|
XGrabKeyboard(disp, WinGetXwin(win), False, GrabModeAsync, GrabModeAsync,
|
|
|
|
CurrentTime);
|
2004-08-14 08:06:26 -07:00
|
|
|
|
2005-06-30 05:37:43 -07:00
|
|
|
#if 0
|
2006-08-07 13:47:12 -07:00
|
|
|
Eprintf("GrabKeyboardSet %#lx %d\n", WinGetXwin(win), rc);
|
2005-06-30 05:37:43 -07:00
|
|
|
#endif
|
|
|
|
return rc;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
2005-06-30 05:37:43 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
GrabKeyboardRelease(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = XUngrabKeyboard(disp, CurrentTime);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
Eprintf("GrabKeyboardRelease %d\n", rc);
|
2004-11-20 09:55:12 -08:00
|
|
|
#endif
|
2005-06-30 05:37:43 -07:00
|
|
|
return rc;
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
int
|
2006-04-29 12:39:21 -07:00
|
|
|
GrabPointerSet(Win win, unsigned int csr, int confine)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2012-10-24 10:20:38 -07:00
|
|
|
int ret;
|
2008-03-24 04:12:40 -07:00
|
|
|
Window confine_to = (confine) ? WinGetXwin(VROOT) : None;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2006-08-07 13:47:12 -07:00
|
|
|
ret = XGrabPointer(disp, WinGetXwin(win), False,
|
2004-08-14 08:06:26 -07:00
|
|
|
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
|
|
|
|
ButtonMotionMask | EnterWindowMask | LeaveWindowMask,
|
|
|
|
GrabModeAsync, GrabModeAsync, confine_to, ECsrGet(csr),
|
|
|
|
CurrentTime);
|
1999-09-04 00:10:13 -07:00
|
|
|
|
2006-08-07 13:47:12 -07:00
|
|
|
Mode.grabs.pointer_grab_window = WinGetXwin(win);
|
2004-08-05 16:08:34 -07:00
|
|
|
Mode.grabs.pointer_grab_active = 1;
|
2004-08-14 08:06:26 -07:00
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_GRABS))
|
2004-11-20 09:55:12 -08:00
|
|
|
Eprintf("GrabPointerSet: %#lx, ret=%d\n", Mode.grabs.pointer_grab_window,
|
|
|
|
ret);
|
|
|
|
|
2004-08-14 08:06:26 -07:00
|
|
|
return ret;
|
1999-09-04 00:10:13 -07:00
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
void
|
2004-08-14 08:06:26 -07:00
|
|
|
GrabPointerRelease(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
XUngrabPointer(disp, CurrentTime);
|
2004-08-14 08:06:26 -07:00
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_GRABS))
|
2004-11-20 09:55:12 -08:00
|
|
|
Eprintf("GrabPointerRelease: %#lx\n", Mode.grabs.pointer_grab_window);
|
|
|
|
|
2004-08-05 16:08:34 -07:00
|
|
|
Mode.grabs.pointer_grab_active = 0;
|
|
|
|
Mode.grabs.pointer_grab_window = None;
|
2004-08-14 08:06:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
GrabButtonSet(unsigned int button, unsigned int modifiers, Win win,
|
2004-08-14 08:06:26 -07:00
|
|
|
unsigned int event_mask, unsigned int csr, int confine)
|
|
|
|
{
|
|
|
|
Bool owner_events = False;
|
|
|
|
int pointer_mode = GrabModeSync;
|
|
|
|
int keyboard_mode = GrabModeAsync;
|
2006-08-07 13:47:12 -07:00
|
|
|
Window confine_to = (confine) ? WinGetXwin(win) : None;
|
2007-01-31 17:23:40 -08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (modifiers == AnyModifier)
|
|
|
|
{
|
|
|
|
XGrabButton(disp, button, modifiers,
|
|
|
|
WinGetXwin(win), owner_events, event_mask, pointer_mode,
|
|
|
|
keyboard_mode, confine_to, ECsrGet(csr));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (i && !Mode.masks.mod_combos[i])
|
|
|
|
continue;
|
|
|
|
XGrabButton(disp, button, modifiers | Mode.masks.mod_combos[i],
|
|
|
|
WinGetXwin(win), owner_events, event_mask, pointer_mode,
|
|
|
|
keyboard_mode, confine_to, ECsrGet(csr));
|
|
|
|
}
|
2004-08-14 08:06:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-29 12:39:21 -07:00
|
|
|
GrabButtonRelease(unsigned int button, unsigned int modifiers, Win win)
|
2004-08-14 08:06:26 -07:00
|
|
|
{
|
2007-01-31 17:23:40 -08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (modifiers == AnyModifier)
|
|
|
|
{
|
|
|
|
XUngrabButton(disp, button, modifiers, WinGetXwin(win));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (i && !Mode.masks.mod_combos[i])
|
|
|
|
continue;
|
|
|
|
XUngrabButton(disp, button, modifiers | Mode.masks.mod_combos[i],
|
|
|
|
WinGetXwin(win));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GrabKeySet(unsigned int key, unsigned int modifiers, Win win)
|
|
|
|
{
|
|
|
|
Bool owner_events = False;
|
|
|
|
int pointer_mode = GrabModeAsync;
|
|
|
|
int keyboard_mode = GrabModeSync;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (modifiers == AnyModifier)
|
|
|
|
{
|
|
|
|
XGrabKey(disp, key, modifiers, WinGetXwin(win), owner_events,
|
|
|
|
pointer_mode, keyboard_mode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (i && !Mode.masks.mod_combos[i])
|
|
|
|
continue;
|
|
|
|
XGrabKey(disp, key, modifiers | Mode.masks.mod_combos[i],
|
|
|
|
WinGetXwin(win), owner_events, pointer_mode, keyboard_mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GrabKeyRelease(unsigned int key, unsigned int modifiers, Win win)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (modifiers == AnyModifier)
|
|
|
|
{
|
|
|
|
XUngrabKey(disp, key, modifiers, WinGetXwin(win));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (i && !Mode.masks.mod_combos[i])
|
|
|
|
continue;
|
|
|
|
XUngrabKey(disp, key, modifiers | Mode.masks.mod_combos[i],
|
|
|
|
WinGetXwin(win));
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|