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