Mercurial > hg > xemacs-beta
annotate src/device-gtk.c @ 5720:1d6995b6986e
Add and use `font-lock-extend-region-functions'.
2013-02-20 Michael Sperber <mike@xemacs.org>
* font-lock.el (font-lock-beg)
(font-lock-extend-region-functions)
(font-lock-extend-region-multiline)
(font-lock-extend-region-wholelines)
(font-lock-default-fontify-region): Add and use
`font-lock-extend-region-functions' from GNU Emacs.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Wed, 20 Feb 2013 11:09:08 +0100 |
parents | 56144c8593a8 |
children |
rev | line source |
---|---|
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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5228
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
462 | 9 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5228
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5228
diff
changeset
|
11 option) any later version. |
462 | 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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5228
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
462 | 20 |
21 /* Synched up with: Not in FSF. */ | |
22 | |
23 /* Original authors: Jamie Zawinski and the FSF */ | |
24 /* Rewritten by Ben Wing and Chuck Thompson. */ | |
25 /* Gtk flavor written by William Perry */ | |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 | |
872 | 30 #include "buffer.h" |
31 #include "device-impl.h" | |
32 #include "elhash.h" | |
33 #include "events.h" | |
34 #include "faces.h" | |
35 #include "frame-impl.h" | |
36 #include "redisplay.h" | |
37 #include "sysdep.h" | |
38 #include "window.h" | |
39 | |
40 #include "console-gtk-impl.h" | |
462 | 41 #include "gccache-gtk.h" |
42 #include "glyphs-gtk.h" | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
43 #include "fontcolor-gtk.h" |
462 | 44 #include "gtk-xemacs.h" |
45 | |
46 #include "sysfile.h" | |
47 #include "systime.h" | |
48 | |
49 #ifdef HAVE_GNOME | |
50 #include <libgnomeui/libgnomeui.h> | |
51 #endif | |
52 | |
53 #ifdef HAVE_BONOBO | |
54 #include <bonobo.h> | |
55 #endif | |
56 | |
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
57 Lisp_Object Qmake_device_early_gtk_entry_point, |
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
58 Qmake_device_late_gtk_entry_point; |
462 | 59 |
60 /* The application class of Emacs. */ | |
61 Lisp_Object Vgtk_emacs_application_class; | |
62 | |
63 Lisp_Object Vgtk_initial_argv_list; /* #### ugh! */ | |
64 Lisp_Object Vgtk_initial_geometry; | |
65 | |
2828 | 66 Lisp_Object Qgtk_seen_characters; |
67 | |
462 | 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 | |
3092 | 76 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
77 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("gtk-device", gtk_device, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
78 0, gtk_device_data_description_1, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
79 Lisp_Gtk_Device); |
3092 | 80 #else /* not NEW_GC */ |
1204 | 81 extern const struct sized_memory_description gtk_device_data_description; |
82 | |
83 const struct sized_memory_description gtk_device_data_description = { | |
84 sizeof (struct gtk_device), gtk_device_data_description_1 | |
85 }; | |
3092 | 86 #endif /* not NEW_GC */ |
1204 | 87 |
462 | 88 |
89 /************************************************************************/ | |
90 /* helper functions */ | |
91 /************************************************************************/ | |
92 | |
93 struct device * | |
94 decode_gtk_device (Lisp_Object device) | |
95 { | |
793 | 96 device = wrap_device (decode_device (device)); |
462 | 97 CHECK_GTK_DEVICE (device); |
98 return XDEVICE (device); | |
99 } | |
100 | |
101 | |
102 /************************************************************************/ | |
103 /* initializing a GTK connection */ | |
104 /************************************************************************/ | |
105 extern Lisp_Object | |
106 xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w); | |
107 | |
108 extern Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp); | |
109 | |
110 #define convert_font(f) __get_gtk_font_truename (f, 0) | |
111 | |
112 static void | |
113 allocate_gtk_device_struct (struct device *d) | |
114 { | |
3092 | 115 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
116 d->device_data = XGTK_DEVICE (ALLOC_NORMAL_LISP_OBJECT (gtk_device)); |
3092 | 117 #else /* not NEW_GC */ |
462 | 118 d->device_data = xnew_and_zero (struct gtk_device); |
3092 | 119 #endif /* not NEW_GC */ |
462 | 120 DEVICE_GTK_DATA (d)->x_keysym_map_hashtable = Qnil; |
121 } | |
122 | |
123 static void | |
124 gtk_init_device_class (struct device *d) | |
125 { | |
126 if (DEVICE_GTK_DEPTH(d) > 2) | |
127 { | |
128 switch (DEVICE_GTK_VISUAL(d)->type) | |
129 { | |
130 case GDK_VISUAL_STATIC_GRAY: | |
131 case GDK_VISUAL_GRAYSCALE: | |
132 DEVICE_CLASS (d) = Qgrayscale; | |
133 break; | |
134 default: | |
135 DEVICE_CLASS (d) = Qcolor; | |
136 } | |
137 } | |
138 else | |
139 DEVICE_CLASS (d) = Qmono; | |
140 } | |
141 | |
142 #ifdef HAVE_GDK_IMLIB_INIT | |
143 extern void gdk_imlib_init(void); | |
144 #endif | |
145 | |
863 | 146 extern void emacs_gtk_selection_handle (GtkWidget *, |
147 GtkSelectionData *selection_data, | |
148 guint info, | |
149 guint time_stamp, | |
150 gpointer data); | |
151 extern void emacs_gtk_selection_clear_event_handle (GtkWidget *widget, | |
152 GdkEventSelection *event, | |
153 gpointer data); | |
154 extern void emacs_gtk_selection_received (GtkWidget *widget, | |
155 GtkSelectionData *selection_data, | |
156 gpointer user_data); | |
157 | |
462 | 158 #ifdef HAVE_BONOBO |
159 static CORBA_ORB orb; | |
160 #endif | |
161 | |
162 DEFUN ("gtk-init", Fgtk_init, 1, 1, 0, /* | |
163 Initialize the GTK subsystem. | |
164 ARGS is a standard list of command-line arguments. | |
165 | |
166 No effect if called more than once. Called automatically when | |
167 creating the first GTK device. Must be called manually from batch | |
168 mode. | |
169 */ | |
170 (args)) | |
171 { | |
172 int argc; | |
173 char **argv; | |
174 static int done; | |
175 | |
176 if (done) | |
177 { | |
178 return (Qt); | |
179 } | |
180 | |
181 make_argc_argv (args, &argc, &argv); | |
182 | |
183 slow_down_interrupts (); | |
184 #ifdef HAVE_GNOME | |
185 gnome_init ("XEmacs", EMACS_VERSION, argc, argv); | |
186 #else | |
187 gtk_init (&argc, &argv); | |
188 #endif | |
189 | |
190 #ifdef HAVE_BONOBO | |
191 orb = oaf_init (argc, argv); | |
192 | |
193 if (bonobo_init (orb, NULL, NULL) == FALSE) | |
194 { | |
195 g_warning ("Could not initialize bonobo..."); | |
196 } | |
197 | |
198 bonobo_activate (); | |
199 #endif | |
200 | |
201 speed_up_interrupts (); | |
202 | |
203 free_argc_argv (argv); | |
204 return (Qt); | |
205 } | |
206 | |
207 static void | |
2286 | 208 gtk_init_device (struct device *d, Lisp_Object UNUSED (props)) |
462 | 209 { |
210 Lisp_Object display; | |
211 GtkWidget *app_shell = NULL; | |
212 GdkVisual *visual = NULL; | |
213 GdkColormap *cmap = NULL; | |
214 | |
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
215 /* Run the early elisp side of the GTK device initialization. */ |
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
216 call0 (Qmake_device_early_gtk_entry_point); |
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
217 |
462 | 218 /* gtk_init() and even gtk_check_init() are so brain dead that |
219 getting an empty argv array causes them to abort. */ | |
220 if (NILP (Vgtk_initial_argv_list)) | |
221 { | |
563 | 222 invalid_operation ("gtk-initial-argv-list must be set before creating Gtk devices", Vgtk_initial_argv_list); |
462 | 223 return; |
224 } | |
225 | |
226 allocate_gtk_device_struct (d); | |
227 display = DEVICE_CONNECTION (d); | |
228 | |
229 /* Attempt to load a site-specific gtkrc */ | |
230 { | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
231 Lisp_Object gtkrc = Fexpand_file_name (build_ascstring ("gtkrc"), Vdata_directory); |
462 | 232 gchar **default_files = gtk_rc_get_default_files (); |
233 gint num_files; | |
234 | |
235 if (STRINGP (gtkrc)) | |
236 { | |
237 /* Found one, load it up! */ | |
238 gchar **new_rc_files = NULL; | |
239 int ctr; | |
240 | |
241 for (num_files = 0; default_files[num_files]; num_files++); | |
242 | |
243 new_rc_files = xnew_array_and_zero (gchar *, num_files + 3); | |
244 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
245 LISP_PATHNAME_CONVERT_OUT (gtkrc, new_rc_files[0]); |
2054 | 246 |
462 | 247 for (ctr = 1; default_files[ctr-1]; ctr++) |
248 new_rc_files[ctr] = g_strdup (default_files[ctr-1]); | |
249 | |
250 gtk_rc_set_default_files (new_rc_files); | |
251 | |
252 for (ctr = 1; new_rc_files[ctr]; ctr++) | |
253 free(new_rc_files[ctr]); | |
254 | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
255 xfree (new_rc_files); |
462 | 256 } |
257 } | |
258 | |
259 Fgtk_init (Vgtk_initial_argv_list); | |
260 | |
261 #ifdef __FreeBSD__ | |
262 gdk_set_use_xshm (FALSE); | |
263 #endif | |
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 | |
329 static void | |
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
330 gtk_finish_init_device (struct device *d, Lisp_Object UNUSED (props)) |
462 | 331 { |
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
332 call1 (Qmake_device_late_gtk_entry_point, wrap_device(d)); |
462 | 333 } |
334 | |
335 static void | |
336 gtk_mark_device (struct device *d) | |
337 { | |
338 mark_object (DEVICE_GTK_WM_COMMAND_FRAME (d)); | |
339 mark_object (DEVICE_GTK_DATA (d)->x_keysym_map_hashtable); | |
340 } | |
341 | |
342 | |
343 /************************************************************************/ | |
344 /* closing an X connection */ | |
345 /************************************************************************/ | |
346 | |
4117 | 347 #ifndef NEW_GC |
462 | 348 static void |
349 free_gtk_device_struct (struct device *d) | |
350 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
351 xfree (d->device_data); |
4117 | 352 } |
3092 | 353 #endif /* not NEW_GC */ |
462 | 354 |
355 static void | |
356 gtk_delete_device (struct device *d) | |
357 { | |
358 #ifdef FREE_CHECKING | |
359 extern void (*__free_hook)(); | |
360 int checking_free; | |
361 #endif | |
362 | |
363 if (1) | |
364 { | |
365 #ifdef FREE_CHECKING | |
366 checking_free = (__free_hook != 0); | |
367 | |
368 /* Disable strict free checking, to avoid bug in X library */ | |
369 if (checking_free) | |
370 disable_strict_free_check (); | |
371 #endif | |
372 | |
373 free_gc_cache (DEVICE_GTK_GC_CACHE (d)); | |
374 | |
375 #ifdef FREE_CHECKING | |
376 if (checking_free) | |
377 enable_strict_free_check (); | |
378 #endif | |
379 } | |
380 | |
381 free_gtk_device_struct (d); | |
382 } | |
383 | |
384 | |
385 /************************************************************************/ | |
386 /* handle X errors */ | |
387 /************************************************************************/ | |
388 | |
389 const char * | |
390 gtk_event_name (GdkEventType event_type) | |
391 { | |
392 GtkEnumValue *vals = gtk_type_enum_get_values (GTK_TYPE_GDK_EVENT_TYPE); | |
393 | |
778 | 394 while (vals && ((GdkEventType)(vals->value) != event_type)) vals++; |
462 | 395 |
396 if (vals) | |
397 return (vals->value_nick); | |
398 | |
399 return (NULL); | |
400 } | |
401 | |
402 | |
403 /************************************************************************/ | |
404 /* display information functions */ | |
405 /************************************************************************/ | |
406 | |
407 DEFUN ("gtk-display-visual-class", Fgtk_display_visual_class, 0, 1, 0, /* | |
408 Return the visual class of the GTK display DEVICE is using. | |
409 The returned value will be one of the symbols `static-gray', `gray-scale', | |
410 `static-color', `pseudo-color', `true-color', or `direct-color'. | |
411 */ | |
412 (device)) | |
413 { | |
414 GdkVisual *vis = DEVICE_GTK_VISUAL (decode_gtk_device (device)); | |
415 switch (vis->type) | |
416 { | |
417 case GDK_VISUAL_STATIC_GRAY: return intern ("static-gray"); | |
418 case GDK_VISUAL_GRAYSCALE: return intern ("gray-scale"); | |
419 case GDK_VISUAL_STATIC_COLOR: return intern ("static-color"); | |
420 case GDK_VISUAL_PSEUDO_COLOR: return intern ("pseudo-color"); | |
421 case GDK_VISUAL_TRUE_COLOR: return intern ("true-color"); | |
422 case GDK_VISUAL_DIRECT_COLOR: return intern ("direct-color"); | |
423 default: | |
563 | 424 invalid_state ("display has an unknown visual class", Qunbound); |
462 | 425 return Qnil; /* suppress compiler warning */ |
426 } | |
427 } | |
428 | |
429 DEFUN ("gtk-display-visual-depth", Fgtk_display_visual_depth, 0, 1, 0, /* | |
430 Return the bitplane depth of the visual the GTK display DEVICE is using. | |
431 */ | |
432 (device)) | |
433 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
434 return make_fixnum (DEVICE_GTK_DEPTH (decode_gtk_device (device))); |
462 | 435 } |
436 | |
437 static Lisp_Object | |
438 gtk_device_system_metrics (struct device *d, | |
439 enum device_metrics m) | |
440 { | |
441 #if 0 | |
442 GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (DEVICE_GTK_APP_SHELL (d))); | |
443 | |
444 style = gtk_style_attach (style, w); | |
445 #endif | |
446 | |
447 switch (m) | |
448 { | |
449 case DM_size_device: | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
450 return Fcons (make_fixnum (gdk_screen_width ()), |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
451 make_fixnum (gdk_screen_height ())); |
462 | 452 case DM_size_device_mm: |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
453 return Fcons (make_fixnum (gdk_screen_width_mm ()), |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
454 make_fixnum (gdk_screen_height_mm ())); |
462 | 455 case DM_num_color_cells: |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
456 return make_fixnum (gdk_colormap_get_system_size ()); |
462 | 457 case DM_num_bit_planes: |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
458 return make_fixnum (DEVICE_GTK_DEPTH (d)); |
462 | 459 |
460 #if 0 | |
461 case DM_color_default: | |
462 case DM_color_select: | |
463 case DM_color_balloon: | |
464 case DM_color_3d_face: | |
465 case DM_color_3d_light: | |
466 case DM_color_3d_dark: | |
467 case DM_color_menu: | |
468 case DM_color_menu_highlight: | |
469 case DM_color_menu_button: | |
470 case DM_color_menu_disabled: | |
471 case DM_color_toolbar: | |
472 case DM_color_scrollbar: | |
473 case DM_color_desktop: | |
474 case DM_color_workspace: | |
475 case DM_font_default: | |
476 case DM_font_menubar: | |
477 case DM_font_dialog: | |
478 case DM_size_cursor: | |
479 case DM_size_scrollbar: | |
480 case DM_size_menu: | |
481 case DM_size_toolbar: | |
482 case DM_size_toolbar_button: | |
483 case DM_size_toolbar_border: | |
484 case DM_size_icon: | |
485 case DM_size_icon_small: | |
486 case DM_size_workspace: | |
487 case DM_device_dpi: | |
488 case DM_mouse_buttons: | |
489 case DM_swap_buttons: | |
490 case DM_show_sounds: | |
491 case DM_slow_device: | |
492 case DM_security: | |
493 #endif | |
494 default: /* No such device metric property for GTK devices */ | |
495 return Qunbound; | |
496 } | |
497 } | |
498 | |
499 DEFUN ("gtk-keysym-on-keyboard-p", Fgtk_keysym_on_keyboard_p, 1, 2, 0, /* | |
500 Return true if KEYSYM names a key on the keyboard of DEVICE. | |
501 More precisely, return true if some keystroke (possibly including modifiers) | |
502 on the keyboard of DEVICE keys generates KEYSYM. | |
503 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in | |
504 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. | |
505 The keysym name can be provided in two forms: | |
506 - if keysym is a string, it must be the name as known to X windows. | |
507 - if keysym is a symbol, it must be the name as known to XEmacs. | |
508 The two names differ in capitalization and underscoring. | |
509 */ | |
510 (keysym, device)) | |
511 { | |
512 struct device *d = decode_device (device); | |
513 | |
514 if (!DEVICE_GTK_P (d)) | |
563 | 515 gui_error ("Not a GTK device", device); |
462 | 516 |
517 return (NILP (Fgethash (keysym, DEVICE_GTK_DATA (d)->x_keysym_map_hashtable, Qnil)) ? | |
518 Qnil : Qt); | |
519 } | |
520 | |
521 | |
522 /************************************************************************/ | |
523 /* grabs and ungrabs */ | |
524 /************************************************************************/ | |
525 | |
526 DEFUN ("gtk-grab-pointer", Fgtk_grab_pointer, 0, 3, 0, /* | |
527 Grab the pointer and restrict it to its current window. | |
528 If optional DEVICE argument is nil, the default device will be used. | |
529 If optional CURSOR argument is non-nil, change the pointer shape to that | |
530 until `gtk-ungrab-pointer' is called (it should be an object returned by the | |
531 `make-cursor-glyph' function). | |
532 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all | |
533 keyboard events during the grab. | |
534 Returns t if the grab is successful, nil otherwise. | |
535 */ | |
2286 | 536 (device, cursor, UNUSED (ignore_keyboard))) |
462 | 537 { |
538 GdkWindow *w; | |
539 int result; | |
540 struct device *d = decode_gtk_device (device); | |
541 | |
542 if (!NILP (cursor)) | |
543 { | |
544 CHECK_POINTER_GLYPH (cursor); | |
545 cursor = glyph_image_instance (cursor, device, ERROR_ME, 0); | |
546 } | |
547 | |
548 /* We should call gdk_pointer_grab() and (possibly) gdk_keyboard_grab() here instead */ | |
549 w = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (device_selected_frame (d))); | |
550 | |
551 result = gdk_pointer_grab (w, FALSE, | |
2054 | 552 (GdkEventMask) (GDK_POINTER_MOTION_MASK | |
553 GDK_POINTER_MOTION_HINT_MASK | | |
554 GDK_BUTTON1_MOTION_MASK | | |
555 GDK_BUTTON2_MOTION_MASK | | |
556 GDK_BUTTON3_MOTION_MASK | | |
557 GDK_BUTTON_PRESS_MASK | | |
558 GDK_BUTTON_RELEASE_MASK), | |
462 | 559 w, |
560 NULL, /* #### BILL!!! Need to create a GdkCursor * as necessary! */ | |
561 GDK_CURRENT_TIME); | |
562 | |
563 return (result == 0) ? Qt : Qnil; | |
564 } | |
565 | |
566 DEFUN ("gtk-ungrab-pointer", Fgtk_ungrab_pointer, 0, 1, 0, /* | |
567 Release a pointer grab made with `gtk-grab-pointer'. | |
568 If optional first arg DEVICE is nil the default device is used. | |
569 If it is t the pointer will be released on all GTK devices. | |
570 */ | |
571 (device)) | |
572 { | |
573 if (!EQ (device, Qt)) | |
574 { | |
575 gdk_pointer_ungrab (GDK_CURRENT_TIME); | |
576 } | |
577 else | |
578 { | |
579 Lisp_Object devcons, concons; | |
580 | |
581 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
582 { | |
583 struct device *d = XDEVICE (XCAR (devcons)); | |
584 | |
585 if (DEVICE_GTK_P (d)) | |
586 gdk_pointer_ungrab (GDK_CURRENT_TIME); | |
587 } | |
588 } | |
589 return Qnil; | |
590 } | |
591 | |
592 DEFUN ("gtk-grab-keyboard", Fgtk_grab_keyboard, 0, 1, 0, /* | |
593 Grab the keyboard on the given device (defaulting to the selected one). | |
594 So long as the keyboard is grabbed, all keyboard events will be delivered | |
595 to emacs -- it is not possible for other clients to eavesdrop on them. | |
596 Ungrab the keyboard with `gtk-ungrab-keyboard' (use an unwind-protect). | |
597 Returns t if the grab is successful, nil otherwise. | |
598 */ | |
599 (device)) | |
600 { | |
601 struct device *d = decode_gtk_device (device); | |
602 GdkWindow *w = GET_GTK_WIDGET_WINDOW (FRAME_GTK_TEXT_WIDGET (device_selected_frame (d))); | |
603 | |
604 gdk_keyboard_grab (w, FALSE, GDK_CURRENT_TIME ); | |
605 | |
606 return Qt; | |
607 } | |
608 | |
609 DEFUN ("gtk-ungrab-keyboard", Fgtk_ungrab_keyboard, 0, 1, 0, /* | |
610 Release a keyboard grab made with `gtk-grab-keyboard'. | |
611 */ | |
2286 | 612 (UNUSED (device))) |
462 | 613 { |
614 gdk_keyboard_ungrab (GDK_CURRENT_TIME); | |
615 return Qnil; | |
616 } | |
617 | |
618 | |
619 /************************************************************************/ | |
620 /* Style Info */ | |
621 /************************************************************************/ | |
622 DEFUN ("gtk-style-info", Fgtk_style_info, 0, 1, 0, /* | |
623 Get the style information for a Gtk device. | |
624 */ | |
625 (device)) | |
626 { | |
627 struct device *d = decode_device (device); | |
628 GtkStyle *style = NULL; | |
629 Lisp_Object result = Qnil; | |
630 GtkWidget *app_shell = GTK_WIDGET (DEVICE_GTK_APP_SHELL (d)); | |
631 GdkWindow *w = GET_GTK_WIDGET_WINDOW (app_shell); | |
632 | |
633 if (!DEVICE_GTK_P (d)) | |
634 return (Qnil); | |
635 | |
636 style = gtk_widget_get_style (app_shell); | |
637 style = gtk_style_attach (style, w); | |
638 | |
639 if (!style) return (Qnil); | |
640 | |
641 #define FROB_COLOR(slot, name) \ | |
642 result = nconc2 (result, \ | |
643 list2 (intern (name), \ | |
644 list5 (xemacs_gtk_convert_color (&style->slot[GTK_STATE_NORMAL], app_shell),\ | |
645 xemacs_gtk_convert_color (&style->slot[GTK_STATE_ACTIVE], app_shell),\ | |
646 xemacs_gtk_convert_color (&style->slot[GTK_STATE_PRELIGHT], app_shell),\ | |
647 xemacs_gtk_convert_color (&style->slot[GTK_STATE_SELECTED], app_shell),\ | |
648 xemacs_gtk_convert_color (&style->slot[GTK_STATE_INSENSITIVE], app_shell)))) | |
649 | |
650 FROB_COLOR (fg, "foreground"); | |
651 FROB_COLOR (bg, "background"); | |
652 FROB_COLOR (light, "light"); | |
653 FROB_COLOR (dark, "dark"); | |
654 FROB_COLOR (mid, "mid"); | |
655 FROB_COLOR (text, "text"); | |
656 FROB_COLOR (base, "base"); | |
657 #undef FROB_COLOR | |
658 | |
659 result = nconc2 (result, list2 (Qfont, convert_font (style->font))); | |
660 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
661 #define FROB_PIXMAP(state) (style->rc_style->bg_pixmap_name[state] ? build_cistring (style->rc_style->bg_pixmap_name[state]) : Qnil) |
462 | 662 |
663 if (style->rc_style) | |
664 result = nconc2 (result, list2 (Qbackground, | |
665 list5 ( FROB_PIXMAP (GTK_STATE_NORMAL), | |
666 FROB_PIXMAP (GTK_STATE_ACTIVE), | |
667 FROB_PIXMAP (GTK_STATE_PRELIGHT), | |
668 FROB_PIXMAP (GTK_STATE_SELECTED), | |
669 FROB_PIXMAP (GTK_STATE_INSENSITIVE)))); | |
670 #undef FROB_PIXMAP | |
671 | |
672 return (result); | |
673 } | |
674 | |
675 | |
676 /************************************************************************/ | |
677 /* initialization */ | |
678 /************************************************************************/ | |
679 | |
680 void | |
681 syms_of_device_gtk (void) | |
682 { | |
3092 | 683 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
684 INIT_LISP_OBJECT (gtk_device); |
3092 | 685 #endif /* NEW_GC */ |
686 | |
462 | 687 DEFSUBR (Fgtk_keysym_on_keyboard_p); |
688 DEFSUBR (Fgtk_display_visual_class); | |
689 DEFSUBR (Fgtk_display_visual_depth); | |
690 DEFSUBR (Fgtk_style_info); | |
691 DEFSUBR (Fgtk_grab_pointer); | |
692 DEFSUBR (Fgtk_ungrab_pointer); | |
693 DEFSUBR (Fgtk_grab_keyboard); | |
694 DEFSUBR (Fgtk_ungrab_keyboard); | |
695 DEFSUBR (Fgtk_init); | |
696 | |
4477
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
697 DEFSYMBOL (Qmake_device_early_gtk_entry_point); |
e34711681f30
Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents:
4117
diff
changeset
|
698 DEFSYMBOL (Qmake_device_late_gtk_entry_point); |
462 | 699 } |
700 | |
701 void | |
702 console_type_create_device_gtk (void) | |
703 { | |
704 CONSOLE_HAS_METHOD (gtk, init_device); | |
705 CONSOLE_HAS_METHOD (gtk, finish_init_device); | |
706 CONSOLE_HAS_METHOD (gtk, mark_device); | |
707 CONSOLE_HAS_METHOD (gtk, delete_device); | |
708 CONSOLE_HAS_METHOD (gtk, device_system_metrics); | |
545 | 709 /* CONSOLE_IMPLEMENTATION_FLAGS (gtk, XDEVIMPF_PIXEL_GEOMETRY); */ |
710 /* I inserted the above commented out statement, as the original | |
711 implementation of gtk_device_implementation_flags(), which I | |
712 deleted, contained commented out XDEVIMPF_PIXEL_GEOMETRY - kkm*/ | |
462 | 713 } |
714 | |
715 void | |
716 vars_of_device_gtk (void) | |
717 { | |
718 Fprovide (Qgtk); | |
719 | |
720 DEFVAR_LISP ("gtk-initial-argv-list", &Vgtk_initial_argv_list /* | |
721 You don't want to know. | |
722 This is used during startup to communicate the remaining arguments in | |
723 `command-line-args-left' to the C code, which passes the args to | |
724 the GTK initialization code, which removes some args, and then the | |
725 args are placed back into `gtk-initial-arg-list' and thence into | |
726 `command-line-args-left'. Perhaps `command-line-args-left' should | |
727 just reside in C. | |
728 */ ); | |
729 | |
730 DEFVAR_LISP ("gtk-initial-geometry", &Vgtk_initial_geometry /* | |
731 You don't want to know. | |
732 This is used during startup to communicate the default geometry to GTK. | |
733 */ ); | |
734 | |
735 Vgtk_initial_geometry = Qnil; | |
736 Vgtk_initial_argv_list = Qnil; | |
2828 | 737 |
738 Qgtk_seen_characters = Qnil; | |
462 | 739 } |
740 | |
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
741 #include "sysgdkx.h" |
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4477
diff
changeset
|
742 |
462 | 743 static void |
744 gtk_device_init_x_specific_cruft (struct device *d) | |
745 { | |
746 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (GDK_DISPLAY ()); | |
747 } |