462
|
1 /* Device functions for X windows.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
872
|
4 Copyright (C) 2002 Ben Wing.
|
462
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: Not in FSF. */
|
|
24
|
|
25 /* Original authors: Jamie Zawinski and the FSF */
|
|
26 /* Rewritten by Ben Wing and Chuck Thompson. */
|
|
27 /* Gtk flavor written by William Perry */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
872
|
32 #include "buffer.h"
|
|
33 #include "device-impl.h"
|
|
34 #include "elhash.h"
|
|
35 #include "events.h"
|
|
36 #include "faces.h"
|
|
37 #include "frame-impl.h"
|
|
38 #include "redisplay.h"
|
|
39 #include "sysdep.h"
|
|
40 #include "window.h"
|
|
41
|
|
42 #include "console-gtk-impl.h"
|
462
|
43 #include "gccache-gtk.h"
|
|
44 #include "glyphs-gtk.h"
|
|
45 #include "objects-gtk.h"
|
|
46 #include "gtk-xemacs.h"
|
|
47
|
|
48 #include "sysfile.h"
|
|
49 #include "systime.h"
|
|
50
|
|
51 #ifdef HAVE_GNOME
|
|
52 #include <libgnomeui/libgnomeui.h>
|
|
53 #endif
|
|
54
|
|
55 #ifdef HAVE_BONOBO
|
|
56 #include <bonobo.h>
|
|
57 #endif
|
|
58
|
|
59 /* Qdisplay in general.c */
|
|
60 Lisp_Object Qinit_pre_gtk_win, Qinit_post_gtk_win;
|
|
61
|
|
62 /* The application class of Emacs. */
|
|
63 Lisp_Object Vgtk_emacs_application_class;
|
|
64
|
|
65 Lisp_Object Vgtk_initial_argv_list; /* #### ugh! */
|
|
66 Lisp_Object Vgtk_initial_geometry;
|
|
67
|
|
68 static void gtk_device_init_x_specific_cruft (struct device *d);
|
|
69
|
|
70
|
|
71 /************************************************************************/
|
|
72 /* helper functions */
|
|
73 /************************************************************************/
|
|
74
|
|
75 struct device *
|
|
76 decode_gtk_device (Lisp_Object device)
|
|
77 {
|
793
|
78 device = wrap_device (decode_device (device));
|
462
|
79 CHECK_GTK_DEVICE (device);
|
|
80 return XDEVICE (device);
|
|
81 }
|
|
82
|
|
83
|
|
84 /************************************************************************/
|
|
85 /* initializing a GTK connection */
|
|
86 /************************************************************************/
|
|
87 extern Lisp_Object
|
|
88 xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w);
|
|
89
|
|
90 extern Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
|
|
91
|
|
92 #define convert_font(f) __get_gtk_font_truename (f, 0)
|
|
93
|
|
94 static void
|
|
95 allocate_gtk_device_struct (struct device *d)
|
|
96 {
|
|
97 d->device_data = xnew_and_zero (struct gtk_device);
|
|
98 DEVICE_GTK_DATA (d)->x_keysym_map_hashtable = Qnil;
|
|
99 }
|
|
100
|
|
101 static void
|
|
102 gtk_init_device_class (struct device *d)
|
|
103 {
|
|
104 if (DEVICE_GTK_DEPTH(d) > 2)
|
|
105 {
|
|
106 switch (DEVICE_GTK_VISUAL(d)->type)
|
|
107 {
|
|
108 case GDK_VISUAL_STATIC_GRAY:
|
|
109 case GDK_VISUAL_GRAYSCALE:
|
|
110 DEVICE_CLASS (d) = Qgrayscale;
|
|
111 break;
|
|
112 default:
|
|
113 DEVICE_CLASS (d) = Qcolor;
|
|
114 }
|
|
115 }
|
|
116 else
|
|
117 DEVICE_CLASS (d) = Qmono;
|
|
118 }
|
|
119
|
|
120 #ifdef HAVE_GDK_IMLIB_INIT
|
|
121 extern void gdk_imlib_init(void);
|
|
122 #endif
|
|
123
|
863
|
124 extern void emacs_gtk_selection_handle (GtkWidget *,
|
|
125 GtkSelectionData *selection_data,
|
|
126 guint info,
|
|
127 guint time_stamp,
|
|
128 gpointer data);
|
|
129 extern void emacs_gtk_selection_clear_event_handle (GtkWidget *widget,
|
|
130 GdkEventSelection *event,
|
|
131 gpointer data);
|
|
132 extern void emacs_gtk_selection_received (GtkWidget *widget,
|
|
133 GtkSelectionData *selection_data,
|
|
134 gpointer user_data);
|
|
135
|
462
|
136 #ifdef HAVE_BONOBO
|
|
137 static CORBA_ORB orb;
|
|
138 #endif
|
|
139
|
|
140 DEFUN ("gtk-init", Fgtk_init, 1, 1, 0, /*
|
|
141 Initialize the GTK subsystem.
|
|
142 ARGS is a standard list of command-line arguments.
|
|
143
|
|
144 No effect if called more than once. Called automatically when
|
|
145 creating the first GTK device. Must be called manually from batch
|
|
146 mode.
|
|
147 */
|
|
148 (args))
|
|
149 {
|
|
150 int argc;
|
|
151 char **argv;
|
|
152 static int done;
|
|
153
|
|
154 if (done)
|
|
155 {
|
|
156 return (Qt);
|
|
157 }
|
|
158
|
|
159 make_argc_argv (args, &argc, &argv);
|
|
160
|
|
161 slow_down_interrupts ();
|
|
162 #ifdef HAVE_GNOME
|
|
163 #ifdef INFODOCK
|
|
164 gnome_init ("InfoDock", EMACS_VERSION, argc, argv);
|
|
165 #else
|
|
166 gnome_init ("XEmacs", EMACS_VERSION, argc, argv);
|
|
167 #endif /* INFODOCK */
|
|
168 #else
|
|
169 gtk_init (&argc, &argv);
|
|
170 #endif
|
|
171
|
|
172 #ifdef HAVE_BONOBO
|
|
173 orb = oaf_init (argc, argv);
|
|
174
|
|
175 if (bonobo_init (orb, NULL, NULL) == FALSE)
|
|
176 {
|
|
177 g_warning ("Could not initialize bonobo...");
|
|
178 }
|
|
179
|
|
180 bonobo_activate ();
|
|
181 #endif
|
|
182
|
|
183 speed_up_interrupts ();
|
|
184
|
|
185 free_argc_argv (argv);
|
|
186 return (Qt);
|
|
187 }
|
|
188
|
|
189 static void
|
|
190 gtk_init_device (struct device *d, Lisp_Object props)
|
|
191 {
|
|
192 Lisp_Object device;
|
|
193 Lisp_Object display;
|
|
194 GtkWidget *app_shell = NULL;
|
|
195 GdkVisual *visual = NULL;
|
|
196 GdkColormap *cmap = NULL;
|
|
197
|
793
|
198 device = wrap_device (d);
|
462
|
199
|
|
200 /* gtk_init() and even gtk_check_init() are so brain dead that
|
|
201 getting an empty argv array causes them to abort. */
|
|
202 if (NILP (Vgtk_initial_argv_list))
|
|
203 {
|
563
|
204 invalid_operation ("gtk-initial-argv-list must be set before creating Gtk devices", Vgtk_initial_argv_list);
|
462
|
205 return;
|
|
206 }
|
|
207
|
|
208 allocate_gtk_device_struct (d);
|
|
209 display = DEVICE_CONNECTION (d);
|
|
210
|
|
211 /* Attempt to load a site-specific gtkrc */
|
|
212 {
|
|
213 Lisp_Object gtkrc = Fexpand_file_name (build_string ("gtkrc"), Vdata_directory);
|
|
214 gchar **default_files = gtk_rc_get_default_files ();
|
|
215 gint num_files;
|
|
216
|
|
217 if (STRINGP (gtkrc))
|
|
218 {
|
|
219 /* Found one, load it up! */
|
|
220 gchar **new_rc_files = NULL;
|
|
221 int ctr;
|
|
222
|
|
223 for (num_files = 0; default_files[num_files]; num_files++);
|
|
224
|
|
225 new_rc_files = xnew_array_and_zero (gchar *, num_files + 3);
|
|
226
|
|
227 new_rc_files[0] = XSTRING_DATA (gtkrc);
|
|
228 for (ctr = 1; default_files[ctr-1]; ctr++)
|
|
229 new_rc_files[ctr] = g_strdup (default_files[ctr-1]);
|
|
230
|
|
231 gtk_rc_set_default_files (new_rc_files);
|
|
232
|
|
233 for (ctr = 1; new_rc_files[ctr]; ctr++)
|
|
234 free(new_rc_files[ctr]);
|
|
235
|
|
236 xfree (new_rc_files);
|
|
237 }
|
|
238 }
|
|
239
|
|
240 Fgtk_init (Vgtk_initial_argv_list);
|
|
241
|
|
242 #ifdef __FreeBSD__
|
|
243 gdk_set_use_xshm (FALSE);
|
|
244 #endif
|
|
245
|
|
246 /* We attempt to load this file so that the user can set
|
|
247 ** gtk-initial-geometry and not need GNOME & session management to
|
|
248 ** set their default frame size. It also avoids the flicker
|
|
249 ** associated with setting the frame size in your .emacs file.
|
|
250 */
|
|
251 call4 (Qload, build_string ("~/.xemacs/gtk-options.el"), Qt, Qt, Qt);
|
|
252
|
|
253 #ifdef HAVE_GDK_IMLIB_INIT
|
|
254 /* Some themes in Gtk are so lame (most notably the Pixmap theme)
|
|
255 that they rely on gdk_imlib, but don't call its initialization
|
|
256 routines. This makes them USELESS for non-gnome applications.
|
|
257 So we bend over backwards to try and make them work. Losers. */
|
|
258 gdk_imlib_init ();
|
|
259 #endif
|
|
260
|
|
261 if (NILP (DEVICE_NAME (d)))
|
|
262 DEVICE_NAME (d) = display;
|
|
263
|
|
264 /* Always search for the best visual */
|
|
265 visual = gdk_visual_get_best();
|
|
266 cmap = gdk_colormap_new (visual, TRUE);
|
|
267
|
|
268 DEVICE_GTK_VISUAL (d) = visual;
|
|
269 DEVICE_GTK_COLORMAP (d) = cmap;
|
|
270 DEVICE_GTK_DEPTH (d) = visual->depth;
|
|
271
|
|
272 {
|
|
273 GtkWidget *w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
274
|
|
275 app_shell = gtk_xemacs_new (NULL);
|
|
276 gtk_container_add (GTK_CONTAINER (w), app_shell);
|
|
277
|
|
278 gtk_widget_realize (w);
|
|
279 }
|
|
280
|
|
281 DEVICE_GTK_APP_SHELL (d) = app_shell;
|
|
282
|
|
283 /* Realize the app_shell so that its window exists for GC creation
|
|
284 purposes */
|
|
285 gtk_widget_realize (GTK_WIDGET (app_shell));
|
|
286
|
|
287 /* Need to set up some selection handlers */
|
|
288 gtk_selection_add_target (GTK_WIDGET (app_shell), GDK_SELECTION_PRIMARY,
|
|
289 GDK_SELECTION_TYPE_STRING, 0);
|
746
|
290 gtk_selection_add_target (GTK_WIDGET (app_shell),
|
|
291 gdk_atom_intern("CLIPBOARD", FALSE),
|
|
292 GDK_SELECTION_TYPE_STRING, 0);
|
462
|
293
|
|
294 gtk_signal_connect (GTK_OBJECT (app_shell), "selection_get",
|
|
295 GTK_SIGNAL_FUNC (emacs_gtk_selection_handle), NULL);
|
746
|
296 gtk_signal_connect (GTK_OBJECT (app_shell), "selection_clear_event",
|
|
297 GTK_SIGNAL_FUNC (emacs_gtk_selection_clear_event_handle),
|
|
298 NULL);
|
462
|
299 gtk_signal_connect (GTK_OBJECT (app_shell), "selection_received",
|
|
300 GTK_SIGNAL_FUNC (emacs_gtk_selection_received), NULL);
|
|
301
|
|
302 DEVICE_GTK_WM_COMMAND_FRAME (d) = Qnil;
|
|
303
|
|
304 gtk_init_modifier_mapping (d);
|
|
305
|
|
306 gtk_device_init_x_specific_cruft (d);
|
|
307
|
|
308 init_baud_rate (d);
|
|
309 init_one_device (d);
|
|
310
|
|
311 DEVICE_GTK_GC_CACHE (d) = make_gc_cache (GTK_WIDGET (app_shell));
|
|
312 DEVICE_GTK_GRAY_PIXMAP (d) = NULL;
|
|
313
|
|
314 gtk_init_device_class (d);
|
|
315
|
|
316 /* Run the elisp side of the X device initialization. */
|
|
317 call0 (Qinit_pre_gtk_win);
|
|
318 }
|
|
319
|
|
320 static void
|
|
321 gtk_finish_init_device (struct device *d, Lisp_Object props)
|
|
322 {
|
|
323 call0 (Qinit_post_gtk_win);
|
|
324 }
|
|
325
|
|
326 static void
|
|
327 gtk_mark_device (struct device *d)
|
|
328 {
|
|
329 mark_object (DEVICE_GTK_WM_COMMAND_FRAME (d));
|
|
330 mark_object (DEVICE_GTK_DATA (d)->x_keysym_map_hashtable);
|
|
331 }
|
|
332
|
|
333
|
|
334 /************************************************************************/
|
|
335 /* closing an X connection */
|
|
336 /************************************************************************/
|
|
337
|
|
338 static void
|
|
339 free_gtk_device_struct (struct device *d)
|
|
340 {
|
|
341 xfree (d->device_data);
|
|
342 }
|
|
343
|
|
344 static void
|
|
345 gtk_delete_device (struct device *d)
|
|
346 {
|
|
347 Lisp_Object device;
|
|
348
|
|
349 #ifdef FREE_CHECKING
|
|
350 extern void (*__free_hook)();
|
|
351 int checking_free;
|
|
352 #endif
|
|
353
|
793
|
354 device = wrap_device (d);
|
462
|
355 if (1)
|
|
356 {
|
|
357 #ifdef FREE_CHECKING
|
|
358 checking_free = (__free_hook != 0);
|
|
359
|
|
360 /* Disable strict free checking, to avoid bug in X library */
|
|
361 if (checking_free)
|
|
362 disable_strict_free_check ();
|
|
363 #endif
|
|
364
|
|
365 free_gc_cache (DEVICE_GTK_GC_CACHE (d));
|
|
366
|
|
367 #ifdef FREE_CHECKING
|
|
368 if (checking_free)
|
|
369 enable_strict_free_check ();
|
|
370 #endif
|
|
371 }
|
|
372
|
|
373 free_gtk_device_struct (d);
|
|
374 }
|
|
375
|
|
376
|
|
377 /************************************************************************/
|
|
378 /* handle X errors */
|
|
379 /************************************************************************/
|
|
380
|
|
381 const char *
|
|
382 gtk_event_name (GdkEventType event_type)
|
|
383 {
|
|
384 GtkEnumValue *vals = gtk_type_enum_get_values (GTK_TYPE_GDK_EVENT_TYPE);
|
|
385
|
778
|
386 while (vals && ((GdkEventType)(vals->value) != event_type)) vals++;
|
462
|
387
|
|
388 if (vals)
|
|
389 return (vals->value_nick);
|
|
390
|
|
391 return (NULL);
|
|
392 }
|
|
393
|
|
394
|
|
395 /************************************************************************/
|
|
396 /* display information functions */
|
|
397 /************************************************************************/
|
|
398
|
|
399 DEFUN ("gtk-display-visual-class", Fgtk_display_visual_class, 0, 1, 0, /*
|
|
400 Return the visual class of the GTK display DEVICE is using.
|
|
401 The returned value will be one of the symbols `static-gray', `gray-scale',
|
|
402 `static-color', `pseudo-color', `true-color', or `direct-color'.
|
|
403 */
|
|
404 (device))
|
|
405 {
|
|
406 GdkVisual *vis = DEVICE_GTK_VISUAL (decode_gtk_device (device));
|
|
407 switch (vis->type)
|
|
408 {
|
|
409 case GDK_VISUAL_STATIC_GRAY: return intern ("static-gray");
|
|
410 case GDK_VISUAL_GRAYSCALE: return intern ("gray-scale");
|
|
411 case GDK_VISUAL_STATIC_COLOR: return intern ("static-color");
|
|
412 case GDK_VISUAL_PSEUDO_COLOR: return intern ("pseudo-color");
|
|
413 case GDK_VISUAL_TRUE_COLOR: return intern ("true-color");
|
|
414 case GDK_VISUAL_DIRECT_COLOR: return intern ("direct-color");
|
|
415 default:
|
563
|
416 invalid_state ("display has an unknown visual class", Qunbound);
|
462
|
417 return Qnil; /* suppress compiler warning */
|
|
418 }
|
|
419 }
|
|
420
|
|
421 DEFUN ("gtk-display-visual-depth", Fgtk_display_visual_depth, 0, 1, 0, /*
|
|
422 Return the bitplane depth of the visual the GTK display DEVICE is using.
|
|
423 */
|
|
424 (device))
|
|
425 {
|
|
426 return make_int (DEVICE_GTK_DEPTH (decode_gtk_device (device)));
|
|
427 }
|
|
428
|
|
429 static Lisp_Object
|
|
430 gtk_device_system_metrics (struct device *d,
|
|
431 enum device_metrics m)
|
|
432 {
|
|
433 #if 0
|
|
434 GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (DEVICE_GTK_APP_SHELL (d)));
|
|
435
|
|
436 style = gtk_style_attach (style, w);
|
|
437 #endif
|
|
438
|
|
439 switch (m)
|
|
440 {
|
|
441 case DM_size_device:
|
|
442 return Fcons (make_int (gdk_screen_width ()),
|
|
443 make_int (gdk_screen_height ()));
|
|
444 case DM_size_device_mm:
|
|
445 return Fcons (make_int (gdk_screen_width_mm ()),
|
|
446 make_int (gdk_screen_height_mm ()));
|
|
447 case DM_num_color_cells:
|
|
448 return make_int (gdk_colormap_get_system_size ());
|
|
449 case DM_num_bit_planes:
|
|
450 return make_int (DEVICE_GTK_DEPTH (d));
|
|
451
|
|
452 #if 0
|
|
453 case DM_color_default:
|
|
454 case DM_color_select:
|
|
455 case DM_color_balloon:
|
|
456 case DM_color_3d_face:
|
|
457 case DM_color_3d_light:
|
|
458 case DM_color_3d_dark:
|
|
459 case DM_color_menu:
|
|
460 case DM_color_menu_highlight:
|
|
461 case DM_color_menu_button:
|
|
462 case DM_color_menu_disabled:
|
|
463 case DM_color_toolbar:
|
|
464 case DM_color_scrollbar:
|
|
465 case DM_color_desktop:
|
|
466 case DM_color_workspace:
|
|
467 case DM_font_default:
|
|
468 case DM_font_menubar:
|
|
469 case DM_font_dialog:
|
|
470 case DM_size_cursor:
|
|
471 case DM_size_scrollbar:
|
|
472 case DM_size_menu:
|
|
473 case DM_size_toolbar:
|
|
474 case DM_size_toolbar_button:
|
|
475 case DM_size_toolbar_border:
|
|
476 case DM_size_icon:
|
|
477 case DM_size_icon_small:
|
|
478 case DM_size_workspace:
|
|
479 case DM_device_dpi:
|
|
480 case DM_mouse_buttons:
|
|
481 case DM_swap_buttons:
|
|
482 case DM_show_sounds:
|
|
483 case DM_slow_device:
|
|
484 case DM_security:
|
|
485 #endif
|
|
486 default: /* No such device metric property for GTK devices */
|
|
487 return Qunbound;
|
|
488 }
|
|
489 }
|
|
490
|
|
491 DEFUN ("gtk-keysym-on-keyboard-p", Fgtk_keysym_on_keyboard_p, 1, 2, 0, /*
|
|
492 Return true if KEYSYM names a key on the keyboard of DEVICE.
|
|
493 More precisely, return true if some keystroke (possibly including modifiers)
|
|
494 on the keyboard of DEVICE keys generates KEYSYM.
|
|
495 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
496 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
|
497 The keysym name can be provided in two forms:
|
|
498 - if keysym is a string, it must be the name as known to X windows.
|
|
499 - if keysym is a symbol, it must be the name as known to XEmacs.
|
|
500 The two names differ in capitalization and underscoring.
|
|
501 */
|
|
502 (keysym, device))
|
|
503 {
|
|
504 struct device *d = decode_device (device);
|
|
505
|
|
506 if (!DEVICE_GTK_P (d))
|
563
|
507 gui_error ("Not a GTK device", device);
|
462
|
508
|
|
509 return (NILP (Fgethash (keysym, DEVICE_GTK_DATA (d)->x_keysym_map_hashtable, Qnil)) ?
|
|
510 Qnil : Qt);
|
|
511 }
|
|
512
|
|
513
|
|
514 /************************************************************************/
|
|
515 /* grabs and ungrabs */
|
|
516 /************************************************************************/
|
|
517
|
|
518 DEFUN ("gtk-grab-pointer", Fgtk_grab_pointer, 0, 3, 0, /*
|
|
519 Grab the pointer and restrict it to its current window.
|
|
520 If optional DEVICE argument is nil, the default device will be used.
|
|
521 If optional CURSOR argument is non-nil, change the pointer shape to that
|
|
522 until `gtk-ungrab-pointer' is called (it should be an object returned by the
|
|
523 `make-cursor-glyph' function).
|
|
524 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all
|
|
525 keyboard events during the grab.
|
|
526 Returns t if the grab is successful, nil otherwise.
|
|
527 */
|
|
528 (device, cursor, ignore_keyboard))
|
|
529 {
|
|
530 GdkWindow *w;
|
|
531 int result;
|
|
532 struct device *d = decode_gtk_device (device);
|
|
533
|
|
534 if (!NILP (cursor))
|
|
535 {
|
|
536 CHECK_POINTER_GLYPH (cursor);
|
|
537 cursor = glyph_image_instance (cursor, device, ERROR_ME, 0);
|
|
538 }
|
|
539
|
|
540 /* We should call gdk_pointer_grab() and (possibly) gdk_keyboard_grab() here instead */
|
|
541 w = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (device_selected_frame (d)));
|
|
542
|
|
543 result = gdk_pointer_grab (w, FALSE,
|
|
544 GDK_POINTER_MOTION_MASK |
|
|
545 GDK_POINTER_MOTION_HINT_MASK |
|
|
546 GDK_BUTTON1_MOTION_MASK |
|
|
547 GDK_BUTTON2_MOTION_MASK |
|
|
548 GDK_BUTTON3_MOTION_MASK |
|
|
549 GDK_BUTTON_PRESS_MASK |
|
|
550 GDK_BUTTON_RELEASE_MASK,
|
|
551 w,
|
|
552 NULL, /* #### BILL!!! Need to create a GdkCursor * as necessary! */
|
|
553 GDK_CURRENT_TIME);
|
|
554
|
|
555 return (result == 0) ? Qt : Qnil;
|
|
556 }
|
|
557
|
|
558 DEFUN ("gtk-ungrab-pointer", Fgtk_ungrab_pointer, 0, 1, 0, /*
|
|
559 Release a pointer grab made with `gtk-grab-pointer'.
|
|
560 If optional first arg DEVICE is nil the default device is used.
|
|
561 If it is t the pointer will be released on all GTK devices.
|
|
562 */
|
|
563 (device))
|
|
564 {
|
|
565 if (!EQ (device, Qt))
|
|
566 {
|
|
567 gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
568 }
|
|
569 else
|
|
570 {
|
|
571 Lisp_Object devcons, concons;
|
|
572
|
|
573 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
574 {
|
|
575 struct device *d = XDEVICE (XCAR (devcons));
|
|
576
|
|
577 if (DEVICE_GTK_P (d))
|
|
578 gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
|
579 }
|
|
580 }
|
|
581 return Qnil;
|
|
582 }
|
|
583
|
|
584 DEFUN ("gtk-grab-keyboard", Fgtk_grab_keyboard, 0, 1, 0, /*
|
|
585 Grab the keyboard on the given device (defaulting to the selected one).
|
|
586 So long as the keyboard is grabbed, all keyboard events will be delivered
|
|
587 to emacs -- it is not possible for other clients to eavesdrop on them.
|
|
588 Ungrab the keyboard with `gtk-ungrab-keyboard' (use an unwind-protect).
|
|
589 Returns t if the grab is successful, nil otherwise.
|
|
590 */
|
|
591 (device))
|
|
592 {
|
|
593 struct device *d = decode_gtk_device (device);
|
|
594 GdkWindow *w = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (device_selected_frame (d)));
|
|
595
|
|
596 gdk_keyboard_grab (w, FALSE, GDK_CURRENT_TIME );
|
|
597
|
|
598 return Qt;
|
|
599 }
|
|
600
|
|
601 DEFUN ("gtk-ungrab-keyboard", Fgtk_ungrab_keyboard, 0, 1, 0, /*
|
|
602 Release a keyboard grab made with `gtk-grab-keyboard'.
|
|
603 */
|
|
604 (device))
|
|
605 {
|
|
606 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
|
607 return Qnil;
|
|
608 }
|
|
609
|
|
610
|
|
611 /************************************************************************/
|
|
612 /* Style Info */
|
|
613 /************************************************************************/
|
|
614 DEFUN ("gtk-style-info", Fgtk_style_info, 0, 1, 0, /*
|
|
615 Get the style information for a Gtk device.
|
|
616 */
|
|
617 (device))
|
|
618 {
|
|
619 struct device *d = decode_device (device);
|
|
620 GtkStyle *style = NULL;
|
|
621 Lisp_Object result = Qnil;
|
|
622 GtkWidget *app_shell = GTK_WIDGET (DEVICE_GTK_APP_SHELL (d));
|
|
623 GdkWindow *w = GET_GTK_WIDGET_WINDOW (app_shell);
|
|
624
|
|
625 if (!DEVICE_GTK_P (d))
|
|
626 return (Qnil);
|
|
627
|
|
628 style = gtk_widget_get_style (app_shell);
|
|
629 style = gtk_style_attach (style, w);
|
|
630
|
|
631 if (!style) return (Qnil);
|
|
632
|
|
633 #define FROB_COLOR(slot, name) \
|
|
634 result = nconc2 (result, \
|
|
635 list2 (intern (name), \
|
|
636 list5 (xemacs_gtk_convert_color (&style->slot[GTK_STATE_NORMAL], app_shell),\
|
|
637 xemacs_gtk_convert_color (&style->slot[GTK_STATE_ACTIVE], app_shell),\
|
|
638 xemacs_gtk_convert_color (&style->slot[GTK_STATE_PRELIGHT], app_shell),\
|
|
639 xemacs_gtk_convert_color (&style->slot[GTK_STATE_SELECTED], app_shell),\
|
|
640 xemacs_gtk_convert_color (&style->slot[GTK_STATE_INSENSITIVE], app_shell))))
|
|
641
|
|
642 FROB_COLOR (fg, "foreground");
|
|
643 FROB_COLOR (bg, "background");
|
|
644 FROB_COLOR (light, "light");
|
|
645 FROB_COLOR (dark, "dark");
|
|
646 FROB_COLOR (mid, "mid");
|
|
647 FROB_COLOR (text, "text");
|
|
648 FROB_COLOR (base, "base");
|
|
649 #undef FROB_COLOR
|
|
650
|
|
651 result = nconc2 (result, list2 (Qfont, convert_font (style->font)));
|
|
652
|
|
653 #define FROB_PIXMAP(state) (style->rc_style->bg_pixmap_name[state] ? build_string (style->rc_style->bg_pixmap_name[state]) : Qnil)
|
|
654
|
|
655 if (style->rc_style)
|
|
656 result = nconc2 (result, list2 (Qbackground,
|
|
657 list5 ( FROB_PIXMAP (GTK_STATE_NORMAL),
|
|
658 FROB_PIXMAP (GTK_STATE_ACTIVE),
|
|
659 FROB_PIXMAP (GTK_STATE_PRELIGHT),
|
|
660 FROB_PIXMAP (GTK_STATE_SELECTED),
|
|
661 FROB_PIXMAP (GTK_STATE_INSENSITIVE))));
|
|
662 #undef FROB_PIXMAP
|
|
663
|
|
664 return (result);
|
|
665 }
|
|
666
|
|
667
|
|
668 /************************************************************************/
|
|
669 /* initialization */
|
|
670 /************************************************************************/
|
|
671
|
|
672 void
|
|
673 syms_of_device_gtk (void)
|
|
674 {
|
|
675 DEFSUBR (Fgtk_keysym_on_keyboard_p);
|
|
676 DEFSUBR (Fgtk_display_visual_class);
|
|
677 DEFSUBR (Fgtk_display_visual_depth);
|
|
678 DEFSUBR (Fgtk_style_info);
|
|
679 DEFSUBR (Fgtk_grab_pointer);
|
|
680 DEFSUBR (Fgtk_ungrab_pointer);
|
|
681 DEFSUBR (Fgtk_grab_keyboard);
|
|
682 DEFSUBR (Fgtk_ungrab_keyboard);
|
|
683 DEFSUBR (Fgtk_init);
|
|
684
|
563
|
685 DEFSYMBOL (Qinit_pre_gtk_win);
|
|
686 DEFSYMBOL (Qinit_post_gtk_win);
|
462
|
687 }
|
|
688
|
|
689 void
|
|
690 console_type_create_device_gtk (void)
|
|
691 {
|
|
692 CONSOLE_HAS_METHOD (gtk, init_device);
|
|
693 CONSOLE_HAS_METHOD (gtk, finish_init_device);
|
|
694 CONSOLE_HAS_METHOD (gtk, mark_device);
|
|
695 CONSOLE_HAS_METHOD (gtk, delete_device);
|
|
696 CONSOLE_HAS_METHOD (gtk, device_system_metrics);
|
545
|
697 /* CONSOLE_IMPLEMENTATION_FLAGS (gtk, XDEVIMPF_PIXEL_GEOMETRY); */
|
|
698 /* I inserted the above commented out statement, as the original
|
|
699 implementation of gtk_device_implementation_flags(), which I
|
|
700 deleted, contained commented out XDEVIMPF_PIXEL_GEOMETRY - kkm*/
|
462
|
701 }
|
|
702
|
|
703 void
|
|
704 vars_of_device_gtk (void)
|
|
705 {
|
|
706 Fprovide (Qgtk);
|
|
707
|
|
708 DEFVAR_LISP ("gtk-initial-argv-list", &Vgtk_initial_argv_list /*
|
|
709 You don't want to know.
|
|
710 This is used during startup to communicate the remaining arguments in
|
|
711 `command-line-args-left' to the C code, which passes the args to
|
|
712 the GTK initialization code, which removes some args, and then the
|
|
713 args are placed back into `gtk-initial-arg-list' and thence into
|
|
714 `command-line-args-left'. Perhaps `command-line-args-left' should
|
|
715 just reside in C.
|
|
716 */ );
|
|
717
|
|
718 DEFVAR_LISP ("gtk-initial-geometry", &Vgtk_initial_geometry /*
|
|
719 You don't want to know.
|
|
720 This is used during startup to communicate the default geometry to GTK.
|
|
721 */ );
|
|
722
|
|
723 Vgtk_initial_geometry = Qnil;
|
|
724 Vgtk_initial_argv_list = Qnil;
|
|
725 }
|
|
726
|
|
727 #include <gdk/gdkx.h>
|
|
728 static void
|
|
729 gtk_device_init_x_specific_cruft (struct device *d)
|
|
730 {
|
|
731 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (GDK_DISPLAY ());
|
|
732 }
|