move client creation to maprequest_handler
This commit is contained in:
parent
3375a1af46
commit
a80fcebf04
83
handler.c
83
handler.c
@ -149,13 +149,23 @@ void wm_keypress_handler(Wm *wm, XKeyPressedEvent e)
|
||||
|
||||
void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
|
||||
{
|
||||
DEBUG_PRINT("MapRequest event\n")
|
||||
DEBUG_PRINT("MapRequest event\n");
|
||||
|
||||
if (e.window == wm->root.window)
|
||||
fprintf(stderr, "%s e.window was root\n", __func__);
|
||||
if (e.window == wm->root.window) {
|
||||
fprintf(stderr, "%s e.window was root, returning\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
Client *c;
|
||||
|
||||
if (wm_window_is_dock(wm, e.window))
|
||||
{
|
||||
DEBUG_PRINT("%s: window is dock, mapping window\n", __func__)
|
||||
wm->dock = e.window;
|
||||
XMapWindow(wm->display, e.window);
|
||||
return;
|
||||
}
|
||||
|
||||
c = wm_client_find(wm, e.window);
|
||||
if (c) {
|
||||
DEBUG_PRINT("%s: client found, mapping window\n", __func__)
|
||||
@ -164,18 +174,14 @@ void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
|
||||
return;
|
||||
}
|
||||
|
||||
if (wm_window_is_dock(wm, e.window))
|
||||
{
|
||||
DEBUG_PRINT("%s: window is dock, mapping window\n", __func__)
|
||||
XMapWindow(wm->display, e.window);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("%s: client not found, creating client\n", __func__)
|
||||
|
||||
c = wm_client_create(wm, e.window);
|
||||
RETURN_IF_NULL(c)
|
||||
//XMapWindow(wm->display, c->window);
|
||||
RETURN_IF_NULL(c);
|
||||
|
||||
wm_client_handle_window_types(wm, c, e);
|
||||
|
||||
wm_layout(wm, c->m);
|
||||
}
|
||||
|
||||
@ -194,50 +200,17 @@ void wm_motion_handler(Wm *wm, XMotionEvent e)
|
||||
void wm_configure_handler(Wm *wm, XConfigureRequestEvent e)
|
||||
{
|
||||
DEBUG_PRINT("ConfigureRequest event\n");
|
||||
Client *c;
|
||||
unsigned char *prop_ret;
|
||||
unsigned long nitems_ret;
|
||||
Atom type;
|
||||
bool is_normal = false;
|
||||
XTextProperty xtp;
|
||||
|
||||
c = wm_client_create(wm, e.window);
|
||||
Client *c;
|
||||
XWindowChanges wc;
|
||||
|
||||
XGetWMName(wm->display, e.window, &xtp);
|
||||
|
||||
DEBUG_PRINT("%s: created window %d name: %s\n", __func__, (int)e.window, xtp.value);
|
||||
|
||||
//XFree(xtp);
|
||||
|
||||
char *name = "_NET_WM_WINDOW_TYPE";
|
||||
type = wm_client_get_atom(wm, c, "_NET_WM_WINDOW_TYPE", &prop_ret, &nitems_ret);
|
||||
|
||||
if (type == -1) {
|
||||
fprintf(stderr, "wm_client_get_atom failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nitems_ret; i++) {
|
||||
DEBUG_PRINT("ConfigureRequest handler: window %d has property %s\n",
|
||||
(int)e.window, XGetAtomName(wm->display, ((Atom*)prop_ret)[i]));
|
||||
if (strcmp(XGetAtomName(wm->display, ((Atom*)prop_ret)[i]),
|
||||
"_NET_WM_WINDOW_TYPE_NORMAL") == 0) {
|
||||
is_normal = true;
|
||||
} else if (strcmp(XGetAtomName(wm->display, ((Atom*)prop_ret)[i]),
|
||||
"_NET_WM_WINDOW_TYPE_DOCK") == 0) {
|
||||
wm->dock = e.window;
|
||||
} else if (strcmp(XGetAtomName(wm->display, ((Atom*)prop_ret)[i]),
|
||||
"_NET_WM_WINDOW_TYPE_DIALOG") == 0) {
|
||||
c->is_floating = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_normal) {
|
||||
DEBUG_PRINT("configure handler: window %d is not normal, returning\n",
|
||||
(int)e.window)
|
||||
wm_client_free(wm, c);
|
||||
return;
|
||||
}
|
||||
|
||||
wm_layout(wm, c->m);
|
||||
wc.x = e.x;
|
||||
wc.y = e.y;
|
||||
wc.width = e.width;
|
||||
wc.height = e.height;
|
||||
wc.border_width = e.border_width;
|
||||
wc.sibling = e.above;
|
||||
wc.stack_mode = e.detail;
|
||||
XConfigureWindow(wm->display, e.window, e.value_mask, &wc);
|
||||
XSync(wm->display, False);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user