move client creation to maprequest_handler
This commit is contained in:
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)
|
void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("MapRequest event\n")
|
DEBUG_PRINT("MapRequest event\n");
|
||||||
|
|
||||||
if (e.window == wm->root.window)
|
if (e.window == wm->root.window) {
|
||||||
fprintf(stderr, "%s e.window was root\n", __func__);
|
fprintf(stderr, "%s e.window was root, returning\n", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Client *c;
|
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);
|
c = wm_client_find(wm, e.window);
|
||||||
if (c) {
|
if (c) {
|
||||||
DEBUG_PRINT("%s: client found, mapping window\n", __func__)
|
DEBUG_PRINT("%s: client found, mapping window\n", __func__)
|
||||||
@ -164,18 +174,14 @@ void wm_maprequest_handler(Wm *wm, XMapRequestEvent e)
|
|||||||
return;
|
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__)
|
DEBUG_PRINT("%s: client not found, creating client\n", __func__)
|
||||||
|
|
||||||
c = wm_client_create(wm, e.window);
|
c = wm_client_create(wm, e.window);
|
||||||
RETURN_IF_NULL(c)
|
RETURN_IF_NULL(c);
|
||||||
//XMapWindow(wm->display, c->window);
|
|
||||||
|
wm_client_handle_window_types(wm, c, e);
|
||||||
|
|
||||||
wm_layout(wm, c->m);
|
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)
|
void wm_configure_handler(Wm *wm, XConfigureRequestEvent e)
|
||||||
{
|
{
|
||||||
DEBUG_PRINT("ConfigureRequest event\n");
|
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);
|
wc.x = e.x;
|
||||||
|
wc.y = e.y;
|
||||||
DEBUG_PRINT("%s: created window %d name: %s\n", __func__, (int)e.window, xtp.value);
|
wc.width = e.width;
|
||||||
|
wc.height = e.height;
|
||||||
//XFree(xtp);
|
wc.border_width = e.border_width;
|
||||||
|
wc.sibling = e.above;
|
||||||
char *name = "_NET_WM_WINDOW_TYPE";
|
wc.stack_mode = e.detail;
|
||||||
type = wm_client_get_atom(wm, c, "_NET_WM_WINDOW_TYPE", &prop_ret, &nitems_ret);
|
XConfigureWindow(wm->display, e.window, e.value_mask, &wc);
|
||||||
|
XSync(wm->display, False);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user