Skip to content

Commit

Permalink
Revert WM_TAKE_FOCUS; not seen any example of application relying on …
Browse files Browse the repository at this point in the history
…it though
  • Loading branch information
iacore committed Mar 8, 2022
1 parent f357b3c commit 216e89f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions gui-agent/vmside.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,29 +1775,29 @@ static void handle_crossing(Ghandles * g, XID winid)

}

// static void take_focus(Ghandles * g, XID winid)
// {
// // Send
// XClientMessageEvent ev;
// memset(&ev, 0, sizeof(ev));
// ev.type = ClientMessage;
// ev.display = g->display;
// ev.window = winid;
// ev.format = 32;
// ev.message_type = g->wmProtocols;
// ev.data.l[0] = g->wm_take_focus;
// ev.data.l[1] = g->time;
// XSendEvent(ev.display, ev.window, 1, 0, (XEvent *) & ev);
// if (g->log_level > 0)
// fprintf(stderr, "WM_TAKE_FOCUS sent for 0x%x\n",
// (int) winid);

// }
static void take_focus(Ghandles * g, XID winid)
{
// Send
XClientMessageEvent ev;
memset(&ev, 0, sizeof(ev));
ev.type = ClientMessage;
ev.display = g->display;
ev.window = winid;
ev.format = 32;
ev.message_type = g->wmProtocols;
ev.data.l[0] = g->wm_take_focus;
ev.data.l[1] = g->time;
XSendEvent(ev.display, ev.window, 1, 0, (XEvent *) & ev);
if (g->log_level > 0)
fprintf(stderr, "WM_TAKE_FOCUS sent for 0x%x\n",
(int) winid);
}

static void handle_focus(Ghandles * g, XID winid)
{
struct msg_focus key;
struct genlist *l;
int use_take_focus = false;

read_data(g->vchan, (char *) &key, sizeof(key));
if (key.type == FocusIn) {
Expand All @@ -1807,13 +1807,18 @@ static void handle_focus(Ghandles * g, XID winid)
} else return;

if ( (l=list_lookup(windows_list, winid)) && (l->data) ) {
use_take_focus = ((struct window_data*)l->data)->support_take_focus;
if (((struct window_data*)l->data)->is_docked)
if (key.detail == NotifyNormal)
XRaiseWindow(g->display, ((struct window_data*)l->data)->embeder);
} else {
fprintf(stderr, "WARNING handle_focus: Window 0x%x data not initialized", (int)winid);
}

// Do not send WM_TAKE_FOCUS if the window doesn't support it
if (use_take_focus)
take_focus(g, winid);

if (g->log_level > 1)
fprintf(stderr, "0x%x raised\n", (int) winid);
} else if (key.type == FocusOut) {
Expand Down

0 comments on commit 216e89f

Please sign in to comment.