comparison src/xterm.c @ 91630:f3b50ee54418

(x_detect_focus_change): Handle embed client message. (handle_one_xevent): Ditto. (handle_one_xevent): If embedded and we get a button press/release, request focus. (xembed_set_info, xembed_send_message): New functions. (x_make_frame_visible): Call xembed_set_info if embedded. (x_make_frame_invisible): Call xembed_set_info if embedded. (x_term_init): Initialize Xatom_XEMBED. (x_make_frame_visible): Check for FRAME_X_EMBEDDED_P also. (x_iconify_frame): Ditto.
author Jan Djärv <jan.h.d@swipnet.se>
date Thu, 07 Feb 2008 14:07:35 +0000
parents c70e45a7acfd
children b7a5a89054dc
comparison
equal deleted inserted replaced
91629:d2d6b0b017fa 91630:f3b50ee54418
3607 case FocusOut: 3607 case FocusOut:
3608 x_focus_changed (event->type, 3608 x_focus_changed (event->type,
3609 (event->xfocus.detail == NotifyPointer ? 3609 (event->xfocus.detail == NotifyPointer ?
3610 FOCUS_IMPLICIT : FOCUS_EXPLICIT), 3610 FOCUS_IMPLICIT : FOCUS_EXPLICIT),
3611 dpyinfo, frame, bufp); 3611 dpyinfo, frame, bufp);
3612 break;
3613
3614 case ClientMessage:
3615 if (event->xclient.message_type == dpyinfo->Xatom_XEMBED)
3616 {
3617 enum xembed_message msg = event->xclient.data.l[1];
3618 x_focus_changed ((msg == XEMBED_FOCUS_IN ? FocusIn : FocusOut),
3619 FOCUS_EXPLICIT, dpyinfo, frame, bufp);
3620 }
3612 break; 3621 break;
3613 } 3622 }
3614 } 3623 }
3615 3624
3616 3625
6198 x_scroll_bar_to_input_event (&event, &inev.ie); 6207 x_scroll_bar_to_input_event (&event, &inev.ie);
6199 *finish = X_EVENT_GOTO_OUT; 6208 *finish = X_EVENT_GOTO_OUT;
6200 goto done; 6209 goto done;
6201 } 6210 }
6202 #endif /* USE_TOOLKIT_SCROLL_BARS */ 6211 #endif /* USE_TOOLKIT_SCROLL_BARS */
6212
6213 /* XEmbed messages from the embedder (if any). */
6214 if (event.xclient.message_type
6215 == dpyinfo->Xatom_XEMBED)
6216 {
6217 enum xembed_message msg = event.xclient.data.l[1];
6218 if (msg == XEMBED_FOCUS_IN || msg == XEMBED_FOCUS_OUT)
6219 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6220
6221 *finish = X_EVENT_GOTO_OUT;
6222 goto done;
6223 }
6203 6224
6204 f = x_any_window_to_frame (dpyinfo, event.xclient.window); 6225 f = x_any_window_to_frame (dpyinfo, event.xclient.window);
6205 if (!f) 6226 if (!f)
6206 goto OTHER; 6227 goto OTHER;
6207 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev.ie)) 6228 if (x_handle_dnd_message (f, &event.xclient, dpyinfo, &inev.ie))
7084 ignore_next_mouse_click_timeout = 0; 7105 ignore_next_mouse_click_timeout = 0;
7085 } 7106 }
7086 else 7107 else
7087 construct_mouse_click (&inev.ie, &event.xbutton, f); 7108 construct_mouse_click (&inev.ie, &event.xbutton, f);
7088 } 7109 }
7110 if (FRAME_X_EMBEDDED_P (f))
7111 xembed_send_message (f, event.xbutton.time,
7112 XEMBED_REQUEST_FOCUS, 0, 0, 0);
7089 } 7113 }
7090 else 7114 else
7091 { 7115 {
7092 struct scroll_bar *bar 7116 struct scroll_bar *bar
7093 = x_window_to_scroll_bar (event.xbutton.display, 7117 = x_window_to_scroll_bar (event.xbutton.display,
9283 x_raise_frame (f); 9307 x_raise_frame (f);
9284 else 9308 else
9285 x_lower_frame (f); 9309 x_lower_frame (f);
9286 } 9310 }
9287 9311
9312 /* XEmbed implementation. */
9313
9314 void
9315 xembed_set_info (f, flags)
9316 struct frame *f;
9317 enum xembed_info flags;
9318 {
9319 Atom atom;
9320 unsigned long data[2];
9321
9322 atom = XInternAtom (FRAME_X_DISPLAY (f), "_XEMBED_INFO", False);
9323
9324 data[0] = XEMBED_VERSION;
9325 data[1] = flags;
9326
9327 XChangeProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), atom, atom,
9328 32, PropModeReplace, (unsigned char *) data, 2);
9329 }
9330
9331 void
9332 xembed_send_message (f, time, message, detail, data1, data2)
9333 struct frame *f;
9334 Time time;
9335 enum xembed_message message;
9336 long detail;
9337 long data1;
9338 long data2;
9339 {
9340 XEvent event;
9341
9342 event.xclient.type = ClientMessage;
9343 event.xclient.window = FRAME_X_OUTPUT (f)->parent_desc;
9344 event.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_XEMBED;
9345 event.xclient.format = 32;
9346 event.xclient.data.l[0] = time;
9347 event.xclient.data.l[1] = message;
9348 event.xclient.data.l[2] = detail;
9349 event.xclient.data.l[3] = data1;
9350 event.xclient.data.l[4] = data2;
9351
9352 XSendEvent (FRAME_X_DISPLAY (f), FRAME_X_OUTPUT (f)->parent_desc,
9353 False, NoEventMask, &event);
9354 XSync (FRAME_X_DISPLAY (f), False);
9355 }
9356
9288 /* Change of visibility. */ 9357 /* Change of visibility. */
9289 9358
9290 /* This tries to wait until the frame is really visible. 9359 /* This tries to wait until the frame is really visible.
9291 However, if the window manager asks the user where to position 9360 However, if the window manager asks the user where to position
9292 the frame, this will return before the user finishes doing that. 9361 the frame, this will return before the user finishes doing that.
9315 /* We test FRAME_GARBAGED_P here to make sure we don't 9384 /* We test FRAME_GARBAGED_P here to make sure we don't
9316 call x_set_offset a second time 9385 call x_set_offset a second time
9317 if we get to x_make_frame_visible a second time 9386 if we get to x_make_frame_visible a second time
9318 before the window gets really visible. */ 9387 before the window gets really visible. */
9319 if (! FRAME_ICONIFIED_P (f) 9388 if (! FRAME_ICONIFIED_P (f)
9389 && ! FRAME_X_EMBEDDED_P (f)
9320 && ! f->output_data.x->asked_for_visible) 9390 && ! f->output_data.x->asked_for_visible)
9321 x_set_offset (f, f->left_pos, f->top_pos, 0); 9391 x_set_offset (f, f->left_pos, f->top_pos, 0);
9322 9392
9323 f->output_data.x->asked_for_visible = 1; 9393 f->output_data.x->asked_for_visible = 1;
9324 9394
9325 if (! EQ (Vx_no_window_manager, Qt)) 9395 if (! EQ (Vx_no_window_manager, Qt))
9326 x_wm_set_window_state (f, NormalState); 9396 x_wm_set_window_state (f, NormalState);
9327 #ifdef USE_X_TOOLKIT 9397 #ifdef USE_X_TOOLKIT
9328 /* This was XtPopup, but that did nothing for an iconified frame. */ 9398 if (FRAME_X_EMBEDDED_P (f))
9329 XtMapWidget (f->output_data.x->widget); 9399 xembed_set_info (f, XEMBED_MAPPED);
9400 else
9401 {
9402 /* This was XtPopup, but that did nothing for an iconified frame. */
9403 XtMapWidget (f->output_data.x->widget);
9404 }
9330 #else /* not USE_X_TOOLKIT */ 9405 #else /* not USE_X_TOOLKIT */
9331 #ifdef USE_GTK 9406 #ifdef USE_GTK
9332 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); 9407 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f));
9333 gtk_window_deiconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 9408 gtk_window_deiconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
9334 #else 9409 #else
9335 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 9410 if (FRAME_X_EMBEDDED_P (f))
9411 xembed_set_info (f, XEMBED_MAPPED);
9412 else
9413 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
9336 #endif /* not USE_GTK */ 9414 #endif /* not USE_GTK */
9337 #endif /* not USE_X_TOOLKIT */ 9415 #endif /* not USE_X_TOOLKIT */
9338 #if 0 /* This seems to bring back scroll bars in the wrong places 9416 #if 0 /* This seems to bring back scroll bars in the wrong places
9339 if the window configuration has changed. They seem 9417 if the window configuration has changed. They seem
9340 to come back ok without this. */ 9418 to come back ok without this. */
9371 9449
9372 Don't do this if the window has never been visible before, 9450 Don't do this if the window has never been visible before,
9373 because the window manager may choose the position 9451 because the window manager may choose the position
9374 and we don't want to override it. */ 9452 and we don't want to override it. */
9375 9453
9376 if (! FRAME_VISIBLE_P (f) && ! FRAME_ICONIFIED_P (f) 9454 if (! FRAME_VISIBLE_P (f)
9455 && ! FRAME_ICONIFIED_P (f)
9456 && ! FRAME_X_EMBEDDED_P (f)
9377 && f->win_gravity == NorthWestGravity 9457 && f->win_gravity == NorthWestGravity
9378 && previously_visible) 9458 && previously_visible)
9379 { 9459 {
9380 Drawable rootw; 9460 Drawable rootw;
9381 int x, y; 9461 int x, y;
9482 9562
9483 #ifdef USE_GTK 9563 #ifdef USE_GTK
9484 if (FRAME_GTK_OUTER_WIDGET (f)) 9564 if (FRAME_GTK_OUTER_WIDGET (f))
9485 gtk_widget_hide (FRAME_GTK_OUTER_WIDGET (f)); 9565 gtk_widget_hide (FRAME_GTK_OUTER_WIDGET (f));
9486 else 9566 else
9567 #else
9568 if (FRAME_X_EMBEDDED_P (f))
9569 xembed_set_info (f, 0);
9570 else
9487 #endif 9571 #endif
9488 { 9572 {
9489 9573
9490 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, 9574 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window,
9491 DefaultScreen (FRAME_X_DISPLAY (f)))) 9575 DefaultScreen (FRAME_X_DISPLAY (f))))
9586 UNBLOCK_INPUT; 9670 UNBLOCK_INPUT;
9587 #else /* not USE_X_TOOLKIT */ 9671 #else /* not USE_X_TOOLKIT */
9588 9672
9589 /* Make sure the X server knows where the window should be positioned, 9673 /* Make sure the X server knows where the window should be positioned,
9590 in case the user deiconifies with the window manager. */ 9674 in case the user deiconifies with the window manager. */
9591 if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f)) 9675 if (! FRAME_VISIBLE_P (f)
9676 && ! FRAME_ICONIFIED_P (f)
9677 && ! FRAME_X_EMBEDDED_P (f))
9592 x_set_offset (f, f->left_pos, f->top_pos, 0); 9678 x_set_offset (f, f->left_pos, f->top_pos, 0);
9593 9679
9594 /* Since we don't know which revision of X we're running, we'll use both 9680 /* Since we don't know which revision of X we're running, we'll use both
9595 the X11R3 and X11R4 techniques. I don't know if this is a good idea. */ 9681 the X11R3 and X11R4 techniques. I don't know if this is a good idea. */
9596 9682
11397 dpyinfo->Xatom_DONE = XInternAtom (dpyinfo->display, "DONE", False); 11483 dpyinfo->Xatom_DONE = XInternAtom (dpyinfo->display, "DONE", False);
11398 11484
11399 dpyinfo->Xatom_Scrollbar = XInternAtom (dpyinfo->display, "SCROLLBAR", 11485 dpyinfo->Xatom_Scrollbar = XInternAtom (dpyinfo->display, "SCROLLBAR",
11400 False); 11486 False);
11401 11487
11488 dpyinfo->Xatom_XEMBED = XInternAtom (dpyinfo->display, "_XEMBED",
11489 False);
11490
11402 dpyinfo->cut_buffers_initialized = 0; 11491 dpyinfo->cut_buffers_initialized = 0;
11403 11492
11404 dpyinfo->x_dnd_atoms_size = 8; 11493 dpyinfo->x_dnd_atoms_size = 8;
11405 dpyinfo->x_dnd_atoms_length = 0; 11494 dpyinfo->x_dnd_atoms_length = 0;
11406 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) 11495 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)