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