comparison src/xterm.c @ 11198:571306c7b038

New arg DPYINFO to all callers of x_window_to_frame, x_any_window_to_frame, and x_top_window_to_frame.
author Karl Heuer <kwzh@gnu.org>
date Mon, 03 Apr 1995 23:37:17 +0000
parents 0e9fad3ccf03
children e6bdaaa6ce1b
comparison
equal deleted inserted replaced
11197:1bdc265aab86 11198:571306c7b038
2304 If win is the root window, it has no parent, and 2304 If win is the root window, it has no parent, and
2305 parent_{x,y} are invalid, but that's okay, because we'll 2305 parent_{x,y} are invalid, but that's okay, because we'll
2306 never use them in that case.) */ 2306 never use them in that case.) */
2307 2307
2308 /* Is win one of our frames? */ 2308 /* Is win one of our frames? */
2309 f1 = x_any_window_to_frame (win); 2309 f1 = x_any_window_to_frame (FRAME_X_DISPLAY_INFO (*fp), win);
2310 } 2310 }
2311 2311
2312 /* If not, is it one of our scroll bars? */ 2312 /* If not, is it one of our scroll bars? */
2313 if (! f1) 2313 if (! f1)
2314 { 2314 {
3020 XClearArea (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), 3020 XClearArea (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
3021 0, 0, 0, 0, True); 3021 0, 0, 0, 0, True);
3022 } 3022 }
3023 3023
3024 /* This processes Expose events from the menubar specific X event 3024 /* This processes Expose events from the menubar specific X event
3025 loop in menubar.c. This allows to redisplay the frame if necessary 3025 loop in xmenu.c. This allows to redisplay the frame if necessary
3026 when handling menubar or popup items. */ 3026 when handling menubar or popup items. */
3027 3027
3028 void 3028 void
3029 process_expose_from_menu (event) 3029 process_expose_from_menu (event)
3030 XEvent event; 3030 XEvent event;
3031 { 3031 {
3032 FRAME_PTR f; 3032 FRAME_PTR f;
3033 struct x_display_info *dpyinfo;
3033 3034
3034 BLOCK_INPUT; 3035 BLOCK_INPUT;
3035 3036
3036 f = x_window_to_frame (event.xexpose.window); 3037 dpyinfo = x_display_info_for_display (event.xexpose.display);
3038 f = x_window_to_frame (dpyinfo, event.xexpose.window);
3037 if (f) 3039 if (f)
3038 { 3040 {
3039 if (f->async_visible == 0) 3041 if (f->async_visible == 0)
3040 { 3042 {
3041 f->async_visible = 1; 3043 f->async_visible = 1;
3042 f->async_iconified = 0; 3044 f->async_iconified = 0;
3043 SET_FRAME_GARBAGED (f); 3045 SET_FRAME_GARBAGED (f);
3044 } 3046 }
3045 else 3047 else
3046 { 3048 {
3047 dumprectangle (x_window_to_frame (event.xexpose.window), 3049 dumprectangle (x_window_to_frame (dpyinfo, event.xexpose.window),
3048 event.xexpose.x, event.xexpose.y, 3050 event.xexpose.x, event.xexpose.y,
3049 event.xexpose.width, event.xexpose.height); 3051 event.xexpose.width, event.xexpose.height);
3050 } 3052 }
3051 } 3053 }
3052 else 3054 else
3250 && event.xclient.format == 32) 3252 && event.xclient.format == 32)
3251 { 3253 {
3252 if (event.xclient.data.l[0] 3254 if (event.xclient.data.l[0]
3253 == dpyinfo->Xatom_wm_take_focus) 3255 == dpyinfo->Xatom_wm_take_focus)
3254 { 3256 {
3255 f = x_window_to_frame (event.xclient.window); 3257 f = x_window_to_frame (dpyinfo, event.xclient.window);
3256 /* Since we set WM_TAKE_FOCUS, we must call 3258 /* Since we set WM_TAKE_FOCUS, we must call
3257 XSetInputFocus explicitly. But not if f is null, 3259 XSetInputFocus explicitly. But not if f is null,
3258 since that might be an event for a deleted frame. */ 3260 since that might be an event for a deleted frame. */
3259 if (f) 3261 if (f)
3260 XSetInputFocus (event.xclient.display, 3262 XSetInputFocus (event.xclient.display,
3271 the session manager, who's looking for such a 3273 the session manager, who's looking for such a
3272 PropertyNotify. Can restart processing when 3274 PropertyNotify. Can restart processing when
3273 a keyboard or mouse event arrives. */ 3275 a keyboard or mouse event arrives. */
3274 if (numchars > 0) 3276 if (numchars > 0)
3275 { 3277 {
3276 f = x_top_window_to_frame (event.xclient.window); 3278 f = x_top_window_to_frame (dpyinfo,
3279 event.xclient.window);
3277 3280
3278 /* This is just so we only give real data once 3281 /* This is just so we only give real data once
3279 for a single Emacs process. */ 3282 for a single Emacs process. */
3280 if (f == selected_frame) 3283 if (f == selected_frame)
3281 XSetCommand (FRAME_X_DISPLAY (f), 3284 XSetCommand (FRAME_X_DISPLAY (f),
3288 } 3291 }
3289 } 3292 }
3290 else if (event.xclient.data.l[0] 3293 else if (event.xclient.data.l[0]
3291 == dpyinfo->Xatom_wm_delete_window) 3294 == dpyinfo->Xatom_wm_delete_window)
3292 { 3295 {
3293 struct frame *f = x_any_window_to_frame (event.xclient.window); 3296 struct frame *f
3297 = x_any_window_to_frame (dpyinfo,
3298 event.xclient.window);
3294 3299
3295 if (f) 3300 if (f)
3296 { 3301 {
3297 if (numchars == 0) 3302 if (numchars == 0)
3298 abort (); 3303 abort ();
3312 } 3317 }
3313 else if (event.xclient.message_type 3318 else if (event.xclient.message_type
3314 == dpyinfo->Xatom_wm_window_moved) 3319 == dpyinfo->Xatom_wm_window_moved)
3315 { 3320 {
3316 int new_x, new_y; 3321 int new_x, new_y;
3317 struct frame *f = x_window_to_frame (event.xclient.window); 3322 struct frame *f
3323 = x_window_to_frame (dpyinfo, event.xclient.window);
3318 3324
3319 new_x = event.xclient.data.s[0]; 3325 new_x = event.xclient.data.s[0];
3320 new_y = event.xclient.data.s[1]; 3326 new_y = event.xclient.data.s[1];
3321 3327
3322 if (f) 3328 if (f)
3327 } 3333 }
3328 #if defined (USE_X_TOOLKIT) && defined (HAVE_X11R5) 3334 #if defined (USE_X_TOOLKIT) && defined (HAVE_X11R5)
3329 else if (event.xclient.message_type 3335 else if (event.xclient.message_type
3330 == dpyinfo->Xatom_editres) 3336 == dpyinfo->Xatom_editres)
3331 { 3337 {
3332 struct frame *f = x_any_window_to_frame (event.xclient.window); 3338 struct frame *f
3333 _XEditResCheckMessages (f->display.x->widget, NULL, &event, NULL); 3339 = x_any_window_to_frame (dpyinfo, event.xclient.window);
3340 _XEditResCheckMessages (f->display.x->widget, NULL,
3341 &event, NULL);
3334 } 3342 }
3335 #endif /* USE_X_TOOLKIT and HAVE_X11R5 */ 3343 #endif /* USE_X_TOOLKIT and HAVE_X11R5 */
3336 } 3344 }
3337 break; 3345 break;
3338 3346
3339 case SelectionNotify: 3347 case SelectionNotify:
3340 #ifdef USE_X_TOOLKIT 3348 #ifdef USE_X_TOOLKIT
3341 if (! x_window_to_frame (event.xselection.requestor)) 3349 if (! x_window_to_frame (dpyinfo, event.xselection.requestor))
3342 goto OTHER; 3350 goto OTHER;
3343 #endif /* not USE_X_TOOLKIT */ 3351 #endif /* not USE_X_TOOLKIT */
3344 x_handle_selection_notify (&event); 3352 x_handle_selection_notify (&event);
3345 break; 3353 break;
3346 3354
3347 case SelectionClear: /* Someone has grabbed ownership. */ 3355 case SelectionClear: /* Someone has grabbed ownership. */
3348 #ifdef USE_X_TOOLKIT 3356 #ifdef USE_X_TOOLKIT
3349 if (! x_window_to_frame (event.xselectionclear.window)) 3357 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window))
3350 goto OTHER; 3358 goto OTHER;
3351 #endif /* USE_X_TOOLKIT */ 3359 #endif /* USE_X_TOOLKIT */
3352 { 3360 {
3353 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event; 3361 XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event;
3354 3362
3366 } 3374 }
3367 break; 3375 break;
3368 3376
3369 case SelectionRequest: /* Someone wants our selection. */ 3377 case SelectionRequest: /* Someone wants our selection. */
3370 #ifdef USE_X_TOOLKIT 3378 #ifdef USE_X_TOOLKIT
3371 if (!x_window_to_frame (event.xselectionrequest.owner)) 3379 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner))
3372 goto OTHER; 3380 goto OTHER;
3373 #endif /* USE_X_TOOLKIT */ 3381 #endif /* USE_X_TOOLKIT */
3374 if (x_queue_selection_requests) 3382 if (x_queue_selection_requests)
3375 x_queue_event (x_window_to_frame (event.xselectionrequest.owner), 3383 x_queue_event (x_window_to_frame (dpyinfo, event.xselectionrequest.owner),
3376 &event); 3384 &event);
3377 else 3385 else
3378 { 3386 {
3379 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event; 3387 XSelectionRequestEvent *eventp = (XSelectionRequestEvent *) &event;
3380 3388
3395 } 3403 }
3396 break; 3404 break;
3397 3405
3398 case PropertyNotify: 3406 case PropertyNotify:
3399 #ifdef USE_X_TOOLKIT 3407 #ifdef USE_X_TOOLKIT
3400 if (!x_any_window_to_frame (event.xproperty.window)) 3408 if (!x_any_window_to_frame (dpyinfo, event.xproperty.window))
3401 goto OTHER; 3409 goto OTHER;
3402 #endif /* not USE_X_TOOLKIT */ 3410 #endif /* not USE_X_TOOLKIT */
3403 x_handle_property_notify (&event); 3411 x_handle_property_notify (&event);
3404 break; 3412 break;
3405 3413
3406 case ReparentNotify: 3414 case ReparentNotify:
3407 f = x_top_window_to_frame (event.xreparent.window); 3415 f = x_top_window_to_frame (dpyinfo, event.xreparent.window);
3408 if (f) 3416 if (f)
3409 { 3417 {
3410 int x, y; 3418 int x, y;
3411 f->display.x->parent_desc = event.xreparent.parent; 3419 f->display.x->parent_desc = event.xreparent.parent;
3412 x_real_positions (f, &x, &y); 3420 x_real_positions (f, &x, &y);
3414 f->display.x->top_pos = y; 3422 f->display.x->top_pos = y;
3415 } 3423 }
3416 break; 3424 break;
3417 3425
3418 case Expose: 3426 case Expose:
3419 f = x_window_to_frame (event.xexpose.window); 3427 f = x_window_to_frame (dpyinfo, event.xexpose.window);
3420 if (f) 3428 if (f)
3421 { 3429 {
3422 if (f->async_visible == 0) 3430 if (f->async_visible == 0)
3423 { 3431 {
3424 f->async_visible = 1; 3432 f->async_visible = 1;
3425 f->async_iconified = 0; 3433 f->async_iconified = 0;
3426 SET_FRAME_GARBAGED (f); 3434 SET_FRAME_GARBAGED (f);
3427 } 3435 }
3428 else 3436 else
3429 dumprectangle (x_window_to_frame (event.xexpose.window), 3437 dumprectangle (x_window_to_frame (dpyinfo,
3438 event.xexpose.window),
3430 event.xexpose.x, event.xexpose.y, 3439 event.xexpose.x, event.xexpose.y,
3431 event.xexpose.width, event.xexpose.height); 3440 event.xexpose.width, event.xexpose.height);
3432 } 3441 }
3433 else 3442 else
3434 { 3443 {
3445 break; 3454 break;
3446 3455
3447 case GraphicsExpose: /* This occurs when an XCopyArea's 3456 case GraphicsExpose: /* This occurs when an XCopyArea's
3448 source area was obscured or not 3457 source area was obscured or not
3449 available.*/ 3458 available.*/
3450 f = x_window_to_frame (event.xgraphicsexpose.drawable); 3459 f = x_window_to_frame (dpyinfo, event.xgraphicsexpose.drawable);
3451 if (f) 3460 if (f)
3452 { 3461 {
3453 dumprectangle (f, 3462 dumprectangle (f,
3454 event.xgraphicsexpose.x, event.xgraphicsexpose.y, 3463 event.xgraphicsexpose.x, event.xgraphicsexpose.y,
3455 event.xgraphicsexpose.width, 3464 event.xgraphicsexpose.width,
3465 source area was completely 3474 source area was completely
3466 available */ 3475 available */
3467 break; 3476 break;
3468 3477
3469 case UnmapNotify: 3478 case UnmapNotify:
3470 f = x_any_window_to_frame (event.xunmap.window); 3479 f = x_any_window_to_frame (dpyinfo, event.xunmap.window);
3471 if (f) /* F may no longer exist if 3480 if (f) /* F may no longer exist if
3472 the frame was deleted. */ 3481 the frame was deleted. */
3473 { 3482 {
3474 /* While a frame is unmapped, display generation is 3483 /* While a frame is unmapped, display generation is
3475 disabled; you don't want to spend time updating a 3484 disabled; you don't want to spend time updating a
3494 break; 3503 break;
3495 3504
3496 case MapNotify: 3505 case MapNotify:
3497 /* We use x_top_window_to_frame because map events can come 3506 /* We use x_top_window_to_frame because map events can come
3498 for subwindows and they don't mean that the frame is visible. */ 3507 for subwindows and they don't mean that the frame is visible. */
3499 f = x_top_window_to_frame (event.xmap.window); 3508 f = x_top_window_to_frame (dpyinfo, event.xmap.window);
3500 if (f) 3509 if (f)
3501 { 3510 {
3502 f->async_visible = 1; 3511 f->async_visible = 1;
3503 f->async_iconified = 0; 3512 f->async_iconified = 0;
3504 3513
3520 /* Turn off processing if we become fully obscured. */ 3529 /* Turn off processing if we become fully obscured. */
3521 case VisibilityNotify: 3530 case VisibilityNotify:
3522 break; 3531 break;
3523 3532
3524 case KeyPress: 3533 case KeyPress:
3525 f = x_any_window_to_frame (event.xkey.window); 3534 f = x_any_window_to_frame (dpyinfo, event.xkey.window);
3526 3535
3527 if (f != 0) 3536 if (f != 0)
3528 { 3537 {
3529 KeySym keysym, orig_keysym; 3538 KeySym keysym, orig_keysym;
3530 /* al%imercury@uunet.uu.net says that making this 81 instead of 3539 /* al%imercury@uunet.uu.net says that making this 81 instead of
3664 FocusIn event, you have to get a FocusOut event before you 3673 FocusIn event, you have to get a FocusOut event before you
3665 relinquish the focus. If you haven't received a FocusIn event, 3674 relinquish the focus. If you haven't received a FocusIn event,
3666 then a mere LeaveNotify is enough to free you. */ 3675 then a mere LeaveNotify is enough to free you. */
3667 3676
3668 case EnterNotify: 3677 case EnterNotify:
3669 f = x_any_window_to_frame (event.xcrossing.window); 3678 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
3670 3679
3671 if (event.xcrossing.focus) /* Entered Window */ 3680 if (event.xcrossing.focus) /* Entered Window */
3672 { 3681 {
3673 /* Avoid nasty pop/raise loops. */ 3682 /* Avoid nasty pop/raise loops. */
3674 if (f && (!(f->auto_raise) 3683 if (f && (!(f->auto_raise)
3689 goto OTHER; 3698 goto OTHER;
3690 #endif /* USE_X_TOOLKIT */ 3699 #endif /* USE_X_TOOLKIT */
3691 break; 3700 break;
3692 3701
3693 case FocusIn: 3702 case FocusIn:
3694 f = x_any_window_to_frame (event.xfocus.window); 3703 f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
3695 if (event.xfocus.detail != NotifyPointer) 3704 if (event.xfocus.detail != NotifyPointer)
3696 x_focus_event_frame = f; 3705 x_focus_event_frame = f;
3697 if (f) 3706 if (f)
3698 x_new_focus_frame (f); 3707 x_new_focus_frame (f);
3699 #ifdef USE_X_TOOLKIT 3708 #ifdef USE_X_TOOLKIT
3701 #endif /* USE_X_TOOLKIT */ 3710 #endif /* USE_X_TOOLKIT */
3702 break; 3711 break;
3703 3712
3704 3713
3705 case LeaveNotify: 3714 case LeaveNotify:
3706 f = x_top_window_to_frame (event.xcrossing.window); 3715 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
3707 if (f) 3716 if (f)
3708 { 3717 {
3709 if (f == dpyinfo->mouse_face_mouse_frame) 3718 if (f == dpyinfo->mouse_face_mouse_frame)
3710 /* If we move outside the frame, 3719 /* If we move outside the frame,
3711 then we're certainly no longer on any text in the frame. */ 3720 then we're certainly no longer on any text in the frame. */
3725 goto OTHER; 3734 goto OTHER;
3726 #endif /* USE_X_TOOLKIT */ 3735 #endif /* USE_X_TOOLKIT */
3727 break; 3736 break;
3728 3737
3729 case FocusOut: 3738 case FocusOut:
3730 f = x_any_window_to_frame (event.xfocus.window); 3739 f = x_any_window_to_frame (dpyinfo, event.xfocus.window);
3731 if (event.xfocus.detail != NotifyPointer 3740 if (event.xfocus.detail != NotifyPointer
3732 && f == x_focus_event_frame) 3741 && f == x_focus_event_frame)
3733 x_focus_event_frame = 0; 3742 x_focus_event_frame = 0;
3734 if (f && f == x_focus_frame) 3743 if (f && f == x_focus_frame)
3735 x_new_focus_frame (0); 3744 x_new_focus_frame (0);
3742 { 3751 {
3743 if (dpyinfo->grabbed && last_mouse_frame 3752 if (dpyinfo->grabbed && last_mouse_frame
3744 && FRAME_LIVE_P (last_mouse_frame)) 3753 && FRAME_LIVE_P (last_mouse_frame))
3745 f = last_mouse_frame; 3754 f = last_mouse_frame;
3746 else 3755 else
3747 f = x_window_to_frame (event.xmotion.window); 3756 f = x_window_to_frame (dpyinfo, event.xmotion.window);
3748 if (f) 3757 if (f)
3749 note_mouse_movement (f, &event.xmotion); 3758 note_mouse_movement (f, &event.xmotion);
3750 else 3759 else
3751 { 3760 {
3752 struct scroll_bar *bar 3761 struct scroll_bar *bar
3769 #endif /* USE_X_TOOLKIT */ 3778 #endif /* USE_X_TOOLKIT */
3770 #endif 3779 #endif
3771 break; 3780 break;
3772 3781
3773 case ConfigureNotify: 3782 case ConfigureNotify:
3774 f = x_any_window_to_frame (event.xconfigure.window); 3783 f = x_any_window_to_frame (dpyinfo, event.xconfigure.window);
3775 #ifdef USE_X_TOOLKIT 3784 #ifdef USE_X_TOOLKIT
3776 if (f 3785 if (f
3777 #if 0 3786 #if 0
3778 && ! event.xconfigure.send_event 3787 && ! event.xconfigure.send_event
3779 #endif 3788 #endif
3899 3908
3900 if (dpyinfo->grabbed && last_mouse_frame 3909 if (dpyinfo->grabbed && last_mouse_frame
3901 && FRAME_LIVE_P (last_mouse_frame)) 3910 && FRAME_LIVE_P (last_mouse_frame))
3902 f = last_mouse_frame; 3911 f = last_mouse_frame;
3903 else 3912 else
3904 f = x_window_to_frame (event.xmotion.window); 3913 f = x_window_to_frame (dpyinfo, event.xmotion.window);
3905 3914
3906 if (f) 3915 if (f)
3907 { 3916 {
3908 if (!x_focus_frame || (f == x_focus_frame)) 3917 if (!x_focus_frame || (f == x_focus_frame))
3909 construct_mouse_click (&emacs_event, &event, f); 3918 construct_mouse_click (&emacs_event, &event, f);