add function to handle window types
This commit is contained in:
parent
02d598107b
commit
3375a1af46
56
client.c
56
client.c
@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "wm.h"
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
// TODO
|
||||
XWindowChanges wm_client_to_xwchanges(Client c)
|
||||
@ -93,6 +96,49 @@ Client* wm_client_create(Wm *wm, Window w)
|
||||
return c;
|
||||
}
|
||||
|
||||
void wm_client_handle_window_types(Wm *wm, Client *c, XMapRequestEvent e)
|
||||
{
|
||||
DEBUG_PRINT("%s\n", __func__);
|
||||
RETURN_IF_NULL(c);
|
||||
|
||||
unsigned char *prop_ret;
|
||||
unsigned long nitems_ret;
|
||||
Atom type;
|
||||
bool is_normal = false;
|
||||
|
||||
type = wm_client_get_atom(wm, c, "_NET_WM_WINDOW_TYPE", &prop_ret, &nitems_ret);
|
||||
|
||||
if (type == ULONG_MAX) {
|
||||
fprintf(stderr, "wm_client_get_atom failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t 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;
|
||||
fprintf(stderr, "client should not have _NET_WM_WINDOW_TYPE_DOCK type\n");
|
||||
// todo function to exit
|
||||
exit(1);
|
||||
} 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\n",
|
||||
(int)e.window)
|
||||
// wm_client_kill(wm, c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void wm_client_hide(Wm *wm, Client *c)
|
||||
{
|
||||
RETURN_IF_NULL(c);
|
||||
@ -212,13 +258,13 @@ Atom wm_client_get_atom(Wm *wm, Client *c, const char *name, unsigned char **ato
|
||||
unsigned long *nitems_ret)
|
||||
{
|
||||
if (!c)
|
||||
return -1;
|
||||
return ULONG_MAX;
|
||||
if (!name)
|
||||
return -1;
|
||||
return ULONG_MAX;
|
||||
if (!atom_ret)
|
||||
return -1;
|
||||
return ULONG_MAX;
|
||||
if (!nitems_ret)
|
||||
return -1;
|
||||
return ULONG_MAX;
|
||||
|
||||
Atom type_ret;
|
||||
int format_ret;
|
||||
@ -232,7 +278,7 @@ Atom wm_client_get_atom(Wm *wm, Client *c, const char *name, unsigned char **ato
|
||||
|
||||
if (ret != Success || (nitems_ret == 0 && type_ret == 0)) {
|
||||
fprintf(stderr, "wm: XGetWindowProperty failed\n");
|
||||
return -1;
|
||||
return ULONG_MAX;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("XGetWindowProperty return values, window %d:\n", (int)c->window);
|
||||
|
1
client.h
1
client.h
@ -26,6 +26,7 @@ XWindowChanges wm_client_to_xwchanges(Client c);
|
||||
Client* wm_client_find(Wm* wm, Window w);
|
||||
Client *wm_get_last_client(Wm *wm, Monitor m);
|
||||
Client* wm_client_create(Wm *wm, Window w);
|
||||
void wm_client_handle_window_types(Wm *wm, Client *c, XMapRequestEvent e);
|
||||
void wm_client_hide(Wm *wm, Client *c);
|
||||
void wm_client_show(Wm* wm, Client *c);
|
||||
void wm_client_focus(Wm* wm, Client *c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user