comparison src/xfns.c @ 2694:ca45565a3392

(Fx_get_mouse_event, Fx_mouse_events): Code deleted.
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 May 1993 16:29:04 +0000
parents a84b9a78ab08
children 267d29b9490b
comparison
equal deleted inserted replaced
2693:1deaf4364cd3 2694:ca45565a3392
3299 width, height); 3299 width, height);
3300 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f), 3300 XCopyPlane (x_current_display, image, FRAME_X_WINDOW (f),
3301 f->display.x->normal_gc, 0, 0, width, height, x, y); 3301 f->display.x->normal_gc, 0, 0, width, height, x, y);
3302 } 3302 }
3303 #endif 3303 #endif
3304
3305 #if 0
3306
3307 #ifdef HAVE_X11
3308 #define XMouseEvent XEvent
3309 #define WhichMouseButton xbutton.button
3310 #define MouseWindow xbutton.window
3311 #define MouseX xbutton.x
3312 #define MouseY xbutton.y
3313 #define MouseTime xbutton.time
3314 #define ButtonReleased ButtonRelease
3315 #define ButtonPressed ButtonPress
3316 #else
3317 #define XMouseEvent XButtonEvent
3318 #define WhichMouseButton detail
3319 #define MouseWindow window
3320 #define MouseX x
3321 #define MouseY y
3322 #define MouseTime time
3323 #endif /* X11 */
3324
3325 DEFUN ("x-mouse-events", Fx_mouse_events, Sx_mouse_events, 0, 0, 0,
3326 "Return number of pending mouse events from X window system.")
3327 ()
3328 {
3329 return make_number (queue_event_count (&x_mouse_queue));
3330 }
3331
3332 /* Encode the mouse button events in the form expected by the
3333 mouse code in Lisp. For X11, this means moving the masks around. */
3334
3335 static int
3336 encode_mouse_button (mouse_event)
3337 XMouseEvent mouse_event;
3338 {
3339 register int event_code;
3340 register char key_mask;
3341
3342 event_code = mouse_event.detail & 3;
3343 key_mask = (mouse_event.detail >> 8) & 0xf0;
3344 event_code |= key_mask >> 1;
3345 if (mouse_event.type == ButtonReleased) event_code |= 0x04;
3346 return event_code;
3347 }
3348
3349 DEFUN ("x-get-mouse-event", Fx_get_mouse_event, Sx_get_mouse_event,
3350 0, 1, 0,
3351 "Get next mouse event out of mouse event buffer.\n\
3352 Optional ARG non-nil means return nil immediately if no pending event;\n\
3353 otherwise, wait for an event. Returns a four-part list:\n\
3354 ((X-POS Y-POS) WINDOW FRAME-PART KEYSEQ TIMESTAMP).\n\
3355 Normally X-POS and Y-POS are the position of the click on the frame\n\
3356 (measured in characters and lines), and WINDOW is the window clicked in.\n\
3357 KEYSEQ is a string, the key sequence to be looked up in the mouse maps.\n\
3358 If FRAME-PART is non-nil, the event was on a scroll bar;\n\
3359 then Y-POS is really the total length of the scroll bar, while X-POS is\n\
3360 the relative position of the scroll bar's value within that total length,\n\
3361 and a third element OFFSET appears in that list: the height of the thumb-up\n\
3362 area at the top of the scroll bar.\n\
3363 FRAME-PART is one of the following symbols:\n\
3364 `vertical-scroll-bar', `vertical-thumbup', `vertical-thumbdown',\n\
3365 `horizontal-scroll-bar', `horizontal-thumbleft', `horizontal-thumbright'.\n\
3366 TIMESTAMP is the lower 23 bits of the X-server's timestamp for\n\
3367 the mouse event.")
3368 (arg)
3369 Lisp_Object arg;
3370 {
3371 XMouseEvent xrep;
3372 register int com_letter;
3373 register Lisp_Object tempx;
3374 register Lisp_Object tempy;
3375 Lisp_Object part, pos, timestamp;
3376 int prefix;
3377 struct frame *f;
3378
3379 int tem;
3380
3381 while (1)
3382 {
3383 BLOCK_INPUT;
3384 tem = dequeue_event (&xrep, &x_mouse_queue);
3385 UNBLOCK_INPUT;
3386
3387 if (tem)
3388 {
3389 switch (xrep.type)
3390 {
3391 case ButtonPressed:
3392 case ButtonReleased:
3393
3394 com_letter = encode_mouse_button (xrep);
3395 mouse_timestamp = xrep.MouseTime;
3396
3397 if ((f = x_window_to_frame (xrep.MouseWindow)) != 0)
3398 {
3399 Lisp_Object frame;
3400
3401 if (f->display.x->icon_desc == xrep.MouseWindow)
3402 {
3403 x_make_frame_visible (f);
3404 continue;
3405 }
3406
3407 XSET (tempx, Lisp_Int,
3408 min (f->width-1, max (0, (xrep.MouseX - f->display.x->internal_border_width)/FONT_WIDTH (f->display.x->font))));
3409 XSET (tempy, Lisp_Int,
3410 min (f->height-1, max (0, (xrep.MouseY - f->display.x->internal_border_width)/FONT_HEIGHT (f->display.x->font))));
3411 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
3412 XSET (frame, Lisp_Frame, f);
3413
3414 pos = Fcons (tempx, Fcons (tempy, Qnil));
3415 Vmouse_window
3416 = Flocate_window_from_coordinates (frame, pos);
3417
3418 Vmouse_event
3419 = Fcons (pos,
3420 Fcons (Vmouse_window,
3421 Fcons (Qnil,
3422 Fcons (Fchar_to_string (make_number (com_letter)),
3423 Fcons (timestamp, Qnil)))));
3424 return Vmouse_event;
3425 }
3426 else if ((f = x_window_to_scroll_bar (xrep.MouseWindow, &part, &prefix)) != 0)
3427 {
3428 int pos, len;
3429 Lisp_Object keyseq;
3430 char *partname;
3431
3432 keyseq = concat2 (Fchar_to_string (make_number (prefix)),
3433 Fchar_to_string (make_number (com_letter)));
3434
3435 pos = xrep.MouseY - (f->display.x->v_scroll_bar_width - 2);
3436 XSET (tempx, Lisp_Int, pos);
3437 len = ((FONT_HEIGHT (f->display.x->font) * f->height)
3438 + f->display.x->internal_border_width
3439 - (2 * (f->display.x->v_scroll_bar_width - 2)));
3440 XSET (tempy, Lisp_Int, len);
3441 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
3442 Vmouse_window = f->selected_window;
3443 Vmouse_event
3444 = Fcons (Fcons (tempx, Fcons (tempy,
3445 Fcons (make_number (f->display.x->v_scroll_bar_width - 2),
3446 Qnil))),
3447 Fcons (Vmouse_window,
3448 Fcons (intern (part),
3449 Fcons (keyseq, Fcons (timestamp,
3450 Qnil)))));
3451 return Vmouse_event;
3452 }
3453 else
3454 continue;
3455
3456 #ifdef HAVE_X11
3457 case MotionNotify:
3458
3459 com_letter = x11_encode_mouse_button (xrep);
3460 if ((f = x_window_to_frame (xrep.MouseWindow)) != 0)
3461 {
3462 Lisp_Object frame;
3463
3464 XSET (tempx, Lisp_Int,
3465 min (f->width-1,
3466 max (0, (xrep.MouseX - f->display.x->internal_border_width)
3467 / FONT_WIDTH (f->display.x->font))));
3468 XSET (tempy, Lisp_Int,
3469 min (f->height-1,
3470 max (0, (xrep.MouseY - f->display.x->internal_border_width)
3471 / FONT_HEIGHT (f->display.x->font))));
3472
3473 XSET (frame, Lisp_Frame, f);
3474 XSET (timestamp, Lisp_Int, (xrep.MouseTime & 0x7fffff));
3475
3476 pos = Fcons (tempx, Fcons (tempy, Qnil));
3477 Vmouse_window
3478 = Flocate_window_from_coordinates (frame, pos);
3479
3480 Vmouse_event
3481 = Fcons (pos,
3482 Fcons (Vmouse_window,
3483 Fcons (Qnil,
3484 Fcons (Fchar_to_string (make_number (com_letter)),
3485 Fcons (timestamp, Qnil)))));
3486 return Vmouse_event;
3487 }
3488
3489 break;
3490 #endif /* HAVE_X11 */
3491
3492 default:
3493 if (f = x_window_to_frame (xrep.MouseWindow))
3494 Vmouse_window = f->selected_window;
3495 else if (f = x_window_to_scroll_bar (xrep.MouseWindow, &part, &prefix))
3496 Vmouse_window = f->selected_window;
3497 return Vmouse_event = Qnil;
3498 }
3499 }
3500
3501 if (!NILP (arg))
3502 return Qnil;
3503
3504 /* Wait till we get another mouse event. */
3505 wait_reading_process_input (0, 0, 2, 0);
3506 }
3507 }
3508 #endif
3509
3510 3304
3511 #ifndef HAVE_X11 3305 #ifndef HAVE_X11
3512 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer, 3306 DEFUN ("x-store-cut-buffer", Fx_store_cut_buffer, Sx_store_cut_buffer,
3513 1, 1, "sStore text in cut buffer: ", 3307 1, 1, "sStore text in cut buffer: ",
3514 "Store contents of STRING into the cut buffer of the X window system.") 3308 "Store contents of STRING into the cut buffer of the X window system.")
4002 defsubr (&Sx_rebind_key); 3796 defsubr (&Sx_rebind_key);
4003 defsubr (&Sx_rebind_keys); 3797 defsubr (&Sx_rebind_keys);
4004 defsubr (&Sx_open_connection); 3798 defsubr (&Sx_open_connection);
4005 defsubr (&Sx_close_current_connection); 3799 defsubr (&Sx_close_current_connection);
4006 defsubr (&Sx_synchronize); 3800 defsubr (&Sx_synchronize);
4007
4008 /* This was used in the old event interface which used a separate
4009 event queue.*/
4010 #if 0
4011 defsubr (&Sx_mouse_events);
4012 defsubr (&Sx_get_mouse_event);
4013 #endif
4014 } 3801 }
4015 3802
4016 #endif /* HAVE_X_WINDOWS */ 3803 #endif /* HAVE_X_WINDOWS */