comparison src/event-Xt.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 6240c7796c7a
children 064ab7fed2e0
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
29 #include "../lwlib/lwlib.h" 29 #include "../lwlib/lwlib.h"
30 #include "EmacsFrame.h" 30 #include "EmacsFrame.h"
31 31
32 #include "blocktype.h" 32 #include "blocktype.h"
33 #include "buffer.h" 33 #include "buffer.h"
34 #include "commands.h"
35 #include "console.h" 34 #include "console.h"
36 #include "console-tty.h" 35 #include "console-tty.h"
37 #include "events.h" 36 #include "events.h"
38 #include "frame.h" 37 #include "frame.h"
39 #include "objects-x.h" 38 #include "objects-x.h"
179 x_reset_key_mapping (struct device *d) 178 x_reset_key_mapping (struct device *d)
180 { 179 {
181 Display *display = DEVICE_X_DISPLAY (d); 180 Display *display = DEVICE_X_DISPLAY (d);
182 struct x_device *xd = DEVICE_X_DATA (d); 181 struct x_device *xd = DEVICE_X_DATA (d);
183 KeySym *keysym, *keysym_end; 182 KeySym *keysym, *keysym_end;
184 Lisp_Object hashtable; 183 Lisp_Object hash_table;
185 int key_code_count, keysyms_per_code; 184 int key_code_count, keysyms_per_code;
186 185
187 if (xd->x_keysym_map) 186 if (xd->x_keysym_map)
188 XFree ((char *) xd->x_keysym_map); 187 XFree ((char *) xd->x_keysym_map);
189 XDisplayKeycodes (display, 188 XDisplayKeycodes (display,
192 key_code_count = xd->x_keysym_map_max_code - xd->x_keysym_map_min_code + 1; 191 key_code_count = xd->x_keysym_map_max_code - xd->x_keysym_map_min_code + 1;
193 xd->x_keysym_map = 192 xd->x_keysym_map =
194 XGetKeyboardMapping (display, xd->x_keysym_map_min_code, key_code_count, 193 XGetKeyboardMapping (display, xd->x_keysym_map_min_code, key_code_count,
195 &xd->x_keysym_map_keysyms_per_code); 194 &xd->x_keysym_map_keysyms_per_code);
196 195
197 hashtable = xd->x_keysym_map_hashtable; 196 hash_table = xd->x_keysym_map_hash_table;
198 if (HASHTABLEP (hashtable)) 197 if (HASH_TABLEP (hash_table))
199 Fclrhash (hashtable); 198 Fclrhash (hash_table);
200 else 199 else
201 xd->x_keysym_map_hashtable = hashtable = 200 xd->x_keysym_map_hash_table = hash_table =
202 make_lisp_hashtable (128, HASHTABLE_NONWEAK, HASHTABLE_EQUAL); 201 make_lisp_hash_table (128, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
203 202
204 for (keysym = xd->x_keysym_map, 203 for (keysym = xd->x_keysym_map,
205 keysyms_per_code = xd->x_keysym_map_keysyms_per_code, 204 keysyms_per_code = xd->x_keysym_map_keysyms_per_code,
206 keysym_end = keysym + (key_code_count * keysyms_per_code); 205 keysym_end = keysym + (key_code_count * keysyms_per_code);
207 keysym < keysym_end; 206 keysym < keysym_end;
215 { 214 {
216 char *name = XKeysymToString (keysym[0]); 215 char *name = XKeysymToString (keysym[0]);
217 Lisp_Object sym = x_keysym_to_emacs_keysym (keysym[0], 0); 216 Lisp_Object sym = x_keysym_to_emacs_keysym (keysym[0], 0);
218 if (name) 217 if (name)
219 { 218 {
220 Fputhash (build_string (name), Qsans_modifiers, hashtable); 219 Fputhash (build_string (name), Qsans_modifiers, hash_table);
221 Fputhash (sym, Qsans_modifiers, hashtable); 220 Fputhash (sym, Qsans_modifiers, hash_table);
222 } 221 }
223 } 222 }
224 223
225 for (j = 1; j < keysyms_per_code; j++) 224 for (j = 1; j < keysyms_per_code; j++)
226 { 225 {
227 if (keysym[j] != keysym[0] && 226 if (keysym[j] != keysym[0] &&
228 keysym[j] != NoSymbol) 227 keysym[j] != NoSymbol)
229 { 228 {
230 char *name = XKeysymToString (keysym[j]); 229 char *name = XKeysymToString (keysym[j]);
231 Lisp_Object sym = x_keysym_to_emacs_keysym (keysym[j], 0); 230 Lisp_Object sym = x_keysym_to_emacs_keysym (keysym[j], 0);
232 if (name && NILP (Fgethash (sym, hashtable, Qnil))) 231 if (name && NILP (Fgethash (sym, hash_table, Qnil)))
233 { 232 {
234 Fputhash (build_string (name), Qt, hashtable); 233 Fputhash (build_string (name), Qt, hash_table);
235 Fputhash (sym, Qt, hashtable); 234 Fputhash (sym, Qt, hash_table);
236 } 235 }
237 } 236 }
238 } 237 }
239 } 238 }
240 } 239 }
448 447
449 void 448 void
450 x_init_modifier_mapping (struct device *d) 449 x_init_modifier_mapping (struct device *d)
451 { 450 {
452 struct x_device *xd = DEVICE_X_DATA (d); 451 struct x_device *xd = DEVICE_X_DATA (d);
453 xd->x_keysym_map_hashtable = Qnil; 452 xd->x_keysym_map_hash_table = Qnil;
454 xd->x_keysym_map = NULL; 453 xd->x_keysym_map = NULL;
455 xd->x_modifier_keymap = NULL; 454 xd->x_modifier_keymap = NULL;
456 x_reset_modifier_mapping (d); 455 x_reset_modifier_mapping (d);
457 } 456 }
458 457
770 static Lisp_Object 769 static Lisp_Object
771 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p) 770 x_to_emacs_keysym (XKeyPressedEvent *event, int simple_p)
772 /* simple_p means don't try too hard (ASCII only) */ 771 /* simple_p means don't try too hard (ASCII only) */
773 { 772 {
774 KeySym keysym = 0; 773 KeySym keysym = 0;
775 774
776 #ifdef HAVE_XIM 775 #ifdef HAVE_XIM
777 int len; 776 int len;
778 char buffer[64]; 777 char buffer[64];
779 char *bufptr = buffer; 778 char *bufptr = buffer;
780 int bufsiz = sizeof (buffer); 779 int bufsiz = sizeof (buffer);
1134 1133
1135 emacs_event->event_type = misc_user_event; 1134 emacs_event->event_type = misc_user_event;
1136 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d); 1135 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d);
1137 1136
1138 state=DndDragButtons(x_event); 1137 state=DndDragButtons(x_event);
1139 1138
1140 if (state & ShiftMask) modifiers |= MOD_SHIFT; 1139 if (state & ShiftMask) modifiers |= MOD_SHIFT;
1141 if (state & ControlMask) modifiers |= MOD_CONTROL; 1140 if (state & ControlMask) modifiers |= MOD_CONTROL;
1142 if (state & xd->MetaMask) modifiers |= MOD_META; 1141 if (state & xd->MetaMask) modifiers |= MOD_META;
1143 if (state & xd->SuperMask) modifiers |= MOD_SUPER; 1142 if (state & xd->SuperMask) modifiers |= MOD_SUPER;
1144 if (state & xd->HyperMask) modifiers |= MOD_HYPER; 1143 if (state & xd->HyperMask) modifiers |= MOD_HYPER;
1181 break; 1180 break;
1182 case DndText: 1181 case DndText:
1183 l_type = Qdragdrop_MIME; 1182 l_type = Qdragdrop_MIME;
1184 l_dndlist = list1 ( list3 ( list1 ( make_string ((Bufbyte *)"text/plain", 10) ), 1183 l_dndlist = list1 ( list3 ( list1 ( make_string ((Bufbyte *)"text/plain", 10) ),
1185 make_string ((Bufbyte *)"8bit", 4), 1184 make_string ((Bufbyte *)"8bit", 4),
1186 make_ext_string ((Extbyte *)data, 1185 make_ext_string ((Extbyte *)data,
1187 strlen((char *)data), 1186 strlen((char *)data),
1188 FORMAT_CTEXT) ) ); 1187 FORMAT_CTEXT) ) );
1189 break; 1188 break;
1190 case DndMIME: 1189 case DndMIME:
1191 /* we have to parse this in some way to extract 1190 /* we have to parse this in some way to extract
1203 case DndFile: 1202 case DndFile:
1204 case DndDir: 1203 case DndDir:
1205 case DndLink: 1204 case DndLink:
1206 case DndExe: 1205 case DndExe:
1207 { 1206 {
1208 char *hurl = dnd_url_hexify_string (data, "file:"); 1207 char *hurl = dnd_url_hexify_string ((char *) data, "file:");
1209 1208
1210 l_dndlist = list1 ( make_string ((Bufbyte *)hurl, 1209 l_dndlist = list1 ( make_string ((Bufbyte *)hurl,
1211 strlen (hurl)) ); 1210 strlen (hurl)) );
1212 l_type = Qdragdrop_URL; 1211 l_type = Qdragdrop_URL;
1213 1212
1215 } 1214 }
1216 break; 1215 break;
1217 case DndURL: 1216 case DndURL:
1218 /* as it is a real URL it should already be escaped 1217 /* as it is a real URL it should already be escaped
1219 and escaping again will break them (cause % is unsave) */ 1218 and escaping again will break them (cause % is unsave) */
1220 l_dndlist = list1 ( make_ext_string ((Extbyte *)data, 1219 l_dndlist = list1 ( make_ext_string ((Extbyte *)data,
1221 strlen ((char *)data), 1220 strlen ((char *)data),
1222 FORMAT_FILENAME) ); 1221 FORMAT_FILENAME) );
1223 l_type = Qdragdrop_URL; 1222 l_type = Qdragdrop_URL;
1224 break; 1223 break;
1225 default: /* Unknown, RawData and any other type */ 1224 default: /* Unknown, RawData and any other type */
1593 1592
1594 case ClientMessage: 1593 case ClientMessage:
1595 handle_client_message (f, event); 1594 handle_client_message (f, event);
1596 break; 1595 break;
1597 1596
1598 case VisibilityNotify: /* window visiblity has changed */ 1597 case VisibilityNotify: /* window visibility has changed */
1599 if (event->xvisibility.window == XtWindow (FRAME_X_SHELL_WIDGET (f))) 1598 if (event->xvisibility.window == XtWindow (FRAME_X_SHELL_WIDGET (f)))
1600 { 1599 {
1601 FRAME_X_TOTALLY_VISIBLE_P (f) = 1600 FRAME_X_TOTALLY_VISIBLE_P (f) =
1602 (event->xvisibility.state == VisibilityUnobscured); 1601 (event->xvisibility.state == VisibilityUnobscured);
1603 /* Note that the fvwm pager only sends VisibilityNotify when 1602 /* Note that the fvwm pager only sends VisibilityNotify when
1692 emacs_Xt_remove_timeout (int id) 1691 emacs_Xt_remove_timeout (int id)
1693 { 1692 {
1694 struct Xt_timeout *timeout, *t2; 1693 struct Xt_timeout *timeout, *t2;
1695 1694
1696 timeout = NULL; 1695 timeout = NULL;
1697 1696
1698 /* Find the timeout on the list of pending ones, if it's still there. */ 1697 /* Find the timeout on the list of pending ones, if it's still there. */
1699 if (pending_timeouts) 1698 if (pending_timeouts)
1700 { 1699 {
1701 if (id == pending_timeouts->id) 1700 if (id == pending_timeouts->id)
1702 { 1701 {
2895 2894
2896 /* this function only makes safe calls */ 2895 /* this function only makes safe calls */
2897 init_what_input_once (); 2896 init_what_input_once ();
2898 2897
2899 Xt_event_stream = xnew (struct event_stream); 2898 Xt_event_stream = xnew (struct event_stream);
2900 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p; 2899 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p;
2901 Xt_event_stream->next_event_cb = emacs_Xt_next_event; 2900 Xt_event_stream->next_event_cb = emacs_Xt_next_event;
2902 Xt_event_stream->handle_magic_event_cb= emacs_Xt_handle_magic_event; 2901 Xt_event_stream->handle_magic_event_cb = emacs_Xt_handle_magic_event;
2903 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout; 2902 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout;
2904 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout; 2903 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout;
2905 Xt_event_stream->select_console_cb = emacs_Xt_select_console; 2904 Xt_event_stream->select_console_cb = emacs_Xt_select_console;
2906 Xt_event_stream->unselect_console_cb = emacs_Xt_unselect_console; 2905 Xt_event_stream->unselect_console_cb = emacs_Xt_unselect_console;
2907 Xt_event_stream->select_process_cb = emacs_Xt_select_process; 2906 Xt_event_stream->select_process_cb = emacs_Xt_select_process;
2908 Xt_event_stream->unselect_process_cb = emacs_Xt_unselect_process; 2907 Xt_event_stream->unselect_process_cb = emacs_Xt_unselect_process;
2909 Xt_event_stream->quit_p_cb = emacs_Xt_quit_p; 2908 Xt_event_stream->quit_p_cb = emacs_Xt_quit_p;
2910 Xt_event_stream->create_stream_pair_cb= emacs_Xt_create_stream_pair; 2909 Xt_event_stream->create_stream_pair_cb = emacs_Xt_create_stream_pair;
2911 Xt_event_stream->delete_stream_pair_cb= emacs_Xt_delete_stream_pair; 2910 Xt_event_stream->delete_stream_pair_cb = emacs_Xt_delete_stream_pair;
2912 2911
2913 DEFVAR_BOOL ("modifier-keys-are-sticky", &modifier_keys_are_sticky /* 2912 DEFVAR_BOOL ("modifier-keys-are-sticky", &modifier_keys_are_sticky /*
2914 *Non-nil makes modifier keys sticky. 2913 *Non-nil makes modifier keys sticky.
2915 This means that you can release the modifier key before pressing down 2914 This means that you can release the modifier key before pressing down
2916 the key that you wish to be modified. Although this is non-standard 2915 the key that you wish to be modified. Although this is non-standard