1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include <X11/Xlocale.h>
28 #ifdef HAVE_SYS_SELECT_H
29 #include <sys/select.h>
30 #endif /* HAVE_SYS_SELECT_H_ */
32 #define XLIB_ILLEGAL_ACCESS
33 #include <X11/Xatom.h>
36 #include <X11/Xutil.h>
37 #include <X11/Xmu/WinUtil.h>
38 #include <X11/cursorfont.h>
40 #include "gdkprivate.h"
45 #ifndef X_GETTIMEOFDAY
46 #define X_GETTIMEOFDAY(tv) gettimeofday (tv, NULL)
47 #endif /* X_GETTIMEOFDAY */
50 typedef struct _GdkPredicate GdkPredicate;
59 * Private function declarations
62 #ifndef HAVE_XCONVERTCASE
63 static void gdkx_XConvertCase (KeySym symbol,
66 #define XConvertCase gdkx_XConvertCase
69 static void gdk_exit_func (void);
70 static int gdk_x_error (Display *display,
72 static int gdk_x_io_error (Display *display);
74 GdkFilterReturn gdk_wm_protocols_filter (GdkXEvent *xev,
78 /* Private variable declarations
80 static int gdk_initialized = 0; /* 1 if the library is initialized,
84 static struct timeval start; /* The time at which the library was
87 static struct timeval timer; /* Timeout interval to use in the call
88 * to "select". This is used in
89 * conjunction with "timerp" to create
90 * a maximum time to wait for an event
93 static struct timeval *timerp; /* The actual timer passed to "select"
94 * This may be NULL, in which case
95 * "select" will block until an event
98 static guint32 timer_val; /* The timeout length as specified by
99 * the user in milliseconds.
102 static gint autorepeat;
104 #ifdef G_ENABLE_DEBUG
105 static const GDebugKey gdk_debug_keys[] = {
106 {"events", GDK_DEBUG_EVENTS},
107 {"misc", GDK_DEBUG_MISC},
108 {"dnd", GDK_DEBUG_DND},
109 {"color-context", GDK_DEBUG_COLOR_CONTEXT},
110 {"xim", GDK_DEBUG_XIM}
113 static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
115 #endif /* G_ENABLE_DEBUG */
118 *--------------------------------------------------------------
121 * Initialize the library for use.
124 * "argc" is the number of arguments.
125 * "argv" is an array of strings.
128 * "argc" and "argv" are modified to reflect any arguments
129 * which were not handled. (Such arguments should either
130 * be handled by the application or dismissed).
133 * The library is initialized.
135 *--------------------------------------------------------------
142 XKeyboardState keyboard_state;
145 XClassHint *class_hint;
146 gchar **argv_orig = NULL;
152 if (g_thread_supported ())
153 gdk_threads_mutex = g_mutex_new ();
159 argv_orig = g_malloc ((argc_orig + 1) * sizeof (char*));
160 for (i = 0; i < argc_orig; i++)
161 argv_orig[i] = g_strdup ((*argv)[i]);
162 argv_orig[argc_orig] = NULL;
165 X_GETTIMEOFDAY (&start);
167 gdk_display_name = NULL;
169 XSetErrorHandler (gdk_x_error);
170 XSetIOErrorHandler (gdk_x_io_error);
174 #ifdef G_ENABLE_DEBUG
176 gchar *debug_string = getenv("GDK_DEBUG");
177 if (debug_string != NULL)
178 gdk_debug_flags = g_parse_debug_string (debug_string,
182 #endif /* G_ENABLE_DEBUG */
190 d = strrchr((*argv)[0],'/');
192 g_set_prgname (d + 1);
194 g_set_prgname ((*argv)[0]);
197 for (i = 1; i < *argc;)
199 #ifdef G_ENABLE_DEBUG
200 if ((strcmp ("--gdk-debug", (*argv)[i]) == 0) ||
201 (strncmp ("--gdk-debug=", (*argv)[i], 12) == 0))
203 gchar *equal_pos = strchr ((*argv)[i], '=');
205 if (equal_pos != NULL)
207 gdk_debug_flags |= g_parse_debug_string (equal_pos+1,
211 else if ((i + 1) < *argc && (*argv)[i + 1])
213 gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
221 else if ((strcmp ("--gdk-no-debug", (*argv)[i]) == 0) ||
222 (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0))
224 gchar *equal_pos = strchr ((*argv)[i], '=');
226 if (equal_pos != NULL)
228 gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1,
232 else if ((i + 1) < *argc && (*argv)[i + 1])
234 gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
243 #endif /* G_ENABLE_DEBUG */
244 if (strcmp ("--display", (*argv)[i]) == 0)
248 if ((i + 1) < *argc && (*argv)[i + 1])
250 gdk_display_name = g_strdup ((*argv)[i + 1]);
251 (*argv)[i + 1] = NULL;
255 else if (strcmp ("--sync", (*argv)[i]) == 0)
260 else if (strcmp ("--no-xshm", (*argv)[i]) == 0)
263 gdk_use_xshm = FALSE;
265 else if (strcmp ("--name", (*argv)[i]) == 0)
267 if ((i + 1) < *argc && (*argv)[i + 1])
270 g_set_prgname ((*argv)[i]);
274 else if (strcmp ("--class", (*argv)[i]) == 0)
276 if ((i + 1) < *argc && (*argv)[i + 1])
279 gdk_progclass = (*argv)[i];
284 else if (strcmp ("--gxid_host", (*argv)[i]) == 0)
286 if ((i + 1) < *argc && (*argv)[i + 1])
289 gdk_input_gxid_host = ((*argv)[i]);
293 else if (strcmp ("--gxid_port", (*argv)[i]) == 0)
295 if ((i + 1) < *argc && (*argv)[i + 1])
298 gdk_input_gxid_port = atoi ((*argv)[i]);
304 else if (strcmp ("--xim-preedit", (*argv)[i]) == 0)
306 if ((i + 1) < *argc && (*argv)[i + 1])
309 if (strcmp ("none", (*argv)[i]) == 0)
310 gdk_im_set_best_style (GDK_IM_PREEDIT_NONE);
311 else if (strcmp ("nothing", (*argv)[i]) == 0)
312 gdk_im_set_best_style (GDK_IM_PREEDIT_NOTHING);
313 else if (strcmp ("area", (*argv)[i]) == 0)
314 gdk_im_set_best_style (GDK_IM_PREEDIT_AREA);
315 else if (strcmp ("position", (*argv)[i]) == 0)
316 gdk_im_set_best_style (GDK_IM_PREEDIT_POSITION);
317 else if (strcmp ("callbacks", (*argv)[i]) == 0)
318 gdk_im_set_best_style (GDK_IM_PREEDIT_CALLBACKS);
321 else if (strcmp ("--xim-status", (*argv)[i]) == 0)
323 if ((i + 1) < *argc && (*argv)[i + 1])
326 if (strcmp ("none", (*argv)[i]) == 0)
327 gdk_im_set_best_style (GDK_IM_STATUS_NONE);
328 else if (strcmp ("nothing", (*argv)[i]) == 0)
329 gdk_im_set_best_style (GDK_IM_STATUS_NOTHING);
330 else if (strcmp ("area", (*argv)[i]) == 0)
331 gdk_im_set_best_style (GDK_IM_STATUS_AREA);
332 else if (strcmp ("callbacks", (*argv)[i]) == 0)
333 gdk_im_set_best_style (GDK_IM_STATUS_CALLBACKS);
341 for (i = 1; i < *argc; i++)
343 for (k = i; k < *argc; k++)
344 if ((*argv)[k] != NULL)
350 for (j = i + k; j < *argc; j++)
351 (*argv)[j-k] = (*argv)[j];
358 g_set_prgname ("<unknown>");
361 GDK_NOTE (MISC, g_message ("progname: \"%s\"", g_get_prgname ()));
363 gdk_display = XOpenDisplay (gdk_display_name);
366 g_warning ("cannot open display: %s", XDisplayName (gdk_display_name));
371 XSynchronize (gdk_display, True);
373 gdk_screen = DefaultScreen (gdk_display);
374 gdk_root_window = RootWindow (gdk_display, gdk_screen);
376 gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window,
377 10, 10, 10, 10, 0, 0 , 0);
378 class_hint = XAllocClassHint();
379 class_hint->res_name = g_get_prgname ();
380 if (gdk_progclass == NULL)
382 gdk_progclass = g_strdup (g_get_prgname ());
383 gdk_progclass[0] = toupper (gdk_progclass[0]);
385 class_hint->res_class = gdk_progclass;
386 XSetClassHint(gdk_display, gdk_leader_window, class_hint);
387 XSetCommand(gdk_display, gdk_leader_window, argv_orig, argc_orig);
390 for (i = 0; i < argc_orig; i++)
391 g_free(argv_orig[i]);
394 gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", True);
395 gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", True);
396 gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", True);
397 gdk_wm_window_protocols[0] = gdk_wm_delete_window;
398 gdk_wm_window_protocols[1] = gdk_wm_take_focus;
399 gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
401 XGetKeyboardControl (gdk_display, &keyboard_state);
402 autorepeat = keyboard_state.global_auto_repeat;
408 g_atexit (gdk_exit_func);
425 *--------------------------------------------------------------
428 * Restores the library to an un-itialized state and exits
429 * the program using the "exit" system call.
432 * "errorcode" is the error value to pass to "exit".
435 * Allocated structures are freed and the program exits
440 *--------------------------------------------------------------
444 gdk_exit (int errorcode)
446 /* de-initialisation is done by the gdk_exit_funct(),
447 no need to do this here (Alex J.) */
452 *--------------------------------------------------------------
461 *--------------------------------------------------------------
465 gdk_set_locale (void)
467 if (!setlocale (LC_ALL,""))
468 g_message ("locale not supported by C library");
470 if (!XSupportsLocale ())
472 g_message ("locale not supported by Xlib, locale set to C");
473 setlocale (LC_ALL, "C");
476 if (!XSetLocaleModifiers (""))
478 g_message ("can not set locale modifiers");
481 return setlocale (LC_ALL,NULL);
485 gdk_set_use_xshm (gint use_xshm)
487 gdk_use_xshm = use_xshm;
491 gdk_get_use_xshm (void)
497 *--------------------------------------------------------------
500 * Get the number of milliseconds since the library was
506 * The time since the library was initialized is returned.
507 * This time value is accurate to milliseconds even though
508 * a more accurate time down to the microsecond could be
513 *--------------------------------------------------------------
520 struct timeval elapsed;
521 guint32 milliseconds;
523 X_GETTIMEOFDAY (&end);
525 if (start.tv_usec > end.tv_usec)
527 end.tv_usec += 1000000;
530 elapsed.tv_sec = end.tv_sec - start.tv_sec;
531 elapsed.tv_usec = end.tv_usec - start.tv_usec;
533 milliseconds = (elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000);
539 *--------------------------------------------------------------
542 * Returns the current timer.
547 * Returns the current timer interval. This interval is
548 * in units of milliseconds.
552 *--------------------------------------------------------------
562 *--------------------------------------------------------------
565 * Sets the timer interval.
568 * "milliseconds" is the new value for the timer.
573 * Calls to "gdk_event_get" will last for a maximum
574 * of time of "milliseconds". However, a value of 0
575 * milliseconds will cause "gdk_event_get" to block
576 * indefinately until an event is received.
578 *--------------------------------------------------------------
582 gdk_timer_set (guint32 milliseconds)
584 timer_val = milliseconds;
585 timer.tv_sec = milliseconds / 1000;
586 timer.tv_usec = (milliseconds % 1000) * 1000;
591 gdk_timer_enable (void)
597 gdk_timer_disable (void)
603 *--------------------------------------------------------------
606 * Grabs the pointer to a specific window
609 * "window" is the window which will receive the grab
610 * "owner_events" specifies whether events will be reported as is,
611 * or relative to "window"
612 * "event_mask" masks only interesting events
613 * "confine_to" limits the cursor movement to the specified window
614 * "cursor" changes the cursor for the duration of the grab
615 * "time" specifies the time
620 * requires a corresponding call to gdk_pointer_ungrab
622 *--------------------------------------------------------------
626 gdk_pointer_grab (GdkWindow * window,
628 GdkEventMask event_mask,
629 GdkWindow * confine_to,
633 /* From gdkwindow.c */
635 GdkWindowPrivate *window_private;
636 GdkWindowPrivate *confine_to_private;
637 GdkCursorPrivate *cursor_private;
644 g_return_val_if_fail (window != NULL, 0);
646 window_private = (GdkWindowPrivate*) window;
647 confine_to_private = (GdkWindowPrivate*) confine_to;
648 cursor_private = (GdkCursorPrivate*) cursor;
650 xwindow = window_private->xwindow;
652 if (!confine_to || confine_to_private->destroyed)
655 xconfine_to = confine_to_private->xwindow;
660 xcursor = cursor_private->xcursor;
664 for (i = 0; i < gdk_nevent_masks; i++)
666 if (event_mask & (1 << (i + 1)))
667 xevent_mask |= gdk_event_mask_table[i];
670 if (gdk_input_vtable.grab_pointer)
671 return_val = gdk_input_vtable.grab_pointer (window,
677 return_val = Success;
679 if (return_val == Success)
681 if (!window_private->destroyed)
682 return_val = XGrabPointer (window_private->xdisplay,
686 GrabModeAsync, GrabModeAsync,
691 return_val = AlreadyGrabbed;
694 if (return_val == GrabSuccess)
695 gdk_xgrab_window = window_private;
701 *--------------------------------------------------------------
704 * Releases any pointer grab
712 *--------------------------------------------------------------
716 gdk_pointer_ungrab (guint32 time)
718 if (gdk_input_vtable.ungrab_pointer)
719 gdk_input_vtable.ungrab_pointer (time);
721 XUngrabPointer (gdk_display, time);
722 gdk_xgrab_window = NULL;
726 *--------------------------------------------------------------
727 * gdk_pointer_is_grabbed
729 * Tell wether there is an active x pointer grab in effect
737 *--------------------------------------------------------------
741 gdk_pointer_is_grabbed (void)
743 return gdk_xgrab_window != NULL;
747 *--------------------------------------------------------------
750 * Grabs the keyboard to a specific window
753 * "window" is the window which will receive the grab
754 * "owner_events" specifies whether events will be reported as is,
755 * or relative to "window"
756 * "time" specifies the time
761 * requires a corresponding call to gdk_keyboard_ungrab
763 *--------------------------------------------------------------
767 gdk_keyboard_grab (GdkWindow * window,
771 GdkWindowPrivate *window_private;
774 g_return_val_if_fail (window != NULL, 0);
776 window_private = (GdkWindowPrivate*) window;
777 xwindow = window_private->xwindow;
779 if (!window_private->destroyed)
780 return XGrabKeyboard (window_private->xdisplay,
783 GrabModeAsync, GrabModeAsync,
786 return AlreadyGrabbed;
790 *--------------------------------------------------------------
791 * gdk_keyboard_ungrab
793 * Releases any keyboard grab
801 *--------------------------------------------------------------
805 gdk_keyboard_ungrab (guint32 time)
807 XUngrabKeyboard (gdk_display, time);
811 *--------------------------------------------------------------
814 * Return the width of the screen.
822 *--------------------------------------------------------------
826 gdk_screen_width (void)
830 return_val = DisplayWidth (gdk_display, gdk_screen);
836 *--------------------------------------------------------------
839 * Return the height of the screen.
847 *--------------------------------------------------------------
851 gdk_screen_height (void)
855 return_val = DisplayHeight (gdk_display, gdk_screen);
861 *--------------------------------------------------------------
862 * gdk_screen_width_mm
864 * Return the width of the screen in millimeters.
872 *--------------------------------------------------------------
876 gdk_screen_width_mm (void)
880 return_val = DisplayWidthMM (gdk_display, gdk_screen);
886 *--------------------------------------------------------------
889 * Return the height of the screen in millimeters.
897 *--------------------------------------------------------------
901 gdk_screen_height_mm (void)
905 return_val = DisplayHeightMM (gdk_display, gdk_screen);
911 gdk_key_repeat_disable (void)
913 XAutoRepeatOff (gdk_display);
917 gdk_key_repeat_restore (void)
920 XAutoRepeatOn (gdk_display);
922 XAutoRepeatOff (gdk_display);
929 XBell(gdk_display, 100);
933 *--------------------------------------------------------------
936 * This is the "atexit" function that makes sure the
937 * library gets a chance to cleanup.
944 * The library is un-initialized and the program exits.
946 *--------------------------------------------------------------
952 static gboolean in_gdk_exit_func = FALSE;
954 /* This is to avoid an infinite loop if a program segfaults in
955 an atexit() handler (and yes, it does happen, especially if a program
956 has trounced over memory too badly for even g_message to work) */
957 if (in_gdk_exit_func == TRUE)
959 in_gdk_exit_func = TRUE;
971 gdk_key_repeat_restore ();
973 XCloseDisplay (gdk_display);
979 *--------------------------------------------------------------
982 * The X error handling routine.
985 * "display" is the X display the error orignated from.
986 * "error" is the XErrorEvent that we are handling.
989 * Either we were expecting some sort of error to occur,
990 * in which case we set the "gdk_error_code" flag, or this
991 * error was unexpected, in which case we will print an
992 * error message and exit. (Since trying to continue will
993 * most likely simply lead to more errors).
997 *--------------------------------------------------------------
1001 gdk_x_error (Display *display,
1006 if (gdk_error_warnings)
1008 XGetErrorText (display, error->error_code, buf, 63);
1009 g_error ("%s\n serial %ld error_code %d request_code %d minor_code %d\n",
1013 error->request_code,
1017 gdk_error_code = -1;
1022 *--------------------------------------------------------------
1025 * The X I/O error handling routine.
1028 * "display" is the X display the error orignated from.
1031 * An X I/O error basically means we lost our connection
1032 * to the X server. There is not much we can do to
1033 * continue, so simply print an error message and exit.
1037 *--------------------------------------------------------------
1041 gdk_x_io_error (Display *display)
1043 g_error ("an x io error occurred");
1048 gdk_get_display(void)
1050 return (gchar *)XDisplayName (gdk_display_name);
1054 gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
1058 gint old_warnings = gdk_error_warnings;
1062 gdk_error_warnings = 0;
1063 result = XSendEvent (gdk_display, window, propagate, event_mask, event_send);
1064 XSync (gdk_display, False);
1065 gdk_error_warnings = old_warnings;
1067 return result && (gdk_error_code != -1);
1070 #ifndef HAVE_XCONVERTCASE
1071 /* compatibility function from X11R6.3, since XConvertCase is not
1072 * supplied by X11R5.
1075 gdkx_XConvertCase (KeySym symbol,
1079 register KeySym sym = symbol;
1081 g_return_if_fail (lower != NULL);
1082 g_return_if_fail (upper != NULL);
1089 #if defined (GDK_A) && defined (GDK_Ooblique)
1090 case 0: /* Latin 1 */
1091 if ((sym >= GDK_A) && (sym <= GDK_Z))
1092 *lower += (GDK_a - GDK_A);
1093 else if ((sym >= GDK_a) && (sym <= GDK_z))
1094 *upper -= (GDK_a - GDK_A);
1095 else if ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis))
1096 *lower += (GDK_agrave - GDK_Agrave);
1097 else if ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis))
1098 *upper -= (GDK_agrave - GDK_Agrave);
1099 else if ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn))
1100 *lower += (GDK_oslash - GDK_Ooblique);
1101 else if ((sym >= GDK_oslash) && (sym <= GDK_thorn))
1102 *upper -= (GDK_oslash - GDK_Ooblique);
1106 #if defined (GDK_Aogonek) && defined (GDK_tcedilla)
1107 case 1: /* Latin 2 */
1108 /* Assume the KeySym is a legal value (ignore discontinuities) */
1109 if (sym == GDK_Aogonek)
1110 *lower = GDK_aogonek;
1111 else if (sym >= GDK_Lstroke && sym <= GDK_Sacute)
1112 *lower += (GDK_lstroke - GDK_Lstroke);
1113 else if (sym >= GDK_Scaron && sym <= GDK_Zacute)
1114 *lower += (GDK_scaron - GDK_Scaron);
1115 else if (sym >= GDK_Zcaron && sym <= GDK_Zabovedot)
1116 *lower += (GDK_zcaron - GDK_Zcaron);
1117 else if (sym == GDK_aogonek)
1118 *upper = GDK_Aogonek;
1119 else if (sym >= GDK_lstroke && sym <= GDK_sacute)
1120 *upper -= (GDK_lstroke - GDK_Lstroke);
1121 else if (sym >= GDK_scaron && sym <= GDK_zacute)
1122 *upper -= (GDK_scaron - GDK_Scaron);
1123 else if (sym >= GDK_zcaron && sym <= GDK_zabovedot)
1124 *upper -= (GDK_zcaron - GDK_Zcaron);
1125 else if (sym >= GDK_Racute && sym <= GDK_Tcedilla)
1126 *lower += (GDK_racute - GDK_Racute);
1127 else if (sym >= GDK_racute && sym <= GDK_tcedilla)
1128 *upper -= (GDK_racute - GDK_Racute);
1132 #if defined (GDK_Hstroke) && defined (GDK_Cabovedot)
1133 case 2: /* Latin 3 */
1134 /* Assume the KeySym is a legal value (ignore discontinuities) */
1135 if (sym >= GDK_Hstroke && sym <= GDK_Hcircumflex)
1136 *lower += (GDK_hstroke - GDK_Hstroke);
1137 else if (sym >= GDK_Gbreve && sym <= GDK_Jcircumflex)
1138 *lower += (GDK_gbreve - GDK_Gbreve);
1139 else if (sym >= GDK_hstroke && sym <= GDK_hcircumflex)
1140 *upper -= (GDK_hstroke - GDK_Hstroke);
1141 else if (sym >= GDK_gbreve && sym <= GDK_jcircumflex)
1142 *upper -= (GDK_gbreve - GDK_Gbreve);
1143 else if (sym >= GDK_Cabovedot && sym <= GDK_Scircumflex)
1144 *lower += (GDK_cabovedot - GDK_Cabovedot);
1145 else if (sym >= GDK_cabovedot && sym <= GDK_scircumflex)
1146 *upper -= (GDK_cabovedot - GDK_Cabovedot);
1150 #if defined (GDK_Rcedilla) && defined (GDK_Amacron)
1151 case 3: /* Latin 4 */
1152 /* Assume the KeySym is a legal value (ignore discontinuities) */
1153 if (sym >= GDK_Rcedilla && sym <= GDK_Tslash)
1154 *lower += (GDK_rcedilla - GDK_Rcedilla);
1155 else if (sym >= GDK_rcedilla && sym <= GDK_tslash)
1156 *upper -= (GDK_rcedilla - GDK_Rcedilla);
1157 else if (sym == GDK_ENG)
1159 else if (sym == GDK_eng)
1161 else if (sym >= GDK_Amacron && sym <= GDK_Umacron)
1162 *lower += (GDK_amacron - GDK_Amacron);
1163 else if (sym >= GDK_amacron && sym <= GDK_umacron)
1164 *upper -= (GDK_amacron - GDK_Amacron);
1168 #if defined (GDK_Serbian_DJE) && defined (GDK_Cyrillic_yu)
1169 case 6: /* Cyrillic */
1170 /* Assume the KeySym is a legal value (ignore discontinuities) */
1171 if (sym >= GDK_Serbian_DJE && sym <= GDK_Serbian_DZE)
1172 *lower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
1173 else if (sym >= GDK_Serbian_dje && sym <= GDK_Serbian_dze)
1174 *upper += (GDK_Serbian_DJE - GDK_Serbian_dje);
1175 else if (sym >= GDK_Cyrillic_YU && sym <= GDK_Cyrillic_HARDSIGN)
1176 *lower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
1177 else if (sym >= GDK_Cyrillic_yu && sym <= GDK_Cyrillic_hardsign)
1178 *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
1180 #endif /* CYRILLIC */
1182 #if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma)
1184 /* Assume the KeySym is a legal value (ignore discontinuities) */
1185 if (sym >= GDK_Greek_ALPHAaccent && sym <= GDK_Greek_OMEGAaccent)
1186 *lower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
1187 else if (sym >= GDK_Greek_alphaaccent && sym <= GDK_Greek_omegaaccent &&
1188 sym != GDK_Greek_iotaaccentdieresis &&
1189 sym != GDK_Greek_upsilonaccentdieresis)
1190 *upper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
1191 else if (sym >= GDK_Greek_ALPHA && sym <= GDK_Greek_OMEGA)
1192 *lower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
1193 else if (sym >= GDK_Greek_alpha && sym <= GDK_Greek_omega &&
1194 sym != GDK_Greek_finalsmallsigma)
1195 *upper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
1203 gdk_keyval_name (guint keyval)
1205 return XKeysymToString (keyval);
1209 gdk_keyval_from_name (const gchar *keyval_name)
1211 g_return_val_if_fail (keyval_name != NULL, 0);
1213 return XStringToKeysym (keyval_name);
1217 gdk_keyval_to_upper (guint keyval)
1221 KeySym lower_val = 0;
1222 KeySym upper_val = 0;
1224 XConvertCase (keyval, &lower_val, &upper_val);
1231 gdk_keyval_to_lower (guint keyval)
1235 KeySym lower_val = 0;
1236 KeySym upper_val = 0;
1238 XConvertCase (keyval, &lower_val, &upper_val);
1245 gdk_keyval_is_upper (guint keyval)
1249 KeySym lower_val = 0;
1250 KeySym upper_val = 0;
1252 XConvertCase (keyval, &lower_val, &upper_val);
1253 return upper_val == keyval;
1259 gdk_keyval_is_lower (guint keyval)
1263 KeySym lower_val = 0;
1264 KeySym upper_val = 0;
1266 XConvertCase (keyval, &lower_val, &upper_val);
1267 return lower_val == keyval;
1273 gdk_threads_enter ()
1275 GDK_THREADS_ENTER ();
1279 gdk_threads_leave ()
1281 GDK_THREADS_LEAVE ();