comparison src/event-Xt.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents 74fd4e045ea6
children b8cc9ab3f761
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
61 #include "dragdrop.h" 61 #include "dragdrop.h"
62 #endif 62 #endif
63 63
64 #if defined (HAVE_OFFIX_DND) 64 #if defined (HAVE_OFFIX_DND)
65 #include "offix.h" 65 #include "offix.h"
66 #endif
67
68 #ifdef WINDOWSNT
69 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if
70 we are running X and Windows modifiers otherwise.
71 gak. This is a kludge until we support multiple native GUIs!
72 */
73 #undef MOD_ALT
74 #undef MOD_CONTROL
75 #undef MOD_SHIFT
76 #endif 66 #endif
77 67
78 #include "events-mod.h" 68 #include "events-mod.h"
79 69
80 static void enqueue_Xt_dispatch_event (Lisp_Object event); 70 static void enqueue_Xt_dispatch_event (Lisp_Object event);
1122 1112
1123 case KeyPress: 1113 case KeyPress:
1124 case ButtonPress: 1114 case ButtonPress:
1125 case ButtonRelease: 1115 case ButtonRelease:
1126 { 1116 {
1127 unsigned int modifiers = 0; 1117 int modifiers = 0;
1128 int shift_p, lock_p; 1118 int shift_p, lock_p;
1129 Bool key_event_p = (x_event->type == KeyPress); 1119 Bool key_event_p = (x_event->type == KeyPress);
1130 unsigned int *state = 1120 unsigned int *state =
1131 key_event_p ? &x_event->xkey.state : &x_event->xbutton.state; 1121 key_event_p ? &x_event->xkey.state : &x_event->xbutton.state;
1132 1122
1149 DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d) = 1139 DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d) =
1150 key_event_p ? x_event->xkey.time : x_event->xbutton.time; 1140 key_event_p ? x_event->xkey.time : x_event->xbutton.time;
1151 1141
1152 x_handle_sticky_modifiers (x_event, d); 1142 x_handle_sticky_modifiers (x_event, d);
1153 1143
1154 if (*state & ControlMask) modifiers |= MOD_CONTROL; 1144 if (*state & ControlMask) modifiers |= XEMACS_MOD_CONTROL;
1155 if (*state & xd->MetaMask) modifiers |= MOD_META; 1145 if (*state & xd->MetaMask) modifiers |= XEMACS_MOD_META;
1156 if (*state & xd->SuperMask) modifiers |= MOD_SUPER; 1146 if (*state & xd->SuperMask) modifiers |= XEMACS_MOD_SUPER;
1157 if (*state & xd->HyperMask) modifiers |= MOD_HYPER; 1147 if (*state & xd->HyperMask) modifiers |= XEMACS_MOD_HYPER;
1158 if (*state & xd->AltMask) modifiers |= MOD_ALT; 1148 if (*state & xd->AltMask) modifiers |= XEMACS_MOD_ALT;
1159 1149
1160 /* Ignore the Caps_Lock key if: 1150 /* Ignore the Caps_Lock key if:
1161 - any other modifiers are down, so that Caps_Lock doesn't 1151 - any other modifiers are down, so that Caps_Lock doesn't
1162 turn C-x into C-X, which would suck. 1152 turn C-x into C-X, which would suck.
1163 - the event was a mouse event. */ 1153 - the event was a mouse event. */
1166 1156
1167 shift_p = *state & ShiftMask; 1157 shift_p = *state & ShiftMask;
1168 lock_p = *state & LockMask; 1158 lock_p = *state & LockMask;
1169 1159
1170 if (shift_p || lock_p) 1160 if (shift_p || lock_p)
1171 modifiers |= MOD_SHIFT; 1161 modifiers |= XEMACS_MOD_SHIFT;
1172 1162
1173 if (key_event_p) 1163 if (key_event_p)
1174 { 1164 {
1175 Lisp_Object keysym; 1165 Lisp_Object keysym;
1176 XKeyEvent *ev = &x_event->xkey; 1166 XKeyEvent *ev = &x_event->xkey;
1198 /* !!#### maybe fix for Mule */ 1188 /* !!#### maybe fix for Mule */
1199 if (lock_p && !shift_p && 1189 if (lock_p && !shift_p &&
1200 ! (CHAR_OR_CHAR_INTP (keysym) 1190 ! (CHAR_OR_CHAR_INTP (keysym)
1201 && keysym_obeys_caps_lock_p 1191 && keysym_obeys_caps_lock_p
1202 ((KeySym) XCHAR_OR_CHAR_INT (keysym), d))) 1192 ((KeySym) XCHAR_OR_CHAR_INT (keysym), d)))
1203 modifiers &= (~MOD_SHIFT); 1193 modifiers &= (~XEMACS_MOD_SHIFT);
1204 1194
1205 /* If this key contains two distinct keysyms, that is, 1195 /* If this key contains two distinct keysyms, that is,
1206 "shift" generates a different keysym than the 1196 "shift" generates a different keysym than the
1207 non-shifted key, then don't apply the shift modifier 1197 non-shifted key, then don't apply the shift modifier
1208 bit: it's implicit. Otherwise, if there would be no 1198 bit: it's implicit. Otherwise, if there would be no
1210 and unshifted version of this key, apply the shift bit. 1200 and unshifted version of this key, apply the shift bit.
1211 Non-graphics, like Backspace and F1 get the shift bit 1201 Non-graphics, like Backspace and F1 get the shift bit
1212 in the modifiers slot. Neither the characters "a", 1202 in the modifiers slot. Neither the characters "a",
1213 "A", "2", nor "@" normally have the shift bit set. 1203 "A", "2", nor "@" normally have the shift bit set.
1214 However, "F1" normally does. */ 1204 However, "F1" normally does. */
1215 if (modifiers & MOD_SHIFT) 1205 if (modifiers & XEMACS_MOD_SHIFT)
1216 { 1206 {
1217 int Mode_switch_p = *state & xd->ModeMask; 1207 int Mode_switch_p = *state & xd->ModeMask;
1218 KeySym bot = XLookupKeysym (ev, Mode_switch_p ? 2 : 0); 1208 KeySym bot = XLookupKeysym (ev, Mode_switch_p ? 2 : 0);
1219 KeySym top = XLookupKeysym (ev, Mode_switch_p ? 3 : 1); 1209 KeySym top = XLookupKeysym (ev, Mode_switch_p ? 3 : 1);
1220 if (top && bot && top != bot) 1210 if (top && bot && top != bot)
1221 modifiers &= ~MOD_SHIFT; 1211 modifiers &= ~XEMACS_MOD_SHIFT;
1222 } 1212 }
1223 emacs_event->event_type = key_press_event; 1213 emacs_event->event_type = key_press_event;
1224 emacs_event->timestamp = ev->time; 1214 emacs_event->timestamp = ev->time;
1225 emacs_event->event.key.modifiers = modifiers; 1215 emacs_event->event.key.modifiers = modifiers;
1226 emacs_event->event.key.keysym = keysym; 1216 emacs_event->event.key.keysym = keysym;
1253 1243
1254 case MotionNotify: 1244 case MotionNotify:
1255 { 1245 {
1256 XMotionEvent *ev = &x_event->xmotion; 1246 XMotionEvent *ev = &x_event->xmotion;
1257 struct frame *frame = x_window_to_frame (d, ev->window); 1247 struct frame *frame = x_window_to_frame (d, ev->window);
1258 unsigned int modifiers = 0; 1248 int modifiers = 0;
1259 XMotionEvent event2; 1249 XMotionEvent event2;
1260 1250
1261 if (! frame) 1251 if (! frame)
1262 return 0; /* not for us */ 1252 return 0; /* not for us */
1263 1253
1282 XSETFRAME (emacs_event->channel, frame); 1272 XSETFRAME (emacs_event->channel, frame);
1283 emacs_event->event_type = pointer_motion_event; 1273 emacs_event->event_type = pointer_motion_event;
1284 emacs_event->timestamp = ev->time; 1274 emacs_event->timestamp = ev->time;
1285 emacs_event->event.motion.x = ev->x; 1275 emacs_event->event.motion.x = ev->x;
1286 emacs_event->event.motion.y = ev->y; 1276 emacs_event->event.motion.y = ev->y;
1287 if (ev->state & ShiftMask) modifiers |= MOD_SHIFT; 1277 if (ev->state & ShiftMask) modifiers |= XEMACS_MOD_SHIFT;
1288 if (ev->state & ControlMask) modifiers |= MOD_CONTROL; 1278 if (ev->state & ControlMask) modifiers |= XEMACS_MOD_CONTROL;
1289 if (ev->state & xd->MetaMask) modifiers |= MOD_META; 1279 if (ev->state & xd->MetaMask) modifiers |= XEMACS_MOD_META;
1290 if (ev->state & xd->SuperMask) modifiers |= MOD_SUPER; 1280 if (ev->state & xd->SuperMask) modifiers |= XEMACS_MOD_SUPER;
1291 if (ev->state & xd->HyperMask) modifiers |= MOD_HYPER; 1281 if (ev->state & xd->HyperMask) modifiers |= XEMACS_MOD_HYPER;
1292 if (ev->state & xd->AltMask) modifiers |= MOD_ALT; 1282 if (ev->state & xd->AltMask) modifiers |= XEMACS_MOD_ALT;
1293 /* Currently ignores Shift_Lock but probably shouldn't 1283 /* Currently ignores Shift_Lock but probably shouldn't
1294 (but it definitely should ignore Caps_Lock). */ 1284 (but it definitely should ignore Caps_Lock). */
1295 emacs_event->event.motion.modifiers = modifiers; 1285 emacs_event->event.motion.modifiers = modifiers;
1296 } 1286 }
1297 break; 1287 break;
1303 explicitly prohibits. */ 1293 explicitly prohibits. */
1304 XClientMessageEvent *ev = &x_event->xclient; 1294 XClientMessageEvent *ev = &x_event->xclient;
1305 #ifdef HAVE_OFFIX_DND 1295 #ifdef HAVE_OFFIX_DND
1306 if (DndIsDropMessage(x_event)) 1296 if (DndIsDropMessage(x_event))
1307 { 1297 {
1308 unsigned int state, modifiers = 0, button=0; 1298 unsigned int state;
1299 int modifiers = 0;
1300 unsigned int button=0;
1309 struct frame *frame = x_any_window_to_frame (d, ev->window); 1301 struct frame *frame = x_any_window_to_frame (d, ev->window);
1310 Extbyte *data; 1302 Extbyte *data;
1311 unsigned long size, dtype; 1303 unsigned long size, dtype;
1312 Lisp_Object l_type = Qnil, l_data = Qnil; 1304 Lisp_Object l_type = Qnil, l_data = Qnil;
1313 Lisp_Object l_dndlist = Qnil, l_item = Qnil; 1305 Lisp_Object l_dndlist = Qnil, l_item = Qnil;
1322 emacs_event->event_type = misc_user_event; 1314 emacs_event->event_type = misc_user_event;
1323 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d); 1315 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d);
1324 1316
1325 state=DndDragButtons(x_event); 1317 state=DndDragButtons(x_event);
1326 1318
1327 if (state & ShiftMask) modifiers |= MOD_SHIFT; 1319 if (state & ShiftMask) modifiers |= XEMACS_MOD_SHIFT;
1328 if (state & ControlMask) modifiers |= MOD_CONTROL; 1320 if (state & ControlMask) modifiers |= XEMACS_MOD_CONTROL;
1329 if (state & xd->MetaMask) modifiers |= MOD_META; 1321 if (state & xd->MetaMask) modifiers |= XEMACS_MOD_META;
1330 if (state & xd->SuperMask) modifiers |= MOD_SUPER; 1322 if (state & xd->SuperMask) modifiers |= XEMACS_MOD_SUPER;
1331 if (state & xd->HyperMask) modifiers |= MOD_HYPER; 1323 if (state & xd->HyperMask) modifiers |= XEMACS_MOD_HYPER;
1332 if (state & xd->AltMask) modifiers |= MOD_ALT; 1324 if (state & xd->AltMask) modifiers |= XEMACS_MOD_ALT;
1333 1325
1334 if (state & Button5Mask) button = Button5; 1326 if (state & Button5Mask) button = Button5;
1335 if (state & Button4Mask) button = Button4; 1327 if (state & Button4Mask) button = Button4;
1336 if (state & Button3Mask) button = Button3; 1328 if (state & Button3Mask) button = Button3;
1337 if (state & Button2Mask) button = Button2; 1329 if (state & Button2Mask) button = Button2;
1461 case EnterNotify: 1453 case EnterNotify:
1462 case LeaveNotify: FROB(xcrossing, window); break; 1454 case LeaveNotify: FROB(xcrossing, window); break;
1463 case FocusIn: 1455 case FocusIn:
1464 case FocusOut: FROB(xfocus, window); break; 1456 case FocusOut: FROB(xfocus, window); break;
1465 case VisibilityNotify: FROB(xvisibility, window); break; 1457 case VisibilityNotify: FROB(xvisibility, window); break;
1458 case CreateNotify: FROB(xcreatewindow, window); break;
1466 default: 1459 default:
1467 w = x_event->xany.window; 1460 w = x_event->xany.window;
1468 *x_event_copy = *x_event; 1461 *x_event_copy = *x_event;
1469 break; 1462 break;
1470 } 1463 }
1720 #endif 1713 #endif
1721 } 1714 }
1722 } 1715 }
1723 1716
1724 static void 1717 static void
1718 emacs_Xt_force_event_pending (struct frame* f)
1719 {
1720 XEvent event;
1721
1722 Display* dpy = DEVICE_X_DISPLAY (XDEVICE (FRAME_DEVICE (f)));
1723 event.xclient.type = ClientMessage;
1724 event.xclient.display = dpy;
1725 event.xclient.message_type = XInternAtom (dpy, "BumpQueue", False);
1726 event.xclient.format = 32;
1727 event.xclient.window = 0;
1728
1729 /* Send the drop message */
1730 XSendEvent(dpy, XtWindow (FRAME_X_SHELL_WIDGET (f)),
1731 True, NoEventMask, &event);
1732 /* Force event pending to check the X queue. */
1733 quit_check_signal_tick_count++;
1734 }
1735
1736 static void
1725 emacs_Xt_handle_magic_event (Lisp_Event *emacs_event) 1737 emacs_Xt_handle_magic_event (Lisp_Event *emacs_event)
1726 { 1738 {
1727 /* This function can GC */ 1739 /* This function can GC */
1728 XEvent *event = &emacs_event->event.magic.underlying_x_event; 1740 XEvent *event = &emacs_event->event.magic.underlying_x_event;
1729 struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event)); 1741 struct frame *f = XFRAME (EVENT_CHANNEL (emacs_event));
1832 #ifdef HAVE_XIM 1844 #ifdef HAVE_XIM
1833 XIM_SetGeometry (f); 1845 XIM_SetGeometry (f);
1834 #endif 1846 #endif
1835 break; 1847 break;
1836 1848
1849 case CreateNotify:
1850 printf ("window created\n");
1851 break;
1837 default: 1852 default:
1838 break; 1853 break;
1839 } 1854 }
1840 } 1855 }
1841 1856
2293 if (f) 2308 if (f)
2294 { 2309 {
2295 char *buf = alloca_array (char, XSTRING_LENGTH (f->name) + 4); 2310 char *buf = alloca_array (char, XSTRING_LENGTH (f->name) + 4);
2296 sprintf (buf, " \"%s\"", XSTRING_DATA (f->name)); 2311 sprintf (buf, " \"%s\"", XSTRING_DATA (f->name));
2297 write_string_to_stdio_stream (stderr, 0, (Bufbyte *) buf, 0, 2312 write_string_to_stdio_stream (stderr, 0, (Bufbyte *) buf, 0,
2298 strlen (buf), Qterminal); 2313 strlen (buf), Qterminal, 1);
2299 } 2314 }
2300 stderr_out ("\n"); 2315 stderr_out ("\n");
2301 } 2316 }
2302 2317
2303 static const char * 2318 static const char *
3078 void 3093 void
3079 reinit_vars_of_event_Xt (void) 3094 reinit_vars_of_event_Xt (void)
3080 { 3095 {
3081 Xt_event_stream = xnew (struct event_stream); 3096 Xt_event_stream = xnew (struct event_stream);
3082 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p; 3097 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p;
3098 Xt_event_stream->force_event_pending = emacs_Xt_force_event_pending;
3083 Xt_event_stream->next_event_cb = emacs_Xt_next_event; 3099 Xt_event_stream->next_event_cb = emacs_Xt_next_event;
3084 Xt_event_stream->handle_magic_event_cb = emacs_Xt_handle_magic_event; 3100 Xt_event_stream->handle_magic_event_cb = emacs_Xt_handle_magic_event;
3085 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout; 3101 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout;
3086 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout; 3102 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout;
3087 Xt_event_stream->select_console_cb = emacs_Xt_select_console; 3103 Xt_event_stream->select_console_cb = emacs_Xt_select_console;