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