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