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