Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2014-01-22 11:33:53 -08:00
commit 25ebb9dbc9
5 changed files with 81 additions and 9 deletions

View File

@ -1783,8 +1783,25 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device)
DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent *) event,
NullGrab, NullWindow, device);
if (deactivateDeviceGrab == TRUE)
if (deactivateDeviceGrab == TRUE) {
(*device->deviceGrab.DeactivateGrab) (device);
if (!IsMaster (device) && !IsFloating (device)) {
int flags, num_events = 0;
InternalEvent dce;
flags = (IsPointerDevice (device)) ?
DEVCHANGE_POINTER_EVENT : DEVCHANGE_KEYBOARD_EVENT;
UpdateFromMaster (&dce, device, flags, &num_events);
BUG_WARN(num_events > 1);
if (num_events == 1)
ChangeMasterDeviceClasses(GetMaster (device, MASTER_ATTACHED),
&dce.changed_event);
}
}
event->detail.key = key;
}

View File

@ -3961,6 +3961,8 @@ CheckPassiveGrabsOnWindow(WindowPtr pWin,
return NULL;
tempGrab = AllocGrab(NULL);
if (tempGrab == NULL)
return NULL;
/* Fill out the grab details, but leave the type for later before
* comparing */
@ -5056,7 +5058,7 @@ ProcUngrabPointer(ClientPtr client)
* @param other_mode GrabModeSync or GrabModeAsync
* @param status Return code to be returned to the caller.
*
* @returns Success or BadValue.
* @returns Success or BadValue or BadAlloc.
*/
int
GrabDevice(ClientPtr client, DeviceIntPtr dev,
@ -5137,6 +5139,8 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
GrabPtr tempGrab;
tempGrab = AllocGrab(NULL);
if (tempGrab == NULL)
return BadAlloc;
tempGrab->next = NULL;
tempGrab->window = pWin;

View File

@ -199,12 +199,11 @@ AllocGrab(const GrabPtr src)
free(grab);
grab = NULL;
}
}
if (src && !CopyGrab(grab, src)) {
free(grab->xi2mask);
free(grab);
grab = NULL;
else if (src && !CopyGrab(grab, src)) {
free(grab->xi2mask);
free(grab);
grab = NULL;
}
}
return grab;

View File

@ -1008,6 +1008,29 @@ ephyrProcessButtonRelease(xcb_generic_event_t *xev)
KdEnqueuePointerEvent(ephyrMouse, mouseState | KD_MOUSE_DELTA, 0, 0, 0);
}
/* Xephyr wants ctrl+shift to grab the window, but that conflicts with
ctrl+alt+shift key combos. Remember the modifier state on key presses and
releases, if mod1 is pressed, we need ctrl, shift and mod1 released
before we allow a shift-ctrl grab activation.
note: a key event contains the mask _before_ the current key takes
effect, so mod1_was_down will be reset on the first key press after all
three were released, not on the last release. That'd require some more
effort.
*/
static int
ephyrUpdateGrabModifierState(int state)
{
static int mod1_was_down = 0;
if ((state & (XCB_MOD_MASK_CONTROL|XCB_MOD_MASK_SHIFT|XCB_MOD_MASK_1)) == 0)
mod1_was_down = 0;
else if (state & XCB_MOD_MASK_1)
mod1_was_down = 1;
return mod1_was_down;
}
static void
ephyrProcessKeyPress(xcb_generic_event_t *xev)
{
@ -1018,6 +1041,7 @@ ephyrProcessKeyPress(xcb_generic_event_t *xev)
return;
}
ephyrUpdateGrabModifierState(key->state);
ephyrUpdateModifierState(key->state);
KdEnqueueKeyboardEvent(ephyrKbd, key->detail, FALSE);
}
@ -1029,6 +1053,7 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
xcb_key_release_event_t *key = (xcb_key_release_event_t *)xev;
static xcb_key_symbols_t *keysyms;
static int grabbed_screen = -1;
int mod1_down = ephyrUpdateGrabModifierState(key->state);
if (!keysyms)
keysyms = xcb_key_symbols_alloc(conn);
@ -1049,7 +1074,7 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
hostx_set_win_title(screen,
"(ctrl+shift grabs mouse and keyboard)");
}
else {
else if (!mod1_down) {
/* Attempt grab */
xcb_grab_keyboard_cookie_t kbgrabc =
xcb_grab_keyboard(conn,

View File

@ -600,6 +600,10 @@ UseMsg(void)
static int
VerifyDisplayName(const char *d)
{
int i;
int period_found = FALSE;
int after_period = 0;
if (d == (char *) 0)
return 0; /* null */
if (*d == '\0')
@ -610,6 +614,29 @@ VerifyDisplayName(const char *d)
return 0; /* must not equal "." or ".." */
if (strchr(d, '/') != (char *) 0)
return 0; /* very important!!! */
/* Since we run atoi() on the display later, only allow
for digits, or exception of :0.0 and similar (two decimal points max)
*/
for (i = 0; i < strlen(d); i++) {
if (!isdigit(d[i])) {
if (d[i] != '.' || period_found)
return 0;
period_found = TRUE;
} else if (period_found)
after_period++;
if (after_period > 2)
return 0;
}
/* don't allow for :0. */
if (period_found && after_period == 0)
return 0;
if (atol(d) > INT_MAX)
return 0;
return 1;
}