Skip to content

Commit 216e89f

Browse files
committed
Revert WM_TAKE_FOCUS; not seen any example of application relying on it though
1 parent f357b3c commit 216e89f

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

gui-agent/vmside.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,29 +1775,29 @@ static void handle_crossing(Ghandles * g, XID winid)
17751775

17761776
}
17771777

1778-
// static void take_focus(Ghandles * g, XID winid)
1779-
// {
1780-
// // Send
1781-
// XClientMessageEvent ev;
1782-
// memset(&ev, 0, sizeof(ev));
1783-
// ev.type = ClientMessage;
1784-
// ev.display = g->display;
1785-
// ev.window = winid;
1786-
// ev.format = 32;
1787-
// ev.message_type = g->wmProtocols;
1788-
// ev.data.l[0] = g->wm_take_focus;
1789-
// ev.data.l[1] = g->time;
1790-
// XSendEvent(ev.display, ev.window, 1, 0, (XEvent *) & ev);
1791-
// if (g->log_level > 0)
1792-
// fprintf(stderr, "WM_TAKE_FOCUS sent for 0x%x\n",
1793-
// (int) winid);
1794-
1795-
// }
1778+
static void take_focus(Ghandles * g, XID winid)
1779+
{
1780+
// Send
1781+
XClientMessageEvent ev;
1782+
memset(&ev, 0, sizeof(ev));
1783+
ev.type = ClientMessage;
1784+
ev.display = g->display;
1785+
ev.window = winid;
1786+
ev.format = 32;
1787+
ev.message_type = g->wmProtocols;
1788+
ev.data.l[0] = g->wm_take_focus;
1789+
ev.data.l[1] = g->time;
1790+
XSendEvent(ev.display, ev.window, 1, 0, (XEvent *) & ev);
1791+
if (g->log_level > 0)
1792+
fprintf(stderr, "WM_TAKE_FOCUS sent for 0x%x\n",
1793+
(int) winid);
1794+
}
17961795

17971796
static void handle_focus(Ghandles * g, XID winid)
17981797
{
17991798
struct msg_focus key;
18001799
struct genlist *l;
1800+
int use_take_focus = false;
18011801

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

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

1818+
// Do not send WM_TAKE_FOCUS if the window doesn't support it
1819+
if (use_take_focus)
1820+
take_focus(g, winid);
1821+
18171822
if (g->log_level > 1)
18181823
fprintf(stderr, "0x%x raised\n", (int) winid);
18191824
} else if (key.type == FocusOut) {

0 commit comments

Comments
 (0)