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