annotate src/event-gtk.c @ 4419:eb82fbb675ea

Use Mercurial changeset hash to identify build version. 2008-01-25 Michael Sperber <mike@xemacs.org> * Makefile.in.in: * configure.ac: * version.sh.in: Use Mercurial tip hash to identify version instead of old CVS method. 2008-01-25 Michael Sperber <mike@xemacs.org> * build-report.el (build-report-version-file-regexp): Adjust to handle Mercurial hash. 2008-01-25 Michael Sperber <mike@xemacs.org> * xemacs.mak (version.sh): Generate version.sh via Mercurial. 2008-01-25 Michael Sperber <mike@xemacs.org> * emacs.c (vars_of_emacs): Zap mention of CVS.
author Mike Sperber <sperber@deinprogramm.de>
date Thu, 07 Feb 2008 10:03:49 +0100
parents 33b9323388c5
children bc4f2511bbea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* The event_stream interface for X11 with gtk, and/or tty frames.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1991-5, 1997 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
4 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 Copyright (C) 2000 William Perry.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24 /* This file is heavily based upon event-Xt.c */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "blocktype.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 #include "commands.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 #include "console.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
36 #include "elhash.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 #include "events.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "file-coding.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
39 #include "frame-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
40 #include "lstream.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 #include "process.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 #include "redisplay.h"
809
285f13b079f3 [xemacs-hg @ 2002-04-07 16:01:30 by wmperry]
wmperry
parents: 800
diff changeset
43 #include "window.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
44
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
45 #include "console-tty.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
46
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
47 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
48 #include "objects-gtk.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 #include "gtk-xemacs.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 #include "systime.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 #include "sysproc.h" /* for MAXDESC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 #include <gdk/gdkkeysyms.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 #ifdef HAVE_DRAGNDROP
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 #include "dragdrop.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60
2081
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
61 #ifdef HAVE_MENUBARS
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
62 # include "menubar.h"
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
63 #endif
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
64
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 #if defined (HAVE_OFFIX_DND)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 #include "offix.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
69 #include <gdk/gdkx.h>
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70
778
2923009caf47 [xemacs-hg @ 2002-03-16 10:38:59 by ben]
ben
parents: 771
diff changeset
71 #include "event-gtk.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 static struct event_stream *gtk_event_stream;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
75 #ifdef WIN32_ANY
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
76 extern int mswindows_is_blocking;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
77 #endif
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
78
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 /* Do we accept events sent by other clients? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 int gtk_allow_sendevents;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 static int process_events_occurred;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 static int tty_events_occurred;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 /* Mask of bits indicating the descriptors that we wait for input on */
1415
d47e87058e8f [xemacs-hg @ 2003-04-15 17:01:56 by stephent]
stephent
parents: 1292
diff changeset
86 extern SELECT_TYPE input_wait_mask, non_fake_input_wait_mask;
d47e87058e8f [xemacs-hg @ 2003-04-15 17:01:56 by stephent]
stephent
parents: 1292
diff changeset
87 extern SELECT_TYPE process_only_mask, tty_only_mask;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
89 static Lisp_Object gtk_keysym_to_emacs_keysym (guint keysym, int simple_p);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 void debug_process_finalization (struct Lisp_Process *p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 gboolean emacs_gtk_event_handler (GtkWidget *wid /* unused */,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 GdkEvent *event,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 gpointer closure /* unused */);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 static int last_quit_check_signal_tick_count;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 Lisp_Object Qsans_modifiers;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98
2489
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
99 /*
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
100 * Identify if the keysym is a modifier. This implementation mirrors x.org's
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
101 * IsModifierKey(), but for GDK keysyms.
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
102 */
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
103 #ifdef GDK_ISO_Lock
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
104 #define IS_MODIFIER_KEY(keysym) \
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
105 ((((keysym) >= GDK_Shift_L) && ((keysym) <= GDK_Hyper_R)) \
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
106 || (((keysym) >= GDK_ISO_Lock) && \
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
107 ((keysym) <= GDK_ISO_Last_Group_Lock)) \
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
108 || ((keysym) == GDK_Mode_switch) \
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
109 || ((keysym) == GDK_Num_Lock))
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
110 #else
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 #define IS_MODIFIER_KEY(keysym) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 ((((keysym) >= GDK_Shift_L) && ((keysym) <= GDK_Hyper_R)) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 || ((keysym) == GDK_Mode_switch) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 || ((keysym) == GDK_Num_Lock))
2489
f81997b69560 [xemacs-hg @ 2005-01-19 23:10:16 by malcolmp]
malcolmp
parents: 2367
diff changeset
115 #endif
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
117 #define THIS_IS_GTK
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
118 #include "event-xlike-inc.c"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 /* magic-event handling */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 handle_focus_event_1 (struct frame *f, int in_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 /* We don't want to handle the focus change now, because we might
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 be in an accept-process-output, sleep-for, or sit-for. So
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 we enqueue it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 Actually, we half handle it: we handle it as far as changing the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 box cursor for redisplay, but we don't call any hooks or do any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 select-frame stuff until after the sit-for.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 if (in_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 GTK_WIDGET_SET_FLAGS (FRAME_GTK_TEXT_WIDGET (f), GTK_HAS_FOCUS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 GTK_WIDGET_UNSET_FLAGS (FRAME_GTK_TEXT_WIDGET (f), GTK_HAS_FOCUS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 gtk_widget_grab_focus (FRAME_GTK_TEXT_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 gtk_widget_draw_focus (FRAME_GTK_TEXT_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 Lisp_Object frm;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 Lisp_Object conser;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
152 frm = wrap_frame (f);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 conser = Fcons (frm, Fcons (FRAME_DEVICE (f), in_p ? Qt : Qnil));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 GCPRO1 (conser);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 emacs_handle_focus_change_preliminary (conser);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 enqueue_magic_eval_event (emacs_handle_focus_change_final,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 conser);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 /* both GDK_MAP and GDK_VISIBILITY_NOTIFY can cause this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 JV is_visible has the same semantics as f->visible*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 change_frame_visibility (struct frame *f, int is_visible)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
168 Lisp_Object frame = wrap_frame (f);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 if (!FRAME_VISIBLE_P (f) && is_visible)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 FRAME_VISIBLE_P (f) = is_visible;
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
174 /* [[ This improves the double flicker when uniconifying a frame
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 some. A lot of it is not showing a buffer which has changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 while the frame was iconified. To fix it further requires
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
177 the good 'ol double redisplay structure. ]] -- comment is
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
178 invalid, obviously predates 19.12, when the double redisplay
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
179 structure (i.e. current + desired) was put back in. --ben */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 va_run_hook_with_args (Qmap_frame_hook, 1, frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 else if (FRAME_VISIBLE_P (f) && !is_visible)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 FRAME_VISIBLE_P (f) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 va_run_hook_with_args (Qunmap_frame_hook, 1, frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 else if (FRAME_VISIBLE_P (f) * is_visible < 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 FRAME_VISIBLE_P(f) = - FRAME_VISIBLE_P(f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 if (FRAME_REPAINT_P (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 va_run_hook_with_args (Qmap_frame_hook, 1, frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 handle_map_event (struct frame *f, GdkEvent *event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
200 Lisp_Object frame = wrap_frame (f);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 if (event->any.type == GDK_MAP)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 FRAME_GTK_TOTALLY_VISIBLE_P (f) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 change_frame_visibility (f, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 FRAME_GTK_TOTALLY_VISIBLE_P (f) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 change_frame_visibility (f, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 /* Calling Fframe_iconified_p is the only way we have to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 correctly update FRAME_ICONIFIED_P */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 Fframe_iconified_p (frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 handle_client_message (struct frame *f, GdkEvent *event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 /* The event-Xt code used to handle WM_DELETE_WINDOW here, but we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 handle that directly in frame-gtk.c */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 if (event->client.message_type == gdk_atom_intern ("WM_PROTOCOLS", 0) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 (GdkAtom) event->client.data.l[0] == gdk_atom_intern ("WM_TAKE_FOCUS", 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 handle_focus_event_1 (f, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 static void
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
231 emacs_gtk_format_magic_event (Lisp_Event *emacs_event, Lisp_Object pstream)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
232 {
789
06b73d289047 [xemacs-hg @ 2002-03-21 15:13:41 by wmperry]
wmperry
parents: 788
diff changeset
233 Lisp_Object console = CDFW_CONSOLE (EVENT_CHANNEL (emacs_event));
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
234 if (CONSOLE_GTK_P (XCONSOLE (console)))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
235 write_c_string
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 809
diff changeset
236 (pstream,
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
237 gtk_event_name (EVENT_MAGIC_GDK_EVENT (emacs_event).type));
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
238 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
239
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
240 static int
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
241 emacs_gtk_compare_magic_event (Lisp_Event *e1, Lisp_Event *e2)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
242 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
243 if (CONSOLE_GTK_P (XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e1)))) &&
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
244 CONSOLE_GTK_P (XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e2)))))
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
245 return (!memcmp (&EVENT_MAGIC_GDK_EVENT (e1),
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
246 &EVENT_MAGIC_GDK_EVENT (e2),
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
247 sizeof (GdkEvent)));
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
248 if (CONSOLE_GTK_P (XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e1)))) ||
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
249 CONSOLE_GTK_P (XCONSOLE (CDFW_CONSOLE (EVENT_CHANNEL (e2)))))
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
250 return 0;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
251 return 1;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
252 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
253
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
254 static Hashcode
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
255 emacs_gtk_hash_magic_event (Lisp_Event *e)
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
256 {
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
257 Lisp_Object console = CDFW_CONSOLE (EVENT_CHANNEL (e));
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
258 if (CONSOLE_GTK_P (XCONSOLE (console)))
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
259 return memory_hash (&EVENT_MAGIC_GDK_EVENT (e),
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
260 sizeof (GdkEvent));
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
261 return 0;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
262 }
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
263
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
264 static void
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 emacs_gtk_handle_magic_event (struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 /* This function can GC */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
268 GdkEvent *event = &EVENT_MAGIC_GDK_EVENT (emacs_event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 if (!FRAME_LIVE_P (f))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 switch (event->any.type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 case GDK_CLIENT_EVENT:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 handle_client_message (f, event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 case GDK_FOCUS_CHANGE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 handle_focus_event_1 (f, event->focus_change.in);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 case GDK_MAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 case GDK_UNMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 handle_map_event (f, event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 case GDK_ENTER_NOTIFY:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 if (event->crossing.detail != GDK_NOTIFY_INFERIOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
292 Lisp_Object frame = wrap_frame (f);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 /* FRAME_X_MOUSE_P (f) = 1; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 va_run_hook_with_args (Qmouse_enter_frame_hook, 1, frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 case GDK_LEAVE_NOTIFY:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 if (event->crossing.detail != GDK_NOTIFY_INFERIOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
302 Lisp_Object frame = wrap_frame (f);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 /* FRAME_X_MOUSE_P (f) = 0; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 va_run_hook_with_args (Qmouse_leave_frame_hook, 1, frame);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 case GDK_VISIBILITY_NOTIFY: /* window visiblity has changed */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 if (event->visibility.window == GET_GTK_WIDGET_WINDOW (FRAME_GTK_SHELL_WIDGET (f)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 FRAME_GTK_TOTALLY_VISIBLE_P (f) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 (event->visibility.state == GDK_VISIBILITY_UNOBSCURED);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 /* Note that the fvwm pager only sends VisibilityNotify when
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 changing pages. Is this all we need to do ? JV */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 /* Nope. We must at least trigger a redisplay here.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 Since this case seems similar to MapNotify, I've
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 factored out some code to change_frame_visibility().
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 This triggers the necessary redisplay and runs
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 (un)map-frame-hook. - dkindred@cs.cmu.edu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 /* Changed it again to support the tristate visibility flag */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 change_frame_visibility (f, (event->visibility.state
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 != GDK_VISIBILITY_FULLY_OBSCURED) ? 1 : -1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 /* Gtk to Emacs event conversion */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 keysym_obeys_caps_lock_p (guint sym, struct device *d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 struct gtk_device *gd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 /* Eeeeevil hack. Don't apply Caps_Lock to things that aren't alphabetic
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 characters, where "alphabetic" means something more than simply A-Z.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 That is, if Caps_Lock is down, typing ESC doesn't produce Shift-ESC.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 But if shift-lock is down, then it does. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 if (gd->lock_interpretation == GDK_Shift_Lock)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 return
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 ((sym >= GDK_A) && (sym <= GDK_Z)) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 ((sym >= GDK_a) && (sym <= GDK_z)) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 ((sym >= GDK_Agrave) && (sym <= GDK_Odiaeresis)) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 ((sym >= GDK_agrave) && (sym <= GDK_odiaeresis)) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 ((sym >= GDK_Ooblique) && (sym <= GDK_Thorn)) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 ((sym >= GDK_oslash) && (sym <= GDK_thorn));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 set_last_server_timestamp (struct device *d, GdkEvent *gdk_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 guint32 t;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 switch (gdk_event->type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 case GDK_KEY_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 case GDK_KEY_RELEASE: t = gdk_event->key.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 case GDK_BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 case GDK_2BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 case GDK_3BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367 case GDK_BUTTON_RELEASE: t = gdk_event->button.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 case GDK_ENTER_NOTIFY:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 case GDK_LEAVE_NOTIFY: t = gdk_event->crossing.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 case GDK_MOTION_NOTIFY: t = gdk_event->motion.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 case GDK_PROPERTY_NOTIFY: t = gdk_event->property.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 case GDK_SELECTION_CLEAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 case GDK_SELECTION_REQUEST:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 case GDK_SELECTION_NOTIFY: t = gdk_event->selection.time; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 default: return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 DEVICE_GTK_LAST_SERVER_TIMESTAMP (d) = t;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 gtk_keysym_to_emacs_keysym (guint keysym, int simple_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 char *name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 if (keysym >= GDK_exclam && keysym <= GDK_asciitilde)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 /* We must assume that the X keysym numbers for the ASCII graphic
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 characters are the same as their ASCII codes. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 return make_char (keysym);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 switch (keysym)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 /* These would be handled correctly by the default case, but by
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 special-casing them here we don't garbage a string or call
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 intern(). */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 case GDK_BackSpace: return QKbackspace;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 case GDK_Tab: return QKtab;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 case GDK_Linefeed: return QKlinefeed;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 case GDK_Return: return QKreturn;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 case GDK_Escape: return QKescape;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 case GDK_space: return QKspace;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 case GDK_Delete: return QKdelete;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 case 0: return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 if (simple_p) return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 /* !!#### not Mule-ized */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 name = gdk_keyval_name (keysym);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 if (!name || !name[0])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 /* This happens if there is a mismatch between the Xlib of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 XEmacs and the Xlib of the X server...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 Let's hard-code in some knowledge of common keysyms introduced
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 in recent X11 releases. Snarfed from X11/keysymdef.h
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 Probably we should add some stuff here for X11R6. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 switch (keysym)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 case 0xFF95: return KEYSYM ("kp-home");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 case 0xFF96: return KEYSYM ("kp-left");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 case 0xFF97: return KEYSYM ("kp-up");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 case 0xFF98: return KEYSYM ("kp-right");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 case 0xFF99: return KEYSYM ("kp-down");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 case 0xFF9A: return KEYSYM ("kp-prior");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 case 0xFF9B: return KEYSYM ("kp-next");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 case 0xFF9C: return KEYSYM ("kp-end");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 case 0xFF9D: return KEYSYM ("kp-begin");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 case 0xFF9E: return KEYSYM ("kp-insert");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 case 0xFF9F: return KEYSYM ("kp-delete");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 case 0x1005FF10: return KEYSYM ("SunF36"); /* labeled F11 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 case 0x1005FF11: return KEYSYM ("SunF37"); /* labeled F12 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 char buf [64];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 sprintf (buf, "unknown-keysym-0x%X", (int) keysym);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 return KEYSYM (buf);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 /* If it's got a one-character name, that's good enough. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 if (!name[1])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 return make_char (name[0]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 /* If it's in the "Keyboard" character set, downcase it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 The case of those keysyms is too totally random for us to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 force anyone to remember them.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 The case of the other character sets is significant, however.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 if ((((unsigned int) keysym) & (~0x1FF)) == ((unsigned int) 0xFE00))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 char buf [255];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 char *s1, *s2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 for (s1 = name, s2 = buf; *s1; s1++, s2++) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 if (*s1 == '_') {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 *s2 = '-';
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 } else {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 *s2 = tolower (* (unsigned char *) s1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 *s2 = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 return KEYSYM (buf);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 return KEYSYM (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 gtk_to_emacs_keysym (struct device *d, GdkEventKey *event, int simple_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466 /* simple_p means don't try too hard (ASCII only) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 if (event->length != 1)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
469 {
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 /* Generate multiple emacs events */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
471 Ichar ch;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 Lisp_Object instream, fb_instream;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 Lstream *istr;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 struct gcpro gcpro1, gcpro2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 fb_instream =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
477 make_fixed_buffer_input_stream ((unsigned char *) event->string, event->length);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
479 /* #### Use get_coding_system_for_text_file
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
480 (Vcomposed_input_coding_system, 0) */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 instream =
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
482 make_coding_input_stream (XLSTREAM (fb_instream),
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
483 Qundecided, CODING_DECODE, 0);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 istr = XLSTREAM (instream);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 GCPRO2 (instream, fb_instream);
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
488 while ((ch = Lstream_get_ichar (istr)) != EOF)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
489 {
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
491 Lisp_Event *ev = XEVENT (emacs_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
492 ev->channel = DEVICE_CONSOLE (d);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 ev->timestamp = event->time;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
494 XSET_EVENT_TYPE (emacs_event, key_press_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
495 XSET_EVENT_KEY_MODIFIERS (emacs_event, 0);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
496 XSET_EVENT_KEY_KEYSYM (emacs_event, make_char (ch));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
497 enqueue_dispatch_event (emacs_event);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
498 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 Lstream_close (istr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 Lstream_delete (istr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 Lstream_delete (XLSTREAM (fb_instream));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 if (IS_MODIFIER_KEY (event->keyval) || (event->keyval == GDK_Mode_switch))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
504 return (Qnil);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 return (gtk_keysym_to_emacs_keysym (event->keyval, simple_p));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
506 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 else
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
508 {
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509 if (IS_MODIFIER_KEY (event->keyval) || (event->keyval == GDK_Mode_switch))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
510 return (Qnil);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 return (gtk_keysym_to_emacs_keysym (event->keyval, simple_p));
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
512 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 /* timeout events */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 static int timeout_id_tick;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
522 struct GTK_timeout
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
523 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
524 int id;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
525 guint timeout_id;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
526 struct GTK_timeout *next;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 } *pending_timeouts, *completed_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 struct GTK_timeout_blocktype
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 Blocktype_declare (struct GTK_timeout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 } *the_GTK_timeout_blocktype;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 /* called by the gtk main loop */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 static gint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 gtk_timeout_callback (gpointer closure)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 struct GTK_timeout *timeout = (struct GTK_timeout *) closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 struct GTK_timeout *t2 = pending_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 /* Remove this one from the list of pending timeouts */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 if (t2 == timeout)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 pending_timeouts = pending_timeouts->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 while (t2->next && t2->next != timeout) t2 = t2->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547 assert (t2->next);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 t2->next = t2->next->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 /* Add this one to the list of completed timeouts */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 timeout->next = completed_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 completed_timeouts = timeout;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
553 return FALSE;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 emacs_gtk_add_timeout (EMACS_TIME thyme)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 struct GTK_timeout *timeout = Blocktype_alloc (the_GTK_timeout_blocktype);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 EMACS_TIME current_time;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 int milliseconds;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 timeout->id = timeout_id_tick++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 timeout->next = pending_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 pending_timeouts = timeout;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 EMACS_GET_TIME (current_time);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 EMACS_SUB_TIME (thyme, thyme, current_time);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 milliseconds = EMACS_SECS (thyme) * 1000 +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569 EMACS_USECS (thyme) / 1000;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 if (milliseconds < 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 milliseconds = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 timeout->timeout_id = gtk_timeout_add (milliseconds,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 gtk_timeout_callback,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 (gpointer) timeout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 return timeout->id;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 emacs_gtk_remove_timeout (int id)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 struct GTK_timeout *timeout, *t2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 timeout = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 /* Find the timeout on the list of pending ones, if it's still there. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 if (pending_timeouts)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 if (id == pending_timeouts->id)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 timeout = pending_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 pending_timeouts = pending_timeouts->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 t2 = pending_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 while (t2->next && t2->next->id != id) t2 = t2->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 if ( t2->next) /*found it */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 timeout = t2->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 t2->next = t2->next->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 /* if it was pending, we have removed it from the list */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 if (timeout)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 gtk_timeout_remove (timeout->timeout_id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 /* It could be that the call back was already called but we didn't convert
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 into an Emacs event yet */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610 if (!timeout && completed_timeouts)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 /* Code duplication! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613 if (id == completed_timeouts->id)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 timeout = completed_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
616 completed_timeouts = completed_timeouts->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 t2 = completed_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621 while (t2->next && t2->next->id != id) t2 = t2->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622 if ( t2->next) /*found it */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 timeout = t2->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625 t2->next = t2->next->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
626 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
627 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
628 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 /* If we found the thing on the lists of timeouts,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 and removed it, deallocate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 if (timeout)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 Blocktype_free (the_GTK_timeout_blocktype, timeout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638 gtk_timeout_to_emacs_event (struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 struct GTK_timeout *timeout = completed_timeouts;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 assert (timeout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 completed_timeouts = completed_timeouts->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 /* timeout events have nil as channel */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
644 set_event_type (emacs_event, timeout_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
645 SET_EVENT_TIMESTAMP_ZERO (emacs_event); /* #### wrong!! */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
646 SET_EVENT_TIMEOUT_INTERVAL_ID (emacs_event, timeout->id);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
647 SET_EVENT_TIMEOUT_FUNCTION (emacs_event, Qnil);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
648 SET_EVENT_TIMEOUT_OBJECT (emacs_event, Qnil);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 Blocktype_free (the_GTK_timeout_blocktype, timeout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
652
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654 /* process and tty events */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 struct what_is_ready_closure
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 int fd;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660 Lisp_Object what;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 gint id;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 static Lisp_Object *filedesc_with_input;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 static struct what_is_ready_closure **filedesc_to_what_closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
667 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 init_what_input_once (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
672 filedesc_with_input = xnew_array (Lisp_Object, MAXDESC);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 filedesc_to_what_closure =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674 xnew_array (struct what_is_ready_closure *, MAXDESC);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 for (i = 0; i < MAXDESC; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 filedesc_to_what_closure[i] = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679 filedesc_with_input[i] = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
680 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682 process_events_occurred = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
683 tty_events_occurred = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
684 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
686 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
687 mark_what_as_being_ready (struct what_is_ready_closure *closure)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
688 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
689 if (NILP (filedesc_with_input[closure->fd]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 SELECT_TYPE temp_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692 FD_ZERO (&temp_mask);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693 FD_SET (closure->fd, &temp_mask);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 /* Check to make sure there's *really* input available.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695 Sometimes things seem to get confused and this gets called
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696 for the tty fd when there's really only input available
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697 on some process's fd. (It will subsequently get called
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 for that process's fd, so returning without setting any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 flags will take care of it.) To see the problem, uncomment
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
700 the stderr_out below, turn NORMAL_QUIT_CHECK_TIMEOUT_MSECS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701 down to 25, do sh -c 'xemacs -nw -q -f shell 2>/tmp/log'
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702 and press return repeatedly. (Seen under AIX & Linux.)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703 -dkindred@cs.cmu.edu */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
704 if (!poll_fds_for_input (temp_mask))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
705 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707 stderr_out ("mark_what_as_being_ready: no input available (fd=%d)\n",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708 closure->fd);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
709 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712 filedesc_with_input[closure->fd] = closure->what;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713 if (PROCESSP (closure->what))
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
714 /* Don't increment this if the current process is already marked
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
715 * as having input. */
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
716 process_events_occurred++;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
717 else
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
718 tty_events_occurred++;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
720 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
721
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
722 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
723 gtk_what_callback (gpointer closure, gint UNUSED (source),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
724 GdkInputCondition UNUSED (why))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726 /* If closure is 0, then we got a fake event from a signal handler.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 The only purpose of this is to make XtAppProcessEvent() stop
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728 blocking. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 if (closure)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 mark_what_as_being_ready ((struct what_is_ready_closure *) closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 fake_event_occurred++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 drain_signal_event_pipe ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 select_filedesc (int fd, Lisp_Object what)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
741 struct what_is_ready_closure *closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743 /* If somebody is trying to select something that's already selected
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744 for, then something went wrong. The generic routines ought to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 detect this and error before here. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746 assert (!filedesc_to_what_closure[fd]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748 closure = xnew (struct what_is_ready_closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 closure->fd = fd;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750 closure->what = what;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751 closure->id = gdk_input_add (fd, GDK_INPUT_READ,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
752 (GdkInputFunction) gtk_what_callback, closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
753 filedesc_to_what_closure[fd] = closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
754 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757 unselect_filedesc (int fd)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 struct what_is_ready_closure *closure = filedesc_to_what_closure[fd];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
761 assert (closure);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
762 if (!NILP (filedesc_with_input[fd]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
763 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
764 /* We are unselecting this process before we have drained the rest of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
765 the input from it, probably from status_notify() in the command loop.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 This can happen like so:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
768 - We are waiting in XtAppNextEvent()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
769 - Process generates output
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
770 - Process is marked as being ready
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
771 - Process dies, SIGCHLD gets generated before we return (!?)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
772 It could happen I guess.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 - sigchld_handler() marks process as dead
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 - Somehow we end up getting a new KeyPress event on the queue
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775 at the same time (I'm really so sure how that happens but I'm
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776 not sure it can't either so let's assume it can...).
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 - Key events have priority so we return that instead of the proc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778 - Before dispatching the lisp key event we call status_notify()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
779 - Which deselects the process that SIGCHLD marked as dead.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781 Thus we never remove it from _with_input and turn it into a lisp
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 event, so we need to do it here. But this does not mean that we're
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783 throwing away the last block of output - status_notify() has already
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 taken care of running the proc filter or whatever.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 filedesc_with_input[fd] = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787 if (PROCESSP (closure->what))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789 assert (process_events_occurred > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790 process_events_occurred--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 assert (tty_events_occurred > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795 tty_events_occurred--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 gdk_input_remove (closure->id);
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1416
diff changeset
799 xfree (closure, struct what_is_ready_closure *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 filedesc_to_what_closure[fd] = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803 static void
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
804 emacs_gtk_select_process (Lisp_Process *process, int doin, int doerr)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
806 Lisp_Object proc;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
807 int infd, errfd;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
808
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
809 event_stream_unixoid_select_process (process, doin, doerr, &infd, &errfd);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
810
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
811 proc = wrap_process (process);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
812 if (doin)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
813 select_filedesc (infd, proc);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
814 if (doerr)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
815 select_filedesc (errfd, proc);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
816 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
818 static void
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
819 emacs_gtk_unselect_process (Lisp_Process *process, int doin, int doerr)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
820 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
821 int infd, errfd;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
822
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
823 event_stream_unixoid_unselect_process (process, doin, doerr, &infd, &errfd);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
824
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
825 if (doin)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
826 unselect_filedesc (infd);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
827 if (doerr)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
828 unselect_filedesc (errfd);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 static void
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
832 emacs_gtk_create_io_streams (void *inhandle, void *outhandle,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
833 void *errhandle, Lisp_Object *instream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
834 Lisp_Object *outstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
835 Lisp_Object *errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
836 USID *in_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
837 USID *err_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
838 int flags)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
840 event_stream_unixoid_create_io_streams
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
841 (inhandle, outhandle, errhandle, instream, outstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
842 errstream, in_usid, err_usid, flags);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
843 if (*in_usid != USID_ERROR)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
844 *in_usid = USID_DONTHASH;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
845 if (*err_usid != USID_ERROR)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
846 *err_usid = USID_DONTHASH;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
849 static void
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
850 emacs_gtk_delete_io_streams (Lisp_Object instream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
851 Lisp_Object outstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
852 Lisp_Object errstream,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
853 USID *in_usid,
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
854 USID *err_usid)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 {
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
856 event_stream_unixoid_delete_io_streams
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
857 (instream, outstream, errstream, in_usid, err_usid);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
858 *in_usid = USID_DONTHASH;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 826
diff changeset
859 *err_usid = USID_DONTHASH;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862 /* This is called from GC when a process object is about to be freed.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863 If we've still got pointers to it in this file, we're gonna lose hard.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
866 debug_process_finalization (struct Lisp_Process *UNUSED (p))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
867 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
868 #if 0 /* #### */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870 Lisp_Object instr, outstr;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872 get_process_streams (p, &instr, &outstr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 /* if it still has fds, then it hasn't been killed yet. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 assert (NILP(instr));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875 assert (NILP(outstr));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 /* Better not still be in the "with input" table; we know it's got no fds. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 for (i = 0; i < MAXDESC; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 Lisp_Object process = filedesc_fds_with_input [i];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880 assert (!PROCESSP (process) || XPROCESS (process) != p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
884
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
885 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 gtk_process_to_emacs_event (struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
888 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890 assert (process_events_occurred > 0);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
891
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
892 for (i = 0; i < MAXDESC; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
894 Lisp_Object process = filedesc_with_input[i];
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 if (PROCESSP (process))
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
896 {
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
897 filedesc_with_input[i] = Qnil;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
898 process_events_occurred--;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
899 /* process events have nil as channel */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
900 set_event_type (emacs_event, process_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
901 SET_EVENT_TIMESTAMP_ZERO (emacs_event); /* #### */
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
902 SET_EVENT_PROCESS_PROCESS (emacs_event, process);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
903 return;
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
904 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 }
2500
3d8143fc88e1 [xemacs-hg @ 2005-01-24 23:33:30 by ben]
ben
parents: 2489
diff changeset
906 ABORT ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
909 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 emacs_gtk_select_console (struct console *con)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 Lisp_Object console;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913 int infd;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915 if (CONSOLE_GTK_P (con))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916 return; /* Gtk consoles are automatically selected for when we initialize them */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 infd = event_stream_unixoid_select_console (con);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
918 console = wrap_console (con);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
919 select_filedesc (infd, console);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 emacs_gtk_unselect_console (struct console *con)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925 Lisp_Object console;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 int infd;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 if (CONSOLE_GTK_P (con))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929 return; /* X consoles are automatically selected for when we initialize them */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930 infd = event_stream_unixoid_unselect_console (con);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
931 console = wrap_console (con);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932 unselect_filedesc (infd);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935 /* read an event from a tty, if one is available. Returns non-zero
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936 if an event was available. Note that when this function is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
937 called, there should always be a tty marked as ready for input.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 However, the input condition might actually be EOF, so there
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939 may not really be any input available. (In this case,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940 read_event_from_tty_or_stream_desc() will arrange for the TTY device
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941 to be deleted.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 gtk_tty_to_emacs_event (struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 assert (tty_events_occurred > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 for (i = 0; i < MAXDESC; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 Lisp_Object console = filedesc_with_input[i];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952 if (CONSOLEP (console))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 assert (tty_events_occurred > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 tty_events_occurred--;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956 filedesc_with_input[i] = Qnil;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
957 if (read_event_from_tty_or_stream_desc (emacs_event,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
958 XCONSOLE (console)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968 /* Drag 'n Drop handling */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 #ifdef HAVE_DRAGNDROP
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 #define TARGET_URI_LIST 0x00
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 #define TARGET_TEXT_PLAIN 0x01
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973 #define TARGET_FILE_NAME 0x02
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974 #define TARGET_NETSCAPE 0x03
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 static GdkAtom preferred_targets[10];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 dragndrop_data_received (GtkWidget *widget,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 GdkDragContext *context,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 gint x,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 gint y,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 GtkSelectionData *data,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
984 guint UNUSED (info),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985 guint time)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 Lisp_Object event = Fmake_event (Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988 struct device *d = gtk_any_window_to_device (widget->window);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 struct frame *f = gtk_any_widget_or_parent_to_frame (d, widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 struct Lisp_Event *ev = XEVENT (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 Lisp_Object l_type = Qnil, l_data = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 Lisp_Object l_dndlist = Qnil, l_item = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995 GCPRO4 (l_type, l_data, l_dndlist, l_item);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
997 set_event_type (ev, misc_user_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
998 SET_EVENT_CHANNEL (ev, wrap_frame (f));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
999 SET_EVENT_TIMESTAMP (ev, time);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1000 SET_EVENT_MISC_USER_X (ev, x);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1001 SET_EVENT_MISC_USER_Y (ev, y);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003 if (data->type == preferred_targets[TARGET_URI_LIST])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 /* newline-separated list of URLs */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 int start, end;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007 const char *string_data = (char *) data->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009 l_type = Qdragdrop_URL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 for (start = 0, end = 0; string_data && string_data[end]; end++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013 if ((string_data[end] == '\r') && (string_data[end+1] == '\n'))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 l_item = make_string (&string_data[start], end - start);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 l_dndlist = Fcons (l_item, l_dndlist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017 ++end;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 start = ++end;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 else if (data->type == preferred_targets[TARGET_TEXT_PLAIN])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024 /* Arbitrary string */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025 l_type = Qdragdrop_MIME;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 l_dndlist = list1 (list3 (list1 (build_string ("text/plain")),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027 build_string ("8_bit"),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028 make_ext_string (data->data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 strlen ((char *)data->data),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 Qctext)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 else if (data->type == preferred_targets[TARGET_FILE_NAME])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 /* Random filename */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 char *hurl = dnd_url_hexify_string (data->data, "file:");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
1037 l_dndlist = list1 (make_string ((Ibyte *)hurl, strlen (hurl)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 l_type = Qdragdrop_URL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1416
diff changeset
1040 xfree (hurl, char *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 else if (data->type == preferred_targets[TARGET_NETSCAPE])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044 /* Single URL */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045 l_dndlist = list1 (make_string ((Extbyte *)data->data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046 strlen ((char *)data->data)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047 l_type = Qdragdrop_URL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 /* Unknown type - what to do?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052 We just pass it up to lisp - we already have a mime type.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 l_type = Qdragdrop_MIME;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055 l_dndlist = list1 (list3 (list1 (build_string (gdk_atom_name (data->type))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 build_string ("8bit"),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 make_ext_string ((Extbyte *) data->data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 data->length, Qbinary)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1061
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1062 SET_EVENT_MISC_USER_FUNCTION (ev, Qdragdrop_drop_dispatch);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1063 SET_EVENT_MISC_USER_OBJECT (ev, Fcons (l_type, l_dndlist));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067 gtk_drag_finish (context, TRUE, FALSE, time);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1068 enqueue_dispatch_event (event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071 gboolean
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
1072 dragndrop_dropped (GtkWidget *UNUSED (widget),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073 GdkDragContext *drag_context,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
1074 gint UNUSED (x),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
1075 gint UNUSED (y),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076 guint time,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 gpointer user_data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 /* Netscape drops things like:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 STRING
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 _SGI_ICON
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1082 _SGI_ICON_TYPE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1083 SGI_FILE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 FILE_NAME
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 _NETSCAPE_URL
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1087 gmc drops things like
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1088 application/x-mc-desktop-icon
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089 text/uri-list
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 text/plain
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 _NETSCAPE_URL
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 We prefer:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 text/uri-list
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 text/plain
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096 FILE_NAME
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 _NETSCAPE_URL
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098 first one
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 GdkAtom found = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101 GList *list = drag_context->targets;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1105 if (!preferred_targets[0])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1106 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 preferred_targets[TARGET_URI_LIST] = gdk_atom_intern ("text/uri-list", FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108 preferred_targets[TARGET_TEXT_PLAIN] = gdk_atom_intern ("text/plain", FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109 preferred_targets[TARGET_FILE_NAME] = gdk_atom_intern ("FILE_NAME", FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110 preferred_targets[TARGET_NETSCAPE] = gdk_atom_intern ("_NETSCAPE_URL", FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1112
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1113 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114 stderr_out ("Drop info available in the following formats: \n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1115 while (list)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 stderr_out ("\t%s\n", gdk_atom_name ((GdkAtom)list->data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118 list = list->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 list = drag_context->targets;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1122
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123 while (list && !found)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1125 for (i = 0; preferred_targets[i] && !found; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1126 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127 if ((GdkAtom) list->data == preferred_targets[i])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129 found = (GdkAtom) list->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1132 list = list->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1134
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1135 if (!found)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1136 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1137 found = (GdkAtom) drag_context->targets->data;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1138 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1140 gtk_drag_get_data (GTK_WIDGET (user_data), drag_context, found, time);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1141 return (TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 #endif /* HAVE_DRAGNDROP */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1144
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 /* get the next event from gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 /* This business exists because menu events "happen" when
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 menubar_selection_callback() is called from somewhere deep
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1152 within XtAppProcessEvent in emacs_Xt_next_event(). The
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1153 callback needs to terminate the modal loop in that function
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1154 or else it will continue waiting until another event is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 received.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1156
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1157 Same business applies to scrollbar events. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1158
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1159 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1160 signal_special_gtk_user_event (Lisp_Object channel, Lisp_Object function,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1161 Lisp_Object object)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1162 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1163 Lisp_Object event = Fmake_event (Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1164
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1165 XSET_EVENT_TYPE (event, misc_user_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1166 XSET_EVENT_CHANNEL (event, channel);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1167 XSET_EVENT_MISC_USER_FUNCTION (event, function);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1168 XSET_EVENT_MISC_USER_OBJECT (event, object);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1169 enqueue_dispatch_event (event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1170 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1171
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1172 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1173 emacs_gtk_next_event (struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1174 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1175 we_didnt_get_an_event:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1176
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1177 while (NILP (dispatch_event_queue) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1178 !completed_timeouts &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1179 !fake_event_occurred &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1180 !process_events_occurred &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1181 !tty_events_occurred)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1182 {
1292
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1183 #ifdef WIN32_ANY
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1184 mswindows_is_blocking = 1;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1185 #endif
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1186 gtk_main_iteration ();
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1187 #ifdef WIN32_ANY
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1188 mswindows_is_blocking = 0;
f3437b56874d [xemacs-hg @ 2003-02-13 09:57:04 by ben]
ben
parents: 1268
diff changeset
1189 #endif
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1190 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1191
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1192 if (!NILP (dispatch_event_queue))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1193 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1194 Lisp_Object event, event2;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1195 event2 = wrap_event (emacs_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1196 event = dequeue_dispatch_event ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1197 Fcopy_event (event, event2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1198 Fdeallocate_event (event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1199 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1200 else if (tty_events_occurred)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1201 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1202 if (!gtk_tty_to_emacs_event (emacs_event))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203 goto we_didnt_get_an_event;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1204 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1205 else if (completed_timeouts)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1206 gtk_timeout_to_emacs_event (emacs_event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1207 else if (fake_event_occurred)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 /* A dummy event, so that a cycle of the command loop will occur. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210 fake_event_occurred = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1211 /* eval events have nil as channel */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1212 set_event_type (emacs_event, eval_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1213 SET_EVENT_EVAL_FUNCTION (emacs_event, Qidentity);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1214 SET_EVENT_EVAL_OBJECT (emacs_event, Qnil);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1215 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1216 else /* if (process_events_occurred) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217 gtk_process_to_emacs_event (emacs_event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1218 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1219
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1220 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1221 gtk_event_to_emacs_event (struct frame *frame, GdkEvent *gdk_event, struct Lisp_Event *emacs_event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1223 struct device *d = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1224 struct gtk_device *gd = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1225 gboolean accept_any_window = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1226
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1227 /* #### Under what circumstances can this happen???? Hunt out the code that
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1228 sets frame to 0 and fix it instead. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1229 if (!frame)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1230 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1231 frame = XFRAME (Fselected_frame (get_default_device (Qgtk)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1232 accept_any_window = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1234
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1235 d = XDEVICE (FRAME_DEVICE (frame));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1236 gd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1237
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1238 set_last_server_timestamp (d, gdk_event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1239
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1240 switch (gdk_event->type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1241 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1242 /* XEmacs handles double and triple clicking on its own, and if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1243 we capture these events, it royally confuses the code in
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1244 ../lisp/mouse.el */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245 case GDK_2BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 case GDK_3BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249 case GDK_BUTTON_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250 case GDK_BUTTON_RELEASE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251 /* We need to ignore button events outside our main window or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252 things get ugly. The standard scrollbars in Gtk try to be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 nice and pass the button press events up to the parent
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 widget. This causes us no end of grief though. Effects
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1255 range from setting point to the wrong place to selecting
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1256 new windows. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1257 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1258 GdkWindow *w = gdk_window_at_pointer (NULL, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1260 /* If you press mouse button and drag it around, and release
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1261 it outside the window, you will get a NULL GdkWindow at
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262 pointer. We need to forward these events on to XEmacs so
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1263 that the mouse selection voodoo works.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1264 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265 if (w && (w != gdk_window_lookup (GDK_ROOT_WINDOW ())))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1267 GdkEvent ev;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268 GtkWidget *wid = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1270 ev.any.window = w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1271 wid = gtk_get_event_widget (&ev);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273 if (!GTK_IS_XEMACS (wid) && !accept_any_window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278 if (!accept_any_window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1279 gtk_widget_grab_focus (FRAME_GTK_TEXT_WIDGET (frame));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1281 /* Fall through */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1282 case GDK_KEY_PRESS:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1283 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 unsigned int modifiers = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 int shift_p, lock_p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286 gboolean key_event_p = (gdk_event->type == GDK_KEY_PRESS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287 unsigned int *state =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1288 key_event_p ? &gdk_event->key.state : &gdk_event->button.state;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1289
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290 /* If this is a synthetic KeyPress or Button event, and the user
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291 has expressed a disinterest in this security hole, then drop
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1292 it on the floor. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1293 /* #### BILL!!! Should this be a generic check for ANY synthetic
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1294 event? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1295 if ((gdk_event->any.send_event) && !gtk_allow_sendevents)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1296 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1297
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1298 DEVICE_GTK_MOUSE_TIMESTAMP (d) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1299 DEVICE_GTK_GLOBAL_MOUSE_TIMESTAMP (d) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1300 key_event_p ? gdk_event->key.time : gdk_event->button.time;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1301
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1302 if (*state & GDK_CONTROL_MASK) modifiers |= XEMACS_MOD_CONTROL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1303 if (*state & gd->MetaMask) modifiers |= XEMACS_MOD_META;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1304 if (*state & gd->SuperMask) modifiers |= XEMACS_MOD_SUPER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1305 if (*state & gd->HyperMask) modifiers |= XEMACS_MOD_HYPER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1306 if (*state & gd->AltMask) modifiers |= XEMACS_MOD_ALT;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1307
589
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1308 {
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1309 int numero_de_botao = -1;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1310
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1311 if (!key_event_p)
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1312 numero_de_botao = gdk_event->button.button;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1313
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1314 /* the button gets noted either in the button or the modifiers
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1315 field, but not both. */
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1316 if (numero_de_botao != 1 && (*state & GDK_BUTTON1_MASK))
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1317 modifiers |= XEMACS_MOD_BUTTON1;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1318 if (numero_de_botao != 2 && (*state & GDK_BUTTON2_MASK))
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1319 modifiers |= XEMACS_MOD_BUTTON2;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1320 if (numero_de_botao != 3 && (*state & GDK_BUTTON3_MASK))
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1321 modifiers |= XEMACS_MOD_BUTTON3;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1322 if (numero_de_botao != 4 && (*state & GDK_BUTTON4_MASK))
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1323 modifiers |= XEMACS_MOD_BUTTON4;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1324 if (numero_de_botao != 5 && (*state & GDK_BUTTON5_MASK))
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1325 modifiers |= XEMACS_MOD_BUTTON5;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1326 }
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1327
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1328 /* Ignore the Caps_Lock key if:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329 - any other modifiers are down, so that Caps_Lock doesn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330 turn C-x into C-X, which would suck.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1331 - the event was a mouse event. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1332 if (modifiers || ! key_event_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1333 *state &= (~GDK_LOCK_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1334
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1335 shift_p = *state & GDK_SHIFT_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1336 lock_p = *state & GDK_LOCK_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1337
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1338 if (shift_p || lock_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1339 modifiers |= XEMACS_MOD_SHIFT;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1340
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1341 if (key_event_p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1342 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1343 GdkEventKey *key_event = &gdk_event->key;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1344 Lisp_Object keysym;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1345
2081
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1346 #ifdef HAVE_MENUBARS
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1347 /* If the user wants see if the event is a menu bar accelerator.
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1348 The process of checking absorbs the event and starts menu
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1349 processing so send a null event into XEmacs to make sure it
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1350 does nothing.
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1351 */
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1352 if (!NILP (Vmenu_accelerator_enabled)
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1353 && gtk_accel_groups_activate(GTK_OBJECT (FRAME_GTK_SHELL_WIDGET(frame)),
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1354 key_event->keyval,
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1355 (GdkModifierType) *state))
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1356 {
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1357 zero_event(emacs_event);
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1358 return 1;
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1359 }
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1360 #endif
e8db6a10ad42 [xemacs-hg @ 2004-05-15 07:31:43 by malcolmp]
malcolmp
parents: 2054
diff changeset
1361
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1362 /* This used to compute the frame from the given X window and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1363 store it here, but we really don't care about the frame. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1364 emacs_event->channel = DEVICE_CONSOLE (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1365
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1366 /* Keysym mucking has already been done inside the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1367 GdkEventKey parsing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1368 keysym = gtk_to_emacs_keysym (d, key_event, 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1369
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1370 /* If the emacs keysym is nil, then that means that the X
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1371 keysym was either a Modifier or NoSymbol, which
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1372 probably means that we're in the midst of reading a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1373 Multi_key sequence, or a "dead" key prefix, or XIM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1374 input. Ignore it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1375 if (NILP (keysym))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1376 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1377
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1378 /* More Caps_Lock garbage: Caps_Lock should *only* add the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1379 shift modifier to two-case keys (that is, A-Z and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1380 related characters). So at this point (after looking up
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1381 the keysym) if the keysym isn't a dual-case alphabetic,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1382 and if the caps lock key was down but the shift key
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1383 wasn't, then turn off the shift modifier. Gag barf */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1384 /* #### type lossage: assuming equivalence of emacs and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1385 X keysyms */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1386 /* !!#### maybe fix for Mule */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1387 if (lock_p && !shift_p &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1388 ! (CHAR_OR_CHAR_INTP (keysym)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1389 && keysym_obeys_caps_lock_p
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1390 ((guint) XCHAR_OR_CHAR_INT (keysym), d)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1391 modifiers &= (~XEMACS_MOD_SHIFT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1392
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1393 /* If this key contains two distinct keysyms, that is,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1394 "shift" generates a different keysym than the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1395 non-shifted key, then don't apply the shift modifier
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1396 bit: it's implicit. Otherwise, if there would be no
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1397 other way to tell the difference between the shifted
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1398 and unshifted version of this key, apply the shift bit.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1399 Non-graphics, like Backspace and F1 get the shift bit
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1400 in the modifiers slot. Neither the characters "a",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1401 "A", "2", nor "@" normally have the shift bit set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1402 However, "F1" normally does. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1403 if (modifiers & XEMACS_MOD_SHIFT)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1404 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1405 if (CHAR_OR_CHAR_INTP (keysym))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1406 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1407 modifiers &= ~XEMACS_MOD_SHIFT;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1408 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1409 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1410
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1411 set_event_type (emacs_event, key_press_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1412 SET_EVENT_TIMESTAMP (emacs_event, key_event->time);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1413 SET_EVENT_KEY_MODIFIERS (emacs_event, modifiers);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1414 SET_EVENT_KEY_KEYSYM (emacs_event, keysym);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1415 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1416 else /* Mouse press/release event */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1417 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1418 GdkEventButton *button_event = &gdk_event->button;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1419
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1420 set_event_type (emacs_event,
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1421 button_event->type == GDK_BUTTON_RELEASE ?
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1422 button_release_event : button_press_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1423 SET_EVENT_CHANNEL (emacs_event, wrap_frame (frame));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1424
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1425 SET_EVENT_BUTTON_MODIFIERS (emacs_event, modifiers);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1426 SET_EVENT_TIMESTAMP (emacs_event, button_event->time);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1427 SET_EVENT_BUTTON_BUTTON (emacs_event, button_event->button);
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1428 SET_EVENT_BUTTON_X (emacs_event, (int) button_event->x);
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1429 SET_EVENT_BUTTON_Y (emacs_event, (int) button_event->y);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1430 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1431 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1432 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1433 case GDK_KEY_RELEASE:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1434 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1435 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1436 case GDK_MOTION_NOTIFY:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1437 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1438 GdkEventMotion *ev = &gdk_event->motion;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1439 unsigned int modifiers = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1440 gint x,y;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1441 GdkModifierType mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1442
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1443 /* We use MOTION_HINT_MASK, so we will get only one motion
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1444 event until the next time we call gdk_window_get_pointer or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1445 the user clicks the mouse. So call gdk_window_get_pointer
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1446 now (meaning that the event will be in sync with the server
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1447 just before Fnext_event() returns). If the mouse is still
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1448 in motion, then the server will immediately generate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1449 exactly one more motion event, which will be on the queue
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1450 waiting for us next time around. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1451 gdk_window_get_pointer (ev->window, &x, &y, &mask);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1452
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1453 DEVICE_GTK_MOUSE_TIMESTAMP (d) = ev->time;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1454
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1455 SET_EVENT_CHANNEL (emacs_event, wrap_frame (frame));
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1456 set_event_type (emacs_event, pointer_motion_event);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1457 SET_EVENT_TIMESTAMP (emacs_event, ev->time);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1458 SET_EVENT_MOTION_X (emacs_event, x);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1459 SET_EVENT_MOTION_Y (emacs_event, y);
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1460
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1461 if (mask & GDK_SHIFT_MASK) modifiers |= XEMACS_MOD_SHIFT;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1462 if (mask & GDK_CONTROL_MASK) modifiers |= XEMACS_MOD_CONTROL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1463 if (mask & gd->MetaMask) modifiers |= XEMACS_MOD_META;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1464 if (mask & gd->SuperMask) modifiers |= XEMACS_MOD_SUPER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1465 if (mask & gd->HyperMask) modifiers |= XEMACS_MOD_HYPER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1466 if (mask & gd->AltMask) modifiers |= XEMACS_MOD_ALT;
589
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1467 if (mask & GDK_BUTTON1_MASK) modifiers |= XEMACS_MOD_BUTTON1;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1468 if (mask & GDK_BUTTON2_MASK) modifiers |= XEMACS_MOD_BUTTON2;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1469 if (mask & GDK_BUTTON3_MASK) modifiers |= XEMACS_MOD_BUTTON3;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1470 if (mask & GDK_BUTTON4_MASK) modifiers |= XEMACS_MOD_BUTTON4;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1471 if (mask & GDK_BUTTON5_MASK) modifiers |= XEMACS_MOD_BUTTON5;
37fe04af1590 [xemacs-hg @ 2001-05-31 02:00:29 by wmperry]
wmperry
parents: 563
diff changeset
1472
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1473 /* Currently ignores Shift_Lock but probably shouldn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1474 (but it definitely should ignore Caps_Lock). */
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1475 SET_EVENT_MOTION_MODIFIERS (emacs_event, modifiers);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1476 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1477 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1478
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1479 default: /* it's a magic event */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1480 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1481 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1482 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1483 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1484 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1485
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1486 static const char *event_name (GdkEvent *);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1487
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1488 static gboolean
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1489 generic_event_handler (GtkWidget *widget, GdkEvent *event)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1490 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1491 Lisp_Object emacs_event = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1492 if (!GTK_IS_XEMACS (widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1493 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1494 stderr_out ("Got a %s event for a non-XEmacs widget\n",event_name (event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1495 return (FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1496 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1497
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1498 emacs_event = Fmake_event (Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1499
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1500 if (gtk_event_to_emacs_event (GTK_XEMACS_FRAME (widget), event, XEVENT (emacs_event)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1501 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1502 enqueue_dispatch_event (emacs_event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1503 return (TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1504 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1505 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1506 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1507 Fdeallocate_event (emacs_event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1508 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1509 return (FALSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1510 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1511
1416
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1512 gint
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1513 emacs_gtk_key_event_handler (GtkWidget *widget, GdkEventKey *event)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1514 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1515 return (generic_event_handler (widget, (GdkEvent *) event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1516 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1517
1416
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1518 gint
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1519 emacs_gtk_button_event_handler (GtkWidget *widget, GdkEventButton *event)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1520 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1521 return (generic_event_handler (widget, (GdkEvent *) event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1522 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1523
1416
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1524 gint
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1525 emacs_gtk_motion_event_handler (GtkWidget *widget, GdkEventMotion *event)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1526 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1527 return (generic_event_handler (widget, (GdkEvent *) event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1528 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1529
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1530 gboolean
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
1531 emacs_shell_event_handler (GtkWidget *UNUSED (wid),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1532 GdkEvent *event,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1533 gpointer closure)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1534 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1535 struct frame *frame = (struct frame *) closure;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1536 Lisp_Object lisp_event = Fmake_event (Qnil, Qnil);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1537 struct Lisp_Event *emacs_event = XEVENT (lisp_event);
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1538 GdkEvent *gdk_event_copy = &EVENT_MAGIC_GDK_EVENT (emacs_event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1539 struct device *d = XDEVICE (FRAME_DEVICE (frame));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1540 gboolean ignore_p = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1541
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1542 set_last_server_timestamp (d, event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1543
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1544 #define FROB(event_member) gdk_event_copy->event_member = event->event_member
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1545
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1546 switch (event->type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1547 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1548 case GDK_SELECTION_REQUEST:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1549 case GDK_SELECTION_CLEAR:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1550 case GDK_SELECTION_NOTIFY: FROB(selection); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1551 case GDK_PROPERTY_NOTIFY: FROB(property); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1552 case GDK_CLIENT_EVENT: FROB(client); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1553 case GDK_MAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1554 case GDK_UNMAP: FROB(any); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1555 case GDK_CONFIGURE: FROB(configure); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1556 case GDK_ENTER_NOTIFY:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1557 case GDK_LEAVE_NOTIFY: FROB(crossing); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1558 case GDK_FOCUS_CHANGE: FROB(focus_change); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1559 case GDK_VISIBILITY_NOTIFY: FROB(visibility); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1560 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1561 ignore_p = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1562 /* Hrmm... do we really want to swallow all the other events as magic? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1563 *gdk_event_copy = *event;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1564 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1565 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1566 #undef FROB
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1567
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1568 emacs_event->event_type = magic_event;
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1569 emacs_event->channel = wrap_frame (frame);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1570
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1571 if (ignore_p)
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1572 {
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1573 stderr_out ("Ignoring event... (%s)\n", event_name (event));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1574 Fdeallocate_event (lisp_event);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1575 return (FALSE);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1576 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1577 else
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1578 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1579 enqueue_dispatch_event (lisp_event);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1580 return (TRUE);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 790
diff changeset
1581 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1582 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1583
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1584
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1585 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1586 /* input pending / C-g checking */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1587 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1588
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1589 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1590
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1591 static void
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1592 emacs_gtk_drain_queue (void)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1593
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1594 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1595 /* We can't just spin through here and wait for GTKs idea of the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1596 event queue to get empty, or the queue never gets drained. The
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1597 situation is as follows. A process event gets signalled, we put
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1598 it on the queue, then we go into Fnext_event(), which calls
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1599 emacs_gtk_drain_queue(). But gtk_events_pending() will always return
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1600 TRUE if there are file-descriptor (aka our process) events
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1601 pending. Using GDK_events_pending() only shows us windowing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1602 system events.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1603 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1604 if (GDK_DISPLAY ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1605 while (gdk_events_pending ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1606 gtk_main_iteration ();
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1607
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
1608 #ifdef HAVE_TTY
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1609 drain_tty_devices ();
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1610 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1611 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1612
790
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1613 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2081
diff changeset
1614 emacs_gtk_force_event_pending (struct frame* UNUSED (f))
790
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1615 {
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1616 #if 0
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1617 stderr_out ("Force event pending called on frame %p!\n", f);
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1618 #endif
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1619 }
755d0acc05ea [xemacs-hg @ 2002-03-21 15:47:19 by wmperry]
wmperry
parents: 789
diff changeset
1620
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1621
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1622 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1623 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1624 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1625
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1626 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1627 syms_of_event_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1628 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
1629 DEFSYMBOL (Qsans_modifiers);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1630 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1631
1416
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1632 void
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1633 reinit_vars_of_event_gtk (void)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1634 {
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1635 gtk_event_stream = xnew_and_zero (struct event_stream);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1636 gtk_event_stream->event_pending_p = emacs_gtk_event_pending_p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1637 gtk_event_stream->next_event_cb = emacs_gtk_next_event;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1638 gtk_event_stream->handle_magic_event_cb= emacs_gtk_handle_magic_event;
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
1639 gtk_event_stream->format_magic_event_cb= emacs_gtk_format_magic_event;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
1640 gtk_event_stream->compare_magic_event_cb= emacs_gtk_compare_magic_event;
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 778
diff changeset
1641 gtk_event_stream->hash_magic_event_cb = emacs_gtk_hash_magic_event;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1642 gtk_event_stream->add_timeout_cb = emacs_gtk_add_timeout;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1643 gtk_event_stream->remove_timeout_cb = emacs_gtk_remove_timeout;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1644 gtk_event_stream->select_console_cb = emacs_gtk_select_console;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1645 gtk_event_stream->unselect_console_cb = emacs_gtk_unselect_console;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1646 gtk_event_stream->select_process_cb = emacs_gtk_select_process;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1647 gtk_event_stream->unselect_process_cb = emacs_gtk_unselect_process;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1648 gtk_event_stream->drain_queue_cb = emacs_gtk_drain_queue;
876
890f3cafe600 [xemacs-hg @ 2002-06-23 09:25:11 by stephent]
stephent
parents: 872
diff changeset
1649 gtk_event_stream->create_io_streams_cb= emacs_gtk_create_io_streams;
890f3cafe600 [xemacs-hg @ 2002-06-23 09:25:11 by stephent]
stephent
parents: 872
diff changeset
1650 gtk_event_stream->delete_io_streams_cb= emacs_gtk_delete_io_streams;
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 876
diff changeset
1651 gtk_event_stream->force_event_pending_cb= emacs_gtk_force_event_pending;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1652
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1653 the_GTK_timeout_blocktype = Blocktype_new (struct GTK_timeout_blocktype);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1654
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1655 /* this function only makes safe calls */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1656 init_what_input_once ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1657 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1658
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1659 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1660 vars_of_event_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1661 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1662 DEFVAR_BOOL ("gtk-allow-sendevents", &gtk_allow_sendevents /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1663 *Non-nil means to allow synthetic events. Nil means they are ignored.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1664 Beware: allowing emacs to process SendEvents opens a big security hole.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1665 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1666 gtk_allow_sendevents = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1667
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1668 last_quit_check_signal_tick_count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1669 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1670
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1671 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1672 init_event_gtk_late (void) /* called when already initialized */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1673 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1674 timeout_id_tick = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1675 pending_timeouts = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1676 completed_timeouts = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1677
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1678 event_stream = gtk_event_stream;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1679
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1680 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1681 /* Shut GDK the hell up */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1682 gdk_error_trap_push ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1683 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1684
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1685 gdk_input_add (signal_event_pipe[0], GDK_INPUT_READ,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1686 (GdkInputFunction) gtk_what_callback, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1687 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1688
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1689 /* Bogus utility routines */
1416
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1690 static const char *
b0c1d9dc4b08 [xemacs-hg @ 2003-04-15 17:21:34 by stephent]
stephent
parents: 1415
diff changeset
1691 event_name (GdkEvent *ev)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1692 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1693 return (gtk_event_name (ev->any.type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1694 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1695
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1696 /* This is down at the bottom of the file so I can avoid polluting the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1697 generic code with this X specific CRAP! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1698
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1699 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1700 #include <X11/keysym.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1701 /* #### BILL!!! Fix this please! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1702
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1703
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1704 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1705 /* keymap handling */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1706 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1707
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1708 /* X bogusly doesn't define the interpretations of any bits besides
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1709 ModControl, ModShift, and ModLock; so the Interclient Communication
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1710 Conventions Manual says that we have to bend over backwards to figure
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1711 out what the other modifier bits mean. According to ICCCM:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1712
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1713 - Any keycode which is assigned ModControl is a "control" key.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1714
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1715 - Any modifier bit which is assigned to a keycode which generates Meta_L
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1716 or Meta_R is the modifier bit meaning "meta". Likewise for Super, Hyper,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1717 etc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1718
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1719 - Any keypress event which contains ModControl in its state should be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1720 interpreted as a "control" character.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1721
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1722 - Any keypress event which contains a modifier bit in its state which is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1723 generated by a keycode whose corresponding keysym is Meta_L or Meta_R
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1724 should be interpreted as a "meta" character. Likewise for Super, Hyper,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1725 etc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1726
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1727 - It is illegal for a keysym to be associated with more than one modifier
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1728 bit.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1729
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1730 This means that the only thing that emacs can reasonably interpret as a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1731 "meta" key is a key whose keysym is Meta_L or Meta_R, and which generates
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1732 one of the modifier bits Mod1-Mod5.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1733
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1734 Unfortunately, many keyboards don't have Meta keys in their default
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1735 configuration. So, if there are no Meta keys, but there are "Alt" keys,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1736 emacs will interpret Alt as Meta. If there are both Meta and Alt keys,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1737 then the Meta keys mean "Meta", and the Alt keys mean "Alt" (it used to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1738 mean "Symbol," but that just confused the hell out of way too many people).
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1739
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1740 This works with the default configurations of the 19 keyboard-types I've
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1741 checked.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1742
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1743 Emacs detects keyboard configurations which violate the above rules, and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1744 prints an error message on the standard-error-output. (Perhaps it should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1745 use a pop-up-window instead.)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1746 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1747
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1748 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1749 gtk_reset_key_mapping (struct device *d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1750 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1751 Display *display = GDK_DISPLAY ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1752 struct gtk_device *xd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1753 KeySym *keysym, *keysym_end;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1754 Lisp_Object hashtable;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1755 int key_code_count, keysyms_per_code;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1756
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1757 if (xd->x_keysym_map)
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1758 XFree ((char *) xd->x_keysym_map);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1759 XDisplayKeycodes (display,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1760 &xd->x_keysym_map_min_code,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1761 &xd->x_keysym_map_max_code);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1762 key_code_count = xd->x_keysym_map_max_code - xd->x_keysym_map_min_code + 1;
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1763 xd->x_keysym_map =
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1764 XGetKeyboardMapping (display, xd->x_keysym_map_min_code, key_code_count,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1765 &xd->x_keysym_map_keysyms_per_code);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1766
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1767 hashtable = xd->x_keysym_map_hashtable;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1768 if (HASH_TABLEP (hashtable))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1769 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1770 Fclrhash (hashtable);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1771 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1772 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1773 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1774 xd->x_keysym_map_hashtable = hashtable =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1775 make_lisp_hash_table (128, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1776 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1777
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
1778 for (keysym = xd->x_keysym_map,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1779 keysyms_per_code = xd->x_keysym_map_keysyms_per_code,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1780 keysym_end = keysym + (key_code_count * keysyms_per_code);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1781 keysym < keysym_end;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1782 keysym += keysyms_per_code)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1783 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1784 int j;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1785
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1786 if (keysym[0] == NoSymbol)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1787 continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1788
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1789 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1790 Extbyte *name = XKeysymToString (keysym[0]);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1791 Lisp_Object sym = gtk_keysym_to_emacs_keysym (keysym[0], 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1792 if (name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1793 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1794 Fputhash (build_ext_string (name, Qnative), Qsans_modifiers,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1795 hashtable);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1796 Fputhash (sym, Qsans_modifiers, hashtable);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1797 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1798 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1799
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1800 for (j = 1; j < keysyms_per_code; j++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1801 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1802 if (keysym[j] != keysym[0] &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1803 keysym[j] != NoSymbol)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1804 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1805 Extbyte *name = XKeysymToString (keysym[j]);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1806 Lisp_Object sym = gtk_keysym_to_emacs_keysym (keysym[j], 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1807 if (name && NILP (Fgethash (sym, hashtable, Qnil)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1808 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
1809 Fputhash (build_ext_string (name, Qnative), Qt, hashtable);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1810 Fputhash (sym, Qt, hashtable);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1811 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1812 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1813 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1814 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1815 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1816
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1817 static const char *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1818 index_to_name (int indice)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1819 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1820 switch (indice)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1821 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1822 case ShiftMapIndex: return "ModShift";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1823 case LockMapIndex: return "ModLock";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1824 case ControlMapIndex: return "ModControl";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1825 case Mod1MapIndex: return "Mod1";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1826 case Mod2MapIndex: return "Mod2";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1827 case Mod3MapIndex: return "Mod3";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1828 case Mod4MapIndex: return "Mod4";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1829 case Mod5MapIndex: return "Mod5";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1830 default: return "???";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1831 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1832 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1833
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1834 /* Boy, I really wish C had local functions... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1835 struct c_doesnt_have_closures /* #### not yet used */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1836 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1837 int warned_about_overlapping_modifiers;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1838 int warned_about_predefined_modifiers;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1839 int warned_about_duplicate_modifiers;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1840 int meta_bit;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1841 int hyper_bit;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1842 int super_bit;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1843 int alt_bit;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1844 int mode_bit;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1845 };
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1846
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1847 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1848 gtk_reset_modifier_mapping (struct device *d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1849 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1850 Display *display = GDK_DISPLAY ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1851 struct gtk_device *xd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1852 int modifier_index, modifier_key, column, mkpm;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1853 int warned_about_overlapping_modifiers = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1854 /* int warned_about_predefined_modifiers = 0; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1855 /* int warned_about_duplicate_modifiers = 0; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1856 int meta_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1857 int hyper_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1858 int super_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1859 int alt_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1860 int mode_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1861 XModifierKeymap *map = (XModifierKeymap *) xd->x_modifier_keymap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1862
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1863 xd->lock_interpretation = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1864
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1865 if (map)
3949
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1866 {
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1867 XFreeModifiermap (xd->x_modifier_keymap);
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1868 /* Set it to NULL in case we receive two MappingModifier events in a
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1869 row, and the second is processed during some CHECK_QUITs within
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1870 x_reset_key_mapping. If that happens, XFreeModifierMap will be
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1871 called twice on the same map, and we crash. */
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1872 xd->x_modifier_keymap = NULL;
33b9323388c5 [xemacs-hg @ 2007-05-12 10:59:15 by aidan]
aidan
parents: 2842
diff changeset
1873 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1874
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1875 gtk_reset_key_mapping (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1876
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1877 xd->x_modifier_keymap = map = XGetModifierMapping (display);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1878
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1879 /* Boy, I really wish C had local functions...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1880 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1881
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1882 /* The call to warn_when_safe must be on the same line as the string or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1883 make-msgfile won't pick it up properly (the newline doesn't confuse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1884 it, but the backslash does). */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1885
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1886 #define store_modifier(name,old) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1887 old = modifier_index;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1888
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1889 mkpm = map->max_keypermod;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1890 for (modifier_index = 0; modifier_index < 8; modifier_index++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1891 for (modifier_key = 0; modifier_key < mkpm; modifier_key++) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1892 KeySym last_sym = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1893 for (column = 0; column < 4; column += 2) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1894 KeyCode code = map->modifiermap[modifier_index * mkpm
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1895 + modifier_key];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1896 KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1897 if (sym == last_sym) continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1898 last_sym = sym;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1899 switch (sym) {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1900 case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1901 case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1902 case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1903 case XK_Super_L: store_modifier ("Super_L", super_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1904 case XK_Super_R: store_modifier ("Super_R", super_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1905 case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1906 case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1907 case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1908 case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1909 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1910 case XK_Control_L: check_modifier ("Control_L", ControlMask); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1911 case XK_Control_R: check_modifier ("Control_R", ControlMask); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1912 case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1913 case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1914 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1915 case XK_Shift_Lock: /* check_modifier ("Shift_Lock", LockMask); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1916 xd->lock_interpretation = XK_Shift_Lock; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1917 case XK_Caps_Lock: /* check_modifier ("Caps_Lock", LockMask); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1918 xd->lock_interpretation = XK_Caps_Lock; break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1919
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1920 /* It probably doesn't make any sense for a modifier bit to be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1921 assigned to a key that is not one of the above, but OpenWindows
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1922 assigns modifier bits to a couple of random function keys for
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1923 no reason that I can discern, so printing a warning here would
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1924 be annoying. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1925 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1926 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1927 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1928 #undef store_modifier
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1929 #undef check_modifier
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1930 #undef modwarn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1931 #undef modbarf
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1932
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1933 /* If there was no Meta key, then try using the Alt key instead.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1934 If there is both a Meta key and an Alt key, then the Alt key
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1935 is not disturbed and remains an Alt key. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1936 if (! meta_bit && alt_bit)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1937 meta_bit = alt_bit, alt_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1938
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1939 /* mode_bit overrides everything, since it's processed down inside of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1940 XLookupString() instead of by us. If Meta and Mode_switch both
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1941 generate the same modifier bit (which is an error), then we don't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1942 interpret that bit as Meta, because we can't make XLookupString()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1943 not interpret it as Mode_switch; and interpreting it as both would
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1944 be totally wrong. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1945 if (mode_bit)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1946 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1947 const char *warn = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1948 if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1949 else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1950 else if (mode_bit == super_bit) warn = "Super", super_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1951 else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1952 if (warn)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1953 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1954 warn_when_safe
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1955 (Qkey_mapping, Qwarning,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1956 "XEmacs: %s is being used for both Mode_switch and %s.",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1957 index_to_name (mode_bit), warn),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1958 warned_about_overlapping_modifiers = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1959 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1960 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1961 #undef index_to_name
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1962
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1963 xd->MetaMask = (meta_bit ? (1 << meta_bit) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1964 xd->HyperMask = (hyper_bit ? (1 << hyper_bit) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1965 xd->SuperMask = (super_bit ? (1 << super_bit) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1966 xd->AltMask = (alt_bit ? (1 << alt_bit) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1967 xd->ModeMask = (mode_bit ? (1 << mode_bit) : 0); /* unused */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1968
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1969 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1970
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1971 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1972 gtk_init_modifier_mapping (struct device *d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1973 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1974 struct gtk_device *gd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1975 gd->x_keysym_map_hashtable = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1976 gd->x_keysym_map = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1977 gd->x_modifier_keymap = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1978 gtk_reset_modifier_mapping (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1979 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1980
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1981 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1982 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1983 gtk_key_is_modifier_p (KeyCode keycode, struct device *d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1984 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1985 struct gtk_device *xd = DEVICE_GTK_DATA (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1986 KeySym *syms;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1987 KeySym *map = (KeySym *) xd->x_keysym_map;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1988 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1989
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1990 if (keycode < xd->x_keysym_map_min_code ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1991 keycode > xd->x_keysym_map_max_code)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1992 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1993
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1994 syms = &map [(keycode - xd->x_keysym_map_min_code) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1995 xd->x_keysym_map_keysyms_per_code];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1996 for (i = 0; i < xd->x_keysym_map_keysyms_per_code; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1997 if (IsModifierKey (syms [i]) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1998 syms [i] == XK_Mode_switch) /* why doesn't IsModifierKey count this? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1999 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2000 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2001 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2002 #endif