gdk.c 30.5 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10
/* GDK - The GIMP Drawing Kit
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library 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
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
Elliot Lee's avatar
Elliot Lee committed
12 13 14
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
15 16 17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19 20 21 22 23 24 25 26

/*
 * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

27
#include "config.h"
Elliot Lee's avatar
Elliot Lee committed
28 29 30 31 32 33

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
34
#include <errno.h>
Elliot Lee's avatar
Elliot Lee committed
35 36 37 38 39 40 41 42 43 44 45 46 47

#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H_ */

#define XLIB_ILLEGAL_ACCESS
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xutil.h>
#include <X11/Xmu/WinUtil.h>
#include <X11/cursorfont.h>

Owen Taylor's avatar
Started  
Owen Taylor committed
48
#include "gdk.h"
Elliot Lee's avatar
Elliot Lee committed
49

50
#include "gdkx.h"
Owen Taylor's avatar
Started  
Owen Taylor committed
51 52
#include "gdkprivate.h"
#include "gdkinputprivate.h"
Elliot Lee's avatar
Elliot Lee committed
53 54

typedef struct _GdkPredicate  GdkPredicate;
55
typedef struct _GdkErrorTrap  GdkErrorTrap;
Elliot Lee's avatar
Elliot Lee committed
56 57 58 59 60 61 62

struct _GdkPredicate
{
  GdkEventFunc func;
  gpointer data;
};

63 64 65 66 67 68
struct _GdkErrorTrap
{
  gint error_warnings;
  gint error_code;
};

Elliot Lee's avatar
Elliot Lee committed
69 70 71
/* 
 * Private function declarations
 */
72

73
#ifndef HAVE_XCONVERTCASE
74 75 76
static void	 gdkx_XConvertCase	(KeySym	       symbol,
					 KeySym	      *lower,
					 KeySym	      *upper);
77 78 79
#define XConvertCase gdkx_XConvertCase
#endif

80 81
static void	    gdk_exit_func		 (void);
static int	    gdk_x_error			 (Display     *display, 
Elliot Lee's avatar
Elliot Lee committed
82
						  XErrorEvent *error);
83
static int	    gdk_x_io_error		 (Display     *display);
Elliot Lee's avatar
Elliot Lee committed
84

85 86 87 88
GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
					 GdkEvent  *event,
					 gpointer   data);

Elliot Lee's avatar
Elliot Lee committed
89 90
/* Private variable declarations
 */
91
static int gdk_initialized = 0;			    /* 1 if the library is initialized,
Elliot Lee's avatar
Elliot Lee committed
92 93 94 95 96
						     * 0 otherwise.
						     */

static gint autorepeat;

97 98 99
static GSList *gdk_error_traps = NULL;               /* List of error traps */
static GSList *gdk_error_trap_free_list = NULL;      /* Free list */

100
#ifdef G_ENABLE_DEBUG
101
static const GDebugKey gdk_debug_keys[] = {
102 103 104
  {"events",	    GDK_DEBUG_EVENTS},
  {"misc",	    GDK_DEBUG_MISC},
  {"dnd",	    GDK_DEBUG_DND},
105
  {"color-context", GDK_DEBUG_COLOR_CONTEXT},
106
  {"xim",	    GDK_DEBUG_XIM}
107
};
108 109 110

static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);

111
#endif /* G_ENABLE_DEBUG */
Elliot Lee's avatar
Elliot Lee committed
112 113 114

/*
 *--------------------------------------------------------------
115
 * gdk_init_heck
Elliot Lee's avatar
Elliot Lee committed
116 117 118 119 120 121 122 123 124 125
 *
 *   Initialize the library for use.
 *
 * Arguments:
 *   "argc" is the number of arguments.
 *   "argv" is an array of strings.
 *
 * Results:
 *   "argc" and "argv" are modified to reflect any arguments
 *   which were not handled. (Such arguments should either
126 127
 *   be handled by the application or dismissed). If initialization
 *   fails, returns FALSE, otherwise TRUE.
Elliot Lee's avatar
Elliot Lee committed
128 129 130 131 132 133 134
 *
 * Side effects:
 *   The library is initialized.
 *
 *--------------------------------------------------------------
 */

135 136 137
gboolean
gdk_init_check (int	 *argc,
		char ***argv)
Elliot Lee's avatar
Elliot Lee committed
138 139
{
  XKeyboardState keyboard_state;
140 141
  gint synchronize;
  gint i, j, k;
Elliot Lee's avatar
Elliot Lee committed
142
  XClassHint *class_hint;
143 144
  gchar **argv_orig = NULL;
  gint argc_orig = 0;
145
  
146
  if (gdk_initialized)
147
    return TRUE;
148
  
149 150 151
  if (g_thread_supported ())
    gdk_threads_mutex = g_mutex_new ();
  
152 153 154 155 156 157 158 159 160
  if (argc && argv)
    {
      argc_orig = *argc;
      
      argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
      for (i = 0; i < argc_orig; i++)
	argv_orig[i] = g_strdup ((*argv)[i]);
      argv_orig[argc_orig] = NULL;
    }
161
  
Elliot Lee's avatar
Elliot Lee committed
162
  gdk_display_name = NULL;
163
  
Elliot Lee's avatar
Elliot Lee committed
164 165
  XSetErrorHandler (gdk_x_error);
  XSetIOErrorHandler (gdk_x_io_error);
166
  
Elliot Lee's avatar
Elliot Lee committed
167
  synchronize = FALSE;
168
  
169 170 171 172 173
#ifdef G_ENABLE_DEBUG
  {
    gchar *debug_string = getenv("GDK_DEBUG");
    if (debug_string != NULL)
      gdk_debug_flags = g_parse_debug_string (debug_string,
174
					      (GDebugKey *) gdk_debug_keys,
175 176 177
					      gdk_ndebug_keys);
  }
#endif	/* G_ENABLE_DEBUG */
178
  
Elliot Lee's avatar
Elliot Lee committed
179 180 181
  if (argc && argv)
    {
      if (*argc > 0)
182 183
	{
	  gchar *d;
184
	  
185 186
	  d = strrchr((*argv)[0],'/');
	  if (d != NULL)
187
	    g_set_prgname (d + 1);
188
	  else
189
	    g_set_prgname ((*argv)[0]);
190
	}
191
      
Elliot Lee's avatar
Elliot Lee committed
192 193
      for (i = 1; i < *argc;)
	{
194
#ifdef G_ENABLE_DEBUG	  
195 196
	  if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
	      (strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
Elliot Lee's avatar
Elliot Lee committed
197
	    {
198 199 200 201 202
	      gchar *equal_pos = strchr ((*argv)[i], '=');
	      
	      if (equal_pos != NULL)
		{
		  gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
203
							   (GDebugKey *) gdk_debug_keys,
204 205 206
							   gdk_ndebug_keys);
		}
	      else if ((i + 1) < *argc && (*argv)[i + 1])
Elliot Lee's avatar
Elliot Lee committed
207
		{
208
		  gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
209
							   (GDebugKey *) gdk_debug_keys,
210
							   gdk_ndebug_keys);
211
		  (*argv)[i] = NULL;
212 213
		  i += 1;
		}
214
	      (*argv)[i] = NULL;
215
	    }
216 217
	  else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
		   (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
218
	    {
219
	      gchar *equal_pos = strchr ((*argv)[i], '=');
220
	      
221 222 223
	      if (equal_pos != NULL)
		{
		  gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
224
							    (GDebugKey *) gdk_debug_keys,
225 226 227
							    gdk_ndebug_keys);
		}
	      else if ((i + 1) < *argc && (*argv)[i + 1])
228 229
		{
		  gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
230
							    (GDebugKey *) gdk_debug_keys,
231
							    gdk_ndebug_keys);
232
		  (*argv)[i] = NULL;
Elliot Lee's avatar
Elliot Lee committed
233 234
		  i += 1;
		}
235
	      (*argv)[i] = NULL;
Elliot Lee's avatar
Elliot Lee committed
236
	    }
Owen Taylor's avatar
Owen Taylor committed
237
	  else 
238
#endif /* G_ENABLE_DEBUG */
Owen Taylor's avatar
Owen Taylor committed
239
	    if (strcmp ("--display", (*argv)[i]) == 0)
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
	      {
		(*argv)[i] = NULL;
		
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    gdk_display_name = g_strdup ((*argv)[i + 1]);
		    (*argv)[i + 1] = NULL;
		    i += 1;
		  }
	      }
	    else if (strcmp ("--sync", (*argv)[i]) == 0)
	      {
		(*argv)[i] = NULL;
		synchronize = TRUE;
	      }
	    else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
	      {
		(*argv)[i] = NULL;
		gdk_use_xshm = FALSE;
	      }
	    else if (strcmp ("--name", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
265
		    g_set_prgname ((*argv)[i]);
266 267 268 269 270 271 272 273 274 275 276 277
		    (*argv)[i] = NULL;
		  }
	      }
	    else if (strcmp ("--class", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
		    gdk_progclass = (*argv)[i];
		    (*argv)[i] = NULL;
		  }
	      }
Elliot Lee's avatar
Elliot Lee committed
278
#ifdef XINPUT_GXI
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
	    else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
		    gdk_input_gxid_host = ((*argv)[i]);
		    (*argv)[i] = NULL;
		  }
	      }
	    else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
		    gdk_input_gxid_port = atoi ((*argv)[i]);
		    (*argv)[i] = NULL;
		  }
	      }
Elliot Lee's avatar
Elliot Lee committed
297
#endif
298
#ifdef USE_XIM
299 300 301 302 303 304
	    else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
		    if (strcmp ("none", (*argv)[i]) == 0)
305
		      gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
306
		    else if (strcmp ("nothing", (*argv)[i]) == 0)
307
		      gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
308
		    else if (strcmp ("area", (*argv)[i]) == 0)
309
		      gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
310
		    else if (strcmp ("position", (*argv)[i]) == 0)
311
		      gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
312
		    else if (strcmp ("callbacks", (*argv)[i]) == 0)
313
		      gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
314
		    (*argv)[i] = NULL;
315 316 317 318 319 320 321 322
		  }
	      }
	    else if (strcmp ("--xim-status", (*argv)[i]) == 0)
	      {
		if ((i + 1) < *argc && (*argv)[i + 1])
		  {
		    (*argv)[i++] = NULL;
		    if (strcmp ("none", (*argv)[i]) == 0)
323
		      gdk_im_set_best_style (GDK_IM_STATUS_NONE);
324
		    else if (strcmp ("nothing", (*argv)[i]) == 0)
325
		      gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
326
		    else if (strcmp ("area", (*argv)[i]) == 0)
327
		      gdk_im_set_best_style (GDK_IM_STATUS_AREA);
328
		    else if (strcmp ("callbacks", (*argv)[i]) == 0)
329
		      gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
330
		    (*argv)[i] = NULL;
331 332
		  }
	      }
333
#endif
334
	  
Elliot Lee's avatar
Elliot Lee committed
335 336
	  i += 1;
	}
337
      
Elliot Lee's avatar
Elliot Lee committed
338 339 340 341 342
      for (i = 1; i < *argc; i++)
	{
	  for (k = i; k < *argc; k++)
	    if ((*argv)[k] != NULL)
	      break;
343
	  
Elliot Lee's avatar
Elliot Lee committed
344 345 346 347 348 349 350 351 352 353 354
	  if (k > i)
	    {
	      k -= i;
	      for (j = i + k; j < *argc; j++)
		(*argv)[j-k] = (*argv)[j];
	      *argc -= k;
	    }
	}
    }
  else
    {
355
      g_set_prgname ("<unknown>");
Elliot Lee's avatar
Elliot Lee committed
356
    }
357
  
358
  GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
359
  
Elliot Lee's avatar
Elliot Lee committed
360 361
  gdk_display = XOpenDisplay (gdk_display_name);
  if (!gdk_display)
362
    return FALSE;
363
  
Elliot Lee's avatar
Elliot Lee committed
364 365
  if (synchronize)
    XSynchronize (gdk_display, True);
366
  
Elliot Lee's avatar
Elliot Lee committed
367 368
  gdk_screen = DefaultScreen (gdk_display);
  gdk_root_window = RootWindow (gdk_display, gdk_screen);
369
  
Elliot Lee's avatar
Elliot Lee committed
370 371 372
  gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window,
					  10, 10, 10, 10, 0, 0 , 0);
  class_hint = XAllocClassHint();
373
  class_hint->res_name = g_get_prgname ();
374 375
  if (gdk_progclass == NULL)
    {
376
      gdk_progclass = g_strdup (g_get_prgname ());
377 378
      gdk_progclass[0] = toupper (gdk_progclass[0]);
    }
Elliot Lee's avatar
Elliot Lee committed
379
  class_hint->res_class = gdk_progclass;
380 381 382
  XmbSetWMProperties (gdk_display, gdk_leader_window,
                      NULL, NULL, argv_orig, argc_orig, 
                      NULL, NULL, class_hint);
Elliot Lee's avatar
Elliot Lee committed
383
  XFree (class_hint);
384 385 386 387 388
  
  for (i = 0; i < argc_orig; i++)
    g_free(argv_orig[i]);
  g_free(argv_orig);
  
389 390 391
  gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
  gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
  gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
Elliot Lee's avatar
Elliot Lee committed
392 393 394
  gdk_wm_window_protocols[0] = gdk_wm_delete_window;
  gdk_wm_window_protocols[1] = gdk_wm_take_focus;
  gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
395
  
Elliot Lee's avatar
Elliot Lee committed
396 397
  XGetKeyboardControl (gdk_display, &keyboard_state);
  autorepeat = keyboard_state.global_auto_repeat;
398
  
Tim Janik's avatar
Tim Janik committed
399
  g_atexit (gdk_exit_func);
400
  
401
  gdk_events_init ();
Elliot Lee's avatar
Elliot Lee committed
402 403 404 405
  gdk_visual_init ();
  gdk_window_init ();
  gdk_image_init ();
  gdk_input_init ();
406 407
  gdk_dnd_init ();

408
#ifdef USE_XIM
409
  gdk_im_open ();
410
#endif
411
  
412
  gdk_initialized = 1;
413 414 415 416 417 418 419 420 421 422 423 424

  return TRUE;
}

void
gdk_init (int *argc, char ***argv)
{
  if (!gdk_init_check (argc, argv))
    {
      g_warning ("cannot open display: %s", gdk_get_display ());
      exit(1);
    }
Elliot Lee's avatar
Elliot Lee committed
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
}

/*
 *--------------------------------------------------------------
 * gdk_exit
 *
 *   Restores the library to an un-itialized state and exits
 *   the program using the "exit" system call.
 *
 * Arguments:
 *   "errorcode" is the error value to pass to "exit".
 *
 * Results:
 *   Allocated structures are freed and the program exits
 *   cleanly.
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

void
Tor Lillqvist's avatar
Tor Lillqvist committed
447
gdk_exit (gint errorcode)
Elliot Lee's avatar
Elliot Lee committed
448
{
449 450 451
  /* de-initialisation is done by the gdk_exit_funct(),
     no need to do this here (Alex J.) */
  exit (errorcode);
Elliot Lee's avatar
Elliot Lee committed
452 453
}

454 455 456 457 458 459 460 461 462 463 464 465
void
gdk_set_use_xshm (gint use_xshm)
{
  gdk_use_xshm = use_xshm;
}

gint
gdk_get_use_xshm (void)
{
  return gdk_use_xshm;
}

Elliot Lee's avatar
Elliot Lee committed
466 467
/*
 *--------------------------------------------------------------
468
 * gdk_pointer_grab
Elliot Lee's avatar
Elliot Lee committed
469
 *
470
 *   Grabs the pointer to a specific window
Elliot Lee's avatar
Elliot Lee committed
471 472
 *
 * Arguments:
473 474 475 476 477 478 479
 *   "window" is the window which will receive the grab
 *   "owner_events" specifies whether events will be reported as is,
 *     or relative to "window"
 *   "event_mask" masks only interesting events
 *   "confine_to" limits the cursor movement to the specified window
 *   "cursor" changes the cursor for the duration of the grab
 *   "time" specifies the time
Elliot Lee's avatar
Elliot Lee committed
480 481 482 483
 *
 * Results:
 *
 * Side effects:
484
 *   requires a corresponding call to gdk_pointer_ungrab
Elliot Lee's avatar
Elliot Lee committed
485 486 487 488
 *
 *--------------------------------------------------------------
 */

489 490 491 492 493 494 495
gint
gdk_pointer_grab (GdkWindow *	  window,
		  gint		  owner_events,
		  GdkEventMask	  event_mask,
		  GdkWindow *	  confine_to,
		  GdkCursor *	  cursor,
		  guint32	  time)
Elliot Lee's avatar
Elliot Lee committed
496
{
497 498 499 500 501 502 503
  gint return_val;
  GdkCursorPrivate *cursor_private;
  guint xevent_mask;
  Window xwindow;
  Window xconfine_to;
  Cursor xcursor;
  int i;
Elliot Lee's avatar
Elliot Lee committed
504
  
505
  g_return_val_if_fail (window != NULL, 0);
506 507
  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
  g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
508
  
509
  cursor_private = (GdkCursorPrivate*) cursor;
510
  
511
  xwindow = GDK_DRAWABLE_XID (window);
512
  
513
  if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to))
514 515
    xconfine_to = None;
  else
516
    xconfine_to = GDK_DRAWABLE_XID (confine_to);
517
  
518 519 520 521
  if (!cursor)
    xcursor = None;
  else
    xcursor = cursor_private->xcursor;
522 523
  
  
524 525
  xevent_mask = 0;
  for (i = 0; i < gdk_nevent_masks; i++)
Owen Taylor's avatar
Owen Taylor committed
526
    {
527 528
      if (event_mask & (1 << (i + 1)))
	xevent_mask |= gdk_event_mask_table[i];
Owen Taylor's avatar
Owen Taylor committed
529
    }
530
  
531 532 533 534 535 536
  if (gdk_input_vtable.grab_pointer)
    return_val = gdk_input_vtable.grab_pointer (window,
						owner_events,
						event_mask,
						confine_to,
						time);
537
  else
538
    return_val = Success;
539
  
540
  if (return_val == Success)
Elliot Lee's avatar
Elliot Lee committed
541
    {
542 543
      if (!GDK_DRAWABLE_DESTROYED (window))
	return_val = XGrabPointer (GDK_DRAWABLE_XDISPLAY (window),
544 545 546 547 548 549 550 551 552
				   xwindow,
				   owner_events,
				   xevent_mask,
				   GrabModeAsync, GrabModeAsync,
				   xconfine_to,
				   xcursor,
				   time);
      else
	return_val = AlreadyGrabbed;
Elliot Lee's avatar
Elliot Lee committed
553
    }
554
  
555
  if (return_val == GrabSuccess)
556
    gdk_xgrab_window = (GdkWindowPrivate *)window;
557
  
558
  return return_val;
Elliot Lee's avatar
Elliot Lee committed
559 560 561 562
}

/*
 *--------------------------------------------------------------
563
 * gdk_pointer_ungrab
Elliot Lee's avatar
Elliot Lee committed
564
 *
565
 *   Releases any pointer grab
Elliot Lee's avatar
Elliot Lee committed
566 567 568 569 570 571 572 573 574 575
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

576 577
void
gdk_pointer_ungrab (guint32 time)
Elliot Lee's avatar
Elliot Lee committed
578
{
579 580 581 582 583
  if (gdk_input_vtable.ungrab_pointer)
    gdk_input_vtable.ungrab_pointer (time);
  
  XUngrabPointer (gdk_display, time);
  gdk_xgrab_window = NULL;
Elliot Lee's avatar
Elliot Lee committed
584 585 586 587
}

/*
 *--------------------------------------------------------------
588
 * gdk_pointer_is_grabbed
Elliot Lee's avatar
Elliot Lee committed
589
 *
590
 *   Tell wether there is an active x pointer grab in effect
Elliot Lee's avatar
Elliot Lee committed
591 592 593 594 595 596 597 598 599 600
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

601
gint
602
gdk_pointer_is_grabbed (void)
Elliot Lee's avatar
Elliot Lee committed
603
{
604
  return gdk_xgrab_window != NULL;
Elliot Lee's avatar
Elliot Lee committed
605 606 607 608
}

/*
 *--------------------------------------------------------------
609
 * gdk_keyboard_grab
Elliot Lee's avatar
Elliot Lee committed
610
 *
611
 *   Grabs the keyboard to a specific window
Elliot Lee's avatar
Elliot Lee committed
612 613 614 615 616 617 618 619 620 621
 *
 * Arguments:
 *   "window" is the window which will receive the grab
 *   "owner_events" specifies whether events will be reported as is,
 *     or relative to "window"
 *   "time" specifies the time
 *
 * Results:
 *
 * Side effects:
622
 *   requires a corresponding call to gdk_keyboard_ungrab
Elliot Lee's avatar
Elliot Lee committed
623
 *
624 625
 *--------------------------------------------------------------
 */
626

627 628 629 630 631 632
gint
gdk_keyboard_grab (GdkWindow *	   window,
		   gint		   owner_events,
		   guint32	   time)
{
  g_return_val_if_fail (window != NULL, 0);
633
  g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
634
  
635 636 637
  if (!GDK_DRAWABLE_DESTROYED (window))
    return XGrabKeyboard (GDK_DRAWABLE_XDISPLAY (window),
			  GDK_DRAWABLE_XID (window),
638 639 640 641 642
			  owner_events,
			  GrabModeAsync, GrabModeAsync,
			  time);
  else
    return AlreadyGrabbed;
Elliot Lee's avatar
Elliot Lee committed
643 644
}

645 646 647 648 649 650 651 652 653 654 655 656 657 658
/*
 *--------------------------------------------------------------
 * gdk_keyboard_ungrab
 *
 *   Releases any keyboard grab
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */
659

660 661 662 663 664
void
gdk_keyboard_ungrab (guint32 time)
{
  XUngrabKeyboard (gdk_display, time);
}
665

666 667 668 669 670 671 672 673 674 675 676 677 678 679
/*
 *--------------------------------------------------------------
 * gdk_screen_width
 *
 *   Return the width of the screen.
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */
680

681 682 683 684 685 686 687 688
gint
gdk_screen_width (void)
{
  gint return_val;
  
  return_val = DisplayWidth (gdk_display, gdk_screen);
  
  return return_val;
689 690
}

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
/*
 *--------------------------------------------------------------
 * gdk_screen_height
 *
 *   Return the height of the screen.
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

gint
gdk_screen_height (void)
Elliot Lee's avatar
Elliot Lee committed
708
{
709
  gint return_val;
710
  
711
  return_val = DisplayHeight (gdk_display, gdk_screen);
712
  
713
  return return_val;
Elliot Lee's avatar
Elliot Lee committed
714 715
}

716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
/*
 *--------------------------------------------------------------
 * gdk_screen_width_mm
 *
 *   Return the width of the screen in millimeters.
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

gint
gdk_screen_width_mm (void)
Elliot Lee's avatar
Elliot Lee committed
733
{
734 735 736
  gint return_val;
  
  return_val = DisplayWidthMM (gdk_display, gdk_screen);
737
  
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
  return return_val;
}

/*
 *--------------------------------------------------------------
 * gdk_screen_height
 *
 *   Return the height of the screen in millimeters.
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

gint
gdk_screen_height_mm (void)
{
  gint return_val;
760
  
761
  return_val = DisplayHeightMM (gdk_display, gdk_screen);
762
  
763 764 765
  return return_val;
}

766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802
/*
 *--------------------------------------------------------------
 * gdk_set_sm_client_id
 *
 *   Set the SM_CLIENT_ID property on the WM_CLIENT_LEADER window
 *   so that the window manager can save our state using the
 *   X11R6 ICCCM session management protocol. A NULL value should 
 *   be set following disconnection from the session manager to
 *   remove the SM_CLIENT_ID property.
 *
 * Arguments:
 * 
 *   "sm_client_id" specifies the client id assigned to us by the
 *   session manager or NULL to remove the property.
 *
 * Results:
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

void
gdk_set_sm_client_id (const gchar* sm_client_id)
{
  if (sm_client_id && strcmp (sm_client_id, ""))
    {
      XChangeProperty (gdk_display, gdk_leader_window,
	   	       gdk_atom_intern ("SM_CLIENT_ID", FALSE),
		       XA_STRING, 8, PropModeReplace,
		       sm_client_id, strlen(sm_client_id));
    }
  else
     XDeleteProperty (gdk_display, gdk_leader_window,
	   	      gdk_atom_intern ("SM_CLIENT_ID", FALSE));
}

803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
void
gdk_key_repeat_disable (void)
{
  XAutoRepeatOff (gdk_display);
}

void
gdk_key_repeat_restore (void)
{
  if (autorepeat)
    XAutoRepeatOn (gdk_display);
  else
    XAutoRepeatOff (gdk_display);
}


void
gdk_beep (void)
{
822
  XBell(gdk_display, 0);
Elliot Lee's avatar
Elliot Lee committed
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
}

/*
 *--------------------------------------------------------------
 * gdk_exit_func
 *
 *   This is the "atexit" function that makes sure the
 *   library gets a chance to cleanup.
 *
 * Arguments:
 *
 * Results:
 *
 * Side effects:
 *   The library is un-initialized and the program exits.
 *
 *--------------------------------------------------------------
 */

static void
843
gdk_exit_func (void)
Elliot Lee's avatar
Elliot Lee committed
844
{
845
  static gboolean in_gdk_exit_func = FALSE;
846
  
847 848
  /* This is to avoid an infinite loop if a program segfaults in
     an atexit() handler (and yes, it does happen, especially if a program
849
     has trounced over memory too badly for even g_message to work) */
850 851
  if (in_gdk_exit_func == TRUE)
    return;
852
  in_gdk_exit_func = TRUE;
853
  
854
  if (gdk_initialized)
Elliot Lee's avatar
Elliot Lee committed
855
    {
856 857 858 859 860 861
#ifdef USE_XIM
      /* cleanup IC */
      gdk_ic_cleanup ();
      /* close IM */
      gdk_im_close ();
#endif
Elliot Lee's avatar
Elliot Lee committed
862 863 864
      gdk_image_exit ();
      gdk_input_exit ();
      gdk_key_repeat_restore ();
865
      
Elliot Lee's avatar
Elliot Lee committed
866
      XCloseDisplay (gdk_display);
867
      gdk_initialized = 0;
Elliot Lee's avatar
Elliot Lee committed
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
    }
}

/*
 *--------------------------------------------------------------
 * gdk_x_error
 *
 *   The X error handling routine.
 *
 * Arguments:
 *   "display" is the X display the error orignated from.
 *   "error" is the XErrorEvent that we are handling.
 *
 * Results:
 *   Either we were expecting some sort of error to occur,
 *   in which case we set the "gdk_error_code" flag, or this
 *   error was unexpected, in which case we will print an
 *   error message and exit. (Since trying to continue will
 *   most likely simply lead to more errors).
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

static int
894
gdk_x_error (Display	 *display,
Elliot Lee's avatar
Elliot Lee committed
895 896
	     XErrorEvent *error)
{
897
  if (error->error_code)
Elliot Lee's avatar
Elliot Lee committed
898
    {
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
      if (gdk_error_warnings)
	{
	  char buf[64];
	  
	  XGetErrorText (display, error->error_code, buf, 63);

#ifdef G_ENABLE_DEBUG	  
	  g_error ("%s\n  serial %ld error_code %d request_code %d minor_code %d\n", 
		   buf, 
		   error->serial, 
		   error->error_code, 
		   error->request_code,
		   error->minor_code);
#else /* !G_ENABLE_DEBUG */
	  fprintf (stderr, "Gdk-ERROR **: %s\n  serial %ld error_code %d request_code %d minor_code %d\n",
		   buf, 
		   error->serial, 
		   error->error_code, 
		   error->request_code,
		   error->minor_code);

	  exit(1);
#endif /* G_ENABLE_DEBUG */
	}
      gdk_error_code = error->error_code;
Elliot Lee's avatar
Elliot Lee committed
924
    }
925
  
Elliot Lee's avatar
Elliot Lee committed
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
  return 0;
}

/*
 *--------------------------------------------------------------
 * gdk_x_io_error
 *
 *   The X I/O error handling routine.
 *
 * Arguments:
 *   "display" is the X display the error orignated from.
 *
 * Results:
 *   An X I/O error basically means we lost our connection
 *   to the X server. There is not much we can do to
 *   continue, so simply print an error message and exit.
 *
 * Side effects:
 *
 *--------------------------------------------------------------
 */

static int
gdk_x_io_error (Display *display)
{
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971
  /* This is basically modelled after the code in XLib. We need
   * an explicit error handler here, so we can disable our atexit()
   * which would otherwise cause a nice segfault.
   * We fprintf(stderr, instead of g_warning() because g_warning()
   * could possibly be redirected to a dialog
   */
  if (errno == EPIPE)
    {
      fprintf (stderr, "Gdk-ERROR **: X connection to %s broken (explicit kill or server shutdown).\n", gdk_display ? DisplayString (gdk_display) : gdk_get_display());
    }
  else
    {
      fprintf (stderr, "Gdk-ERROR **: Fatal IO error %d (%s) on X server %s.\n",
	       errno, g_strerror (errno),
	       gdk_display ? DisplayString (gdk_display) : gdk_get_display());
    }

  /* Disable the atexit shutdown for GDK */
  gdk_initialized = 0;
  
  exit(1);
Elliot Lee's avatar
Elliot Lee committed
972 973
}

Manish Singh's avatar
Manish Singh committed
974
gchar *
975
gdk_get_display (void)
Manish Singh's avatar
Manish Singh committed
976 977 978
{
  return (gchar *)XDisplayName (gdk_display_name);
}
979

980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
/*************************************************************
 * gdk_error_trap_push:
 *     Push an error trap. X errors will be trapped until
 *     the corresponding gdk_error_pop(), which will return
 *     the error code, if any.
 *   arguments:
 *     
 *   results:
 *************************************************************/

void
gdk_error_trap_push (void)
{
  GSList *node;
  GdkErrorTrap *trap;

  if (gdk_error_trap_free_list)
    {
      node = gdk_error_trap_free_list;
      gdk_error_trap_free_list = gdk_error_trap_free_list->next;
    }
  else
    {
1003
      node = g_slist_alloc ();
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
      node->data = g_new (GdkErrorTrap, 1);
    }

  node->next = gdk_error_traps;
  gdk_error_traps = node;
  
  trap = node->data;
  trap->error_code = gdk_error_code;
  trap->error_warnings = gdk_error_warnings;

  gdk_error_code = 0;
  gdk_error_warnings = 0;
}

/*************************************************************
 * gdk_error_trap_pop:
 *     Pop an error trap added with gdk_error_push()
 *   arguments:
 *     
 *   results:
 *     0, if no error occured, otherwise the error code.
 *************************************************************/

gint
gdk_error_trap_pop (void)
{
  GSList *node;
  GdkErrorTrap *trap;
  gint result;

  g_return_val_if_fail (gdk_error_traps != NULL, 0);

  node = gdk_error_traps;
  gdk_error_traps = gdk_error_traps->next;

  node->next = gdk_error_trap_free_list;
  gdk_error_trap_free_list = node;
  
  result = gdk_error_code;
  
  trap = node->data;
  gdk_error_code = trap->error_code;
  gdk_error_warnings = trap->error_warnings;
  
  return result;
}

1051 1052 1053 1054 1055
gint 
gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
		 XEvent *event_send)
{
  Status result;
1056
  gint old_warnings = gdk_error_warnings;
1057 1058 1059 1060 1061 1062
  
  gdk_error_code = 0;
  
  gdk_error_warnings = 0;
  result = XSendEvent (gdk_display, window, propagate, event_mask, event_send);
  XSync (gdk_display, False);
1063
  gdk_error_warnings = old_warnings;
1064
  
1065
  return result && !gdk_error_code;
1066
}
Tim Janik's avatar
Tim Janik committed
1067

1068
#ifndef HAVE_XCONVERTCASE
1069 1070 1071 1072 1073 1074 1075 1076 1077
/* compatibility function from X11R6.3, since XConvertCase is not
 * supplied by X11R5.
 */
static void
gdkx_XConvertCase (KeySym symbol,
		   KeySym *lower,
		   KeySym *upper)
{
  register KeySym sym = symbol;
1078
  
1079 1080
  g_return_if_fail (lower != NULL);
  g_return_if_fail (upper != NULL);
1081
  
1082 1083
  *lower = sym;
  *upper = sym;
1084
  
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
  switch (sym >> 8)
    {
#if	defined (GDK_A) && defined (GDK_Ooblique)
    case 0: /* Latin 1 */
      if ((sym >= GDK_A) && (sym <= GDK_Z))
	*lower += (GDK_a - GDK_A);
      else if ((sym >= GDK_a) && (sym <= GDK_z))
	*upper -= (GDK_a - GDK_A);
      else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
	*lower += (GDK_agrave - GDK_Agrave);
      else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
	*upper -= (GDK_agrave - GDK_Agrave);
      else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
	*lower += (GDK_oslash - GDK_Ooblique);
      else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
	*upper -= (GDK_oslash - GDK_Ooblique);
      break;
#endif	/* LATIN1 */
      
#if	defined (GDK_Aogonek) && defined (GDK_tcedilla)
    case 1: /* Latin 2 */
      /* Assume the KeySym is a legal value (ignore discontinuities) */
      if (sym == GDK_Aogonek)
	*lower = GDK_aogonek;
      else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
	*lower += (GDK_lstroke - GDK_Lstroke);
      else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
	*lower += (GDK_scaron - GDK_Scaron);
      else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
	*lower += (GDK_zcaron - GDK_Zcaron);
      else if (sym == GDK_aogonek)
	*upper = GDK_Aogonek;
      else if (sym >= GDK_lstroke && sym <= GDK_sacute)
	*upper -= (GDK_lstroke - GDK_Lstroke);
      else if (sym >= GDK_scaron && sym <= GDK_zacute)
	*upper -= (GDK_scaron - GDK_Scaron);
      else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
	*upper -= (GDK_zcaron - GDK_Zcaron);
      else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
	*lower += (GDK_racute - GDK_Racute);
      else if (sym >= GDK_racute && sym <= GDK_tcedilla)
	*upper -= (GDK_racute - GDK_Racute);
      break;
#endif	/* LATIN2 */
      
#if	defined (GDK_Hstroke) && defined (GDK_Cabovedot)
    case 2: /* Latin 3 */
      /* Assume the KeySym is a legal value (ignore discontinuities) */
      if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
	*lower += (GDK_hstroke - GDK_Hstroke);
      else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
	*lower += (GDK_gbreve - GDK_Gbreve);
      else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
	*upper -= (GDK_hstroke - GDK_Hstroke);
      else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
	*upper -= (GDK_gbreve - GDK_Gbreve);
      else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
	*lower += (GDK_cabovedot - GDK_Cabovedot);
      else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
	*upper -= (GDK_cabovedot - GDK_Cabovedot);
      break;
#endif	/* LATIN3 */
      
#if	defined (GDK_Rcedilla) && defined (GDK_Amacron)
    case 3: /* Latin 4 */
      /* Assume the KeySym is a legal value (ignore discontinuities) */
      if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
	*lower += (GDK_rcedilla - GDK_Rcedilla);
      else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
	*upper -= (GDK_rcedilla - GDK_Rcedilla);
      else if (sym == GDK_ENG)
	*lower = GDK_eng;
      else if (sym == GDK_eng)
	*upper = GDK_ENG;
      else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
	*lower += (GDK_amacron - GDK_Amacron);
      else if (sym >= GDK_amacron && sym <= GDK_umacron)
	*upper -= (GDK_amacron - GDK_Amacron);
      break;
#endif	/* LATIN4 */
      
#if	defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
    case 6: /* Cyrillic */
      /* Assume the KeySym is a legal value (ignore discontinuities) */
      if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
	*lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
      else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
	*upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
      else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
	*lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
      else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
	*upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
      break;
#endif	/* CYRILLIC */
1179
      
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
#if	defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
    case 7: /* Greek */
      /* Assume the KeySym is a legal value (ignore discontinuities) */
      if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
	*lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
      else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
	       sym != GDK_Greek_iotaaccentdieresis &&
	       sym != GDK_Greek_upsilonaccentdieresis)
	*upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
      else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
	*lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
      else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
	       sym != GDK_Greek_finalsmallsigma)
	*upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
      break;
#endif	/* GREEK */
    }
}
1198
#endif
1199

Tim Janik's avatar
Tim Janik committed
1200
gchar*
1201
gdk_keyval_name (guint	      keyval)
Tim Janik's avatar
Tim Janik committed
1202 1203 1204 1205 1206 1207 1208 1209
{
  return XKeysymToString (keyval);
}

guint
gdk_keyval_from_name (const gchar *keyval_name)
{
  g_return_val_if_fail (keyval_name != NULL, 0);
1210
  
Tim Janik's avatar
Tim Janik committed
1211 1212 1213 1214
  return XStringToKeysym (keyval_name);
}

guint
1215
gdk_keyval_to_upper (guint	  keyval)
Tim Janik's avatar
Tim Janik committed
1216 1217 1218 1219 1220
{
  if (keyval)
    {
      KeySym lower_val = 0;
      KeySym upper_val = 0;
1221
      
1222
      XConvertCase (keyval, &lower_val, &upper_val);
Tim Janik's avatar
Tim Janik committed
1223 1224 1225 1226 1227 1228
      return upper_val;
    }
  return 0;
}

guint
1229
gdk_keyval_to_lower (guint	  keyval)
Tim Janik's avatar
Tim Janik committed
1230 1231 1232 1233 1234
{
  if (keyval)
    {
      KeySym lower_val = 0;
      KeySym upper_val = 0;
1235
      
1236
      XConvertCase (keyval, &lower_val, &upper_val);
Tim Janik's avatar
Tim Janik committed
1237 1238 1239 1240 1241 1242
      return lower_val;
    }
  return 0;
}

gboolean
1243
gdk_keyval_is_upper (guint	  keyval)
Tim Janik's avatar
Tim Janik committed
1244 1245 1246 1247 1248
{
  if (keyval)
    {
      KeySym lower_val = 0;
      KeySym upper_val = 0;
1249
      
1250
      XConvertCase (keyval, &lower_val, &upper_val);
Tim Janik's avatar
Tim Janik committed
1251 1252 1253 1254 1255 1256
      return upper_val == keyval;
    }
  return TRUE;
}

gboolean
1257
gdk_keyval_is_lower (guint	  keyval)
Tim Janik's avatar
Tim Janik committed
1258 1259 1260 1261 1262
{
  if (keyval)
    {
      KeySym lower_val = 0;
      KeySym upper_val = 0;
1263
      
1264
      XConvertCase (keyval, &lower_val, &upper_val);
Tim Janik's avatar
Tim Janik committed
1265 1266 1267 1268
      return lower_val == keyval;
    }
  return TRUE;
}
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281

void
gdk_threads_enter ()
{
  GDK_THREADS_ENTER ();
}

void
gdk_threads_leave ()
{
  GDK_THREADS_LEAVE ();
}