gdkasync.c 18.6 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2 3 4 5 6 7 8 9 10 11 12 13 14 15
 * gdkasync.c: Utility functions using the Xlib asynchronous interfaces
 * Copyright (C) 2003, Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
16
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
 */
/* Portions of code in this file are based on code from Xlib
 */
/*
Copyright 1986, 1998  The Open Group

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

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
OPEN GROUP 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.

Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.

*/
44
#include "config.h"
45 46

#include "gdkasync.h"
Matthias Clasen's avatar
Matthias Clasen committed
47
#include "gdkprivate-x11.h"
48

49 50 51
#ifdef NEED_XIPROTO_H_FOR_XREPLY
#include <X11/extensions/XIproto.h>
#endif
52

53
#include <X11/Xlibint.h>
54

55

56 57
typedef struct _ChildInfoChildState ChildInfoChildState;
typedef struct _ChildInfoState ChildInfoState;
58
typedef struct _ListChildrenState ListChildrenState;
59
typedef struct _SendEventState SendEventState;
60
typedef struct _SetInputFocusState SetInputFocusState;
61
typedef struct _RoundtripState RoundtripState;
62

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
typedef enum {
  CHILD_INFO_GET_PROPERTY,
  CHILD_INFO_GET_WA,
  CHILD_INFO_GET_GEOMETRY
} ChildInfoReq;

struct _ChildInfoChildState
{
  gulong seq[3];
};

struct _ChildInfoState
{
  gboolean get_wm_state;
  Window *children;
  guint nchildren;
  GdkChildInfoX11 *child_info;
  ChildInfoChildState *child_states;

  guint current_child;
  guint n_children_found;
  gint current_request;
  gboolean have_error;
  gboolean child_has_error;
};

89 90 91 92 93 94 95 96
struct _ListChildrenState
{
  Display *dpy;
  gulong get_property_req;
  gboolean have_error;
  gboolean has_wm_state;
};

97
struct _SendEventState
98 99 100 101
{
  Display *dpy;
  Window window;
  _XAsyncHandler async;
102 103 104 105 106 107 108 109 110 111 112
  gulong send_event_req;
  gulong get_input_focus_req;
  gboolean have_error;
  GdkSendXEventCallback callback;
  gpointer data;
};

struct _SetInputFocusState
{
  Display *dpy;
  _XAsyncHandler async;
113 114 115 116
  gulong set_input_focus_req;
  gulong get_input_focus_req;
};

117 118 119 120 121
struct _RoundtripState
{
  Display *dpy;
  _XAsyncHandler async;
  gulong get_input_focus_req;
122
  GdkDisplay *display;
123 124 125 126
  GdkRoundTripCallback callback;
  gpointer data;
};

127 128 129 130 131 132 133 134 135 136 137 138
static gboolean
callback_idle (gpointer data)
{
  SendEventState *state = (SendEventState *)data;  
  
  state->callback (state->window, !state->have_error, state->data);

  g_free (state);

  return FALSE;
}

139 140 141 142 143 144 145 146 147 148 149
static Bool
send_event_handler (Display *dpy,
		    xReply  *rep,
		    char    *buf,
		    int      len,
		    XPointer data)
{
  SendEventState *state = (SendEventState *)data;  

  if (dpy->last_request_read == state->send_event_req)
    {
150 151
      if (rep->generic.type == X_Error &&
	  rep->error.errorCode == BadWindow)
152
	{
153 154
	  state->have_error = TRUE;
	  return True;
155 156 157 158 159
	}
    }
  else if (dpy->last_request_read == state->get_input_focus_req)
    {
      xGetInputFocusReply replbuf;
160
      xGetInputFocusReply *repl G_GNUC_UNUSED;
161 162 163
      
      if (rep->generic.type != X_Error)
	{
164 165 166
	  /* Actually does nothing, since there are no additional bytes
	   * to read, but maintain good form.
	   */
167 168 169 170 171 172 173
	  repl = (xGetInputFocusReply *)
	    _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			    (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
			    True);
	}

      if (state->callback)
174 175 176 177 178
        {
          guint id;
          id = gdk_threads_add_idle (callback_idle, state);
          g_source_set_name_by_id (id, "[gtk+] callback_idle");
        }
179 180 181

      DeqAsyncHandler(state->dpy, &state->async);

182
      return (rep->generic.type != X_Error);
183 184 185 186 187
    }

  return False;
}

188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
static void
client_message_to_wire (XClientMessageEvent *ev,
			xEvent              *event)
{
  int i;
  event->u.clientMessage.window = ev->window;
  event->u.u.type = ev->type;
  event->u.u.detail = ev->format;
  switch (ev->format)
    {
    case 8:	
      event->u.clientMessage.u.b.type   = ev->message_type;
      for (i = 0; i < 20; i++)
	event->u.clientMessage.u.b.bytes[i] = ev->data.b[i];
      break;
    case 16:
      event->u.clientMessage.u.s.type   = ev->message_type;
      event->u.clientMessage.u.s.shorts0   = ev->data.s[0];
      event->u.clientMessage.u.s.shorts1   = ev->data.s[1];
      event->u.clientMessage.u.s.shorts2   = ev->data.s[2];
      event->u.clientMessage.u.s.shorts3   = ev->data.s[3];
      event->u.clientMessage.u.s.shorts4   = ev->data.s[4];
      event->u.clientMessage.u.s.shorts5   = ev->data.s[5];
      event->u.clientMessage.u.s.shorts6   = ev->data.s[6];
      event->u.clientMessage.u.s.shorts7   = ev->data.s[7];
      event->u.clientMessage.u.s.shorts8   = ev->data.s[8];
      event->u.clientMessage.u.s.shorts9   = ev->data.s[9];
      break;
    case 32:
      event->u.clientMessage.u.l.type   = ev->message_type;
      event->u.clientMessage.u.l.longs0   = ev->data.l[0];
      event->u.clientMessage.u.l.longs1   = ev->data.l[1];
      event->u.clientMessage.u.l.longs2   = ev->data.l[2];
      event->u.clientMessage.u.l.longs3   = ev->data.l[3];
      event->u.clientMessage.u.l.longs4   = ev->data.l[4];
      break;
    default:
      /* client passing bogus data, let server complain */
      break;
    }
}

230
void
231 232 233 234 235 236 237
_gdk_x11_send_client_message_async (GdkDisplay           *display, 
				    Window                window, 
				    gboolean              propagate,
				    glong                 event_mask,
				    XClientMessageEvent  *event_send,
				    GdkSendXEventCallback callback,
				    gpointer              data)
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
{
  Display *dpy;
  SendEventState *state;
  
  dpy = GDK_DISPLAY_XDISPLAY (display);

  state = g_new (SendEventState, 1);

  state->dpy = dpy;
  state->window = window;
  state->callback = callback;
  state->data = data;
  state->have_error = FALSE;
  
  LockDisplay(dpy);

  state->async.next = dpy->async_handlers;
  state->async.handler = send_event_handler;
  state->async.data = (XPointer) state;
  dpy->async_handlers = &state->async;

  {
    register xSendEventReq *req;
    xEvent ev;
    
263
    client_message_to_wire (event_send, &ev);
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
      
    GetReq(SendEvent, req);
    req->destination = window;
    req->propagate = propagate;
    req->eventMask = event_mask;
    /* gross, matches Xproto.h */
#ifdef WORD64			
    memcpy ((char *) req->eventdata, (char *) &ev, SIZEOF(xEvent));
#else    
    memcpy ((char *) &req->event, (char *) &ev, SIZEOF(xEvent));
#endif
    
    state->send_event_req = dpy->request;
  }

  /*
   * XSync (dpy, 0)
   */
  {
283
    G_GNUC_UNUSED xReq *req;
284 285 286 287 288 289 290 291 292
    
    GetEmptyReq(GetInputFocus, req);
    state->get_input_focus_req = dpy->request;
  }
  
  UnlockDisplay(dpy);
  SyncHandle();
}

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
static Bool
list_children_handler (Display *dpy,
		       xReply  *rep,
		       char    *buf,
		       int      len,
		       XPointer data)
{
  ListChildrenState *state = (ListChildrenState *)data;

  if (dpy->last_request_read != state->get_property_req)
    return False;
  
  if (rep->generic.type == X_Error)
    {
      state->have_error = TRUE;
      return False;
    }
  else
    {
      xGetPropertyReply replbuf;
      xGetPropertyReply *repl;
	    
      repl = (xGetPropertyReply *)
	_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			(sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,
			True);

      state->has_wm_state = repl->propertyType != None;
      /* Since we called GetProperty with longLength of 0, we don't
       * have to worry about consuming the property data that would
       * normally follow after the reply
       */

      return True;
    }
}

static gboolean
list_children_and_wm_state (Display      *dpy,
			    Window        w,
			    Atom          wm_state_atom,
			    gboolean     *has_wm_state,
			    Window      **children,
			    unsigned int *nchildren)
{
  ListChildrenState state;
  _XAsyncHandler async;
  long nbytes;
  xQueryTreeReply rep;
  register xResourceReq *req;
  xGetPropertyReq *prop_req;

  LockDisplay(dpy);

  *children = NULL;
  *nchildren = 0;
  *has_wm_state = FALSE;
  
  state.have_error = FALSE;
  state.has_wm_state = FALSE;

  if (wm_state_atom)
    {
      async.next = dpy->async_handlers;
      async.handler = list_children_handler;
      async.data = (XPointer) &state;
      dpy->async_handlers = &async;

      GetReq (GetProperty, prop_req);
      prop_req->window = w;
      prop_req->property = wm_state_atom;
      prop_req->type = AnyPropertyType;
      prop_req->delete = False;
      prop_req->longOffset = 0;
      prop_req->longLength = 0;
      
      state.get_property_req = dpy->request;
    }
  
  GetResReq(QueryTree, w, req);
  if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
    {
      state.have_error = TRUE;
      goto out;
    }

  if (rep.nChildren != 0)
    {
      nbytes = rep.nChildren << 2;
      if (state.have_error)
	{
	  _XEatData(dpy, (unsigned long) nbytes);
	  goto out;
	}
      *children = g_new (Window, rep.nChildren);
      _XRead32 (dpy, (long *) *children, nbytes);
    }

  *nchildren = rep.nChildren;
  *has_wm_state = state.has_wm_state;

 out:
  if (wm_state_atom)
    DeqAsyncHandler(dpy, &async);
  UnlockDisplay(dpy);
  SyncHandle();
  
  return !state.have_error;
}

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
static void
handle_get_wa_reply (Display                   *dpy,
		     ChildInfoState            *state,
		     xGetWindowAttributesReply *repl)
{
  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];
  child->is_mapped = repl->mapState != IsUnmapped;
  child->window_class = repl->class;
}

static void
handle_get_geometry_reply (Display           *dpy,
			   ChildInfoState    *state,
			   xGetGeometryReply *repl)
{
  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];
  
  child->x = cvtINT16toInt (repl->x);
  child->y = cvtINT16toInt (repl->y);
  child->width = repl->width;
  child->height = repl->height;
}

static void
handle_get_property_reply (Display           *dpy,
			   ChildInfoState    *state,
			   xGetPropertyReply *repl)
{
  GdkChildInfoX11 *child = &state->child_info[state->n_children_found];
  child->has_wm_state = repl->propertyType != None;

  /* Since we called GetProperty with longLength of 0, we don't
   * have to worry about consuming the property data that would
   * normally follow after the reply
   */
}

static void
next_child (ChildInfoState *state)
{
  if (state->current_request == CHILD_INFO_GET_GEOMETRY)
    {
      if (!state->have_error && !state->child_has_error)
	{
	  state->child_info[state->n_children_found].window = state->children[state->current_child];
	  state->n_children_found++;
	}
      state->current_child++;
      if (state->get_wm_state)
	state->current_request = CHILD_INFO_GET_PROPERTY;
      else
	state->current_request = CHILD_INFO_GET_WA;
      state->child_has_error = FALSE;
      state->have_error = FALSE;
    }
  else
    state->current_request++;
}

static Bool
get_child_info_handler (Display *dpy,
			xReply  *rep,
			char    *buf,
			int      len,
			XPointer data)
{
  Bool result = True;
  
  ChildInfoState *state = (ChildInfoState *)data;

  if (dpy->last_request_read != state->child_states[state->current_child].seq[state->current_request])
    return False;
  
  if (rep->generic.type == X_Error)
    {
      state->child_has_error = TRUE;
      if (rep->error.errorCode != BadDrawable ||
	  rep->error.errorCode != BadWindow)
	{
	  state->have_error = TRUE;
	  result = False;
	}
    }
  else
    {
      switch (state->current_request)
	{
	case CHILD_INFO_GET_PROPERTY:
	  {
	    xGetPropertyReply replbuf;
	    xGetPropertyReply *repl;
	    
	    repl = (xGetPropertyReply *)
	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			      (sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,
			      True);
	    
	    handle_get_property_reply (dpy, state, repl);
	  }
	  break;
	case CHILD_INFO_GET_WA:
	  {
	    xGetWindowAttributesReply replbuf;
	    xGetWindowAttributesReply *repl;
	    
	    repl = (xGetWindowAttributesReply *)
	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			      (sizeof(xGetWindowAttributesReply) - sizeof(xReply)) >> 2,
			      True);
	    
	    handle_get_wa_reply (dpy, state, repl);
	  }
	  break;
	case CHILD_INFO_GET_GEOMETRY:
	  {
	    xGetGeometryReply replbuf;
	    xGetGeometryReply *repl;
	    
	    repl = (xGetGeometryReply *)
	      _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			      (sizeof(xGetGeometryReply) - sizeof(xReply)) >> 2,
			      True);
	    
	    handle_get_geometry_reply (dpy, state, repl);
	  }
	  break;
	}
    }

  next_child (state);

  return result;
}

gboolean
_gdk_x11_get_window_child_info (GdkDisplay       *display,
				Window            window,
				gboolean          get_wm_state,
541
				gboolean         *win_has_wm_state,
542 543 544 545 546 547 548
				GdkChildInfoX11 **children,
				guint            *nchildren)
{
  Display *dpy;
  _XAsyncHandler async;
  ChildInfoState state;
  Atom wm_state_atom;
549
  gboolean has_wm_state;
550 551 552 553 554 555 556
  Bool result;
  guint i;

  *children = NULL;
  *nchildren = 0;
  
  dpy = GDK_DISPLAY_XDISPLAY (display);
557 558 559 560
  if (get_wm_state)
    wm_state_atom = gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE");
  else
    wm_state_atom = None;
561

562 563 564
  state.children = NULL;
  state.nchildren = 0;

565
  gdk_x11_display_error_trap_push (display);
566 567 568 569
  result = list_children_and_wm_state (dpy, window,
				       win_has_wm_state ? wm_state_atom : None,
				       &has_wm_state,
				       &state.children, &state.nchildren);
570
  gdk_x11_display_error_trap_pop_ignored (display);
571
  if (!result)
572 573 574 575
    {
      g_free (state.children);
      return FALSE;
    }
576

577 578 579 580
  if (has_wm_state)
    {
      if (win_has_wm_state)
	*win_has_wm_state = TRUE;
581
      g_free (state.children);
582 583 584 585 586 587 588 589
      return TRUE;
    }
  else
    {
      if (win_has_wm_state)
	*win_has_wm_state = FALSE;
    }

590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
  state.get_wm_state = get_wm_state;
  state.child_info = g_new (GdkChildInfoX11, state.nchildren);
  state.child_states = g_new (ChildInfoChildState, state.nchildren);
  state.current_child = 0;
  state.n_children_found = 0;
  if (get_wm_state)
    state.current_request = CHILD_INFO_GET_PROPERTY;
  else
    state.current_request = CHILD_INFO_GET_WA;
  state.have_error = FALSE;
  state.child_has_error = FALSE;

  LockDisplay(dpy);

  async.next = dpy->async_handlers;
  async.handler = get_child_info_handler;
  async.data = (XPointer) &state;
  dpy->async_handlers = &async;
  
  for (i = 0; i < state.nchildren; i++)
    {
      xResourceReq *resource_req;
      xGetPropertyReq *prop_req;
      Window window = state.children[i];
      
      if (get_wm_state)
	{
	  GetReq (GetProperty, prop_req);
	  prop_req->window = window;
	  prop_req->property = wm_state_atom;
	  prop_req->type = AnyPropertyType;
	  prop_req->delete = False;
	  prop_req->longOffset = 0;
	  prop_req->longLength = 0;

	  state.child_states[i].seq[CHILD_INFO_GET_PROPERTY] = dpy->request;
	}
      
      GetResReq(GetWindowAttributes, window, resource_req);
      state.child_states[i].seq[CHILD_INFO_GET_WA] = dpy->request;
      
      GetResReq(GetGeometry, window, resource_req);
      state.child_states[i].seq[CHILD_INFO_GET_GEOMETRY] = dpy->request;
    }

  if (i != 0)
    {
      /* Wait for the last reply
       */
      xGetGeometryReply rep;

      /* On error, our async handler will get called
       */
      if (_XReply (dpy, (xReply *)&rep, 0, xTrue))
	handle_get_geometry_reply (dpy, &state, &rep);

      next_child (&state);
    }

  if (!state.have_error)
    {
      *children = state.child_info;
      *nchildren = state.n_children_found;
    }
  else
    {
      g_free (state.child_info);
    }

659
  g_free (state.children);
660 661 662 663 664 665 666 667 668
  g_free (state.child_states);
  
  DeqAsyncHandler(dpy, &async);
  UnlockDisplay(dpy);
  SyncHandle();

  return !state.have_error;
}

669 670 671 672 673
static gboolean
roundtrip_callback_idle (gpointer data)
{
  RoundtripState *state = (RoundtripState *)data;  
  
674
  state->callback (state->display, state->data, state->get_input_focus_req);
675 676 677 678 679 680 681 682 683 684 685 686 687

  g_free (state);

  return FALSE;
}

static Bool
roundtrip_handler (Display *dpy,
		   xReply  *rep,
		   char    *buf,
		   int      len,
		   XPointer data)
{
688
  RoundtripState *state = (RoundtripState *)data;  
689 690 691 692
  
  if (dpy->last_request_read == state->get_input_focus_req)
    {
      xGetInputFocusReply replbuf;
693
      xGetInputFocusReply *repl G_GNUC_UNUSED;
694 695 696 697 698 699 700 701 702 703 704 705
      
      if (rep->generic.type != X_Error)
	{
	  /* Actually does nothing, since there are no additional bytes
	   * to read, but maintain good form.
	   */
	  repl = (xGetInputFocusReply *)
	    _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
			    (sizeof(xGetInputFocusReply) - sizeof(xReply)) >> 2,
			    True);
	}

706
      
707
      if (state->callback)
708 709 710 711 712
        {
          guint id;
          id = gdk_threads_add_idle (roundtrip_callback_idle, state);
          g_source_set_name_by_id (id, "[gtk+] roundtrip_callback_idle");
        }
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733

      DeqAsyncHandler(state->dpy, &state->async);

      return (rep->generic.type != X_Error);
    }

  return False;
}

void
_gdk_x11_roundtrip_async (GdkDisplay           *display, 
			  GdkRoundTripCallback callback,
			  gpointer              data)
{
  Display *dpy;
  RoundtripState *state;
  
  dpy = GDK_DISPLAY_XDISPLAY (display);

  state = g_new (RoundtripState, 1);

734
  state->display = display;
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
  state->dpy = dpy;
  state->callback = callback;
  state->data = data;
  
  LockDisplay(dpy);

  state->async.next = dpy->async_handlers;
  state->async.handler = roundtrip_handler;
  state->async.data = (XPointer) state;
  dpy->async_handlers = &state->async;

  /*
   * XSync (dpy, 0)
   */
  {
750
    G_GNUC_UNUSED xReq *req;
751 752 753 754 755 756 757 758
    
    GetEmptyReq(GetInputFocus, req);
    state->get_input_focus_req = dpy->request;
  }
  
  UnlockDisplay(dpy);
  SyncHandle();
}