Compare commits

...

4 Commits

3 changed files with 32 additions and 27 deletions

View File

@ -18,6 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "client.h"
#include "wm.h"
#include <X11/X.h>
#include <X11/Xlib.h>
// TODO
XWindowChanges wm_client_to_xwchanges(Client c)
@ -48,6 +51,7 @@ Client* wm_client_find(Wm *wm, Window w)
Client* wm_client_create(Wm *wm, Window w)
{
DEBUG_PRINT("%s\n", __func__);
Client *t;
XTextProperty xtp;
int strln;
@ -56,6 +60,8 @@ Client* wm_client_create(Wm *wm, Window w)
Client *c = malloc(sizeof(Client));
c->next = NULL;
c->prev = NULL;
c->window = w;
c->m = wm->smon;
c->ws = wm->smon->selws;
@ -71,7 +77,6 @@ Client* wm_client_create(Wm *wm, Window w)
if (wm->smon->clients == NULL) {
wm->smon->clients = c;
c->prev = NULL;
} else {
t = wm_get_last_client(wm, *c->m);
//c = &root;
@ -167,12 +172,25 @@ void wm_client_free(Wm *wm, Client *c)
void wm_client_kill(Wm *wm, Client *c)
{
DEBUG_PRINT("%s\n", __func__);
RETURN_IF_NULL(c);
Monitor *m;
m = c->m;
XDestroyWindow(wm->display, c->window);
XEvent event;
Atom delete_atom = XInternAtom(wm->display, "WM_DELETE_WINDOW", False);
event.type = ClientMessage;
event.xclient.window = c->window;
event.xclient.display = wm->display;
event.xclient.message_type = delete_atom;
event.xclient.format = 32;
event.xclient.data.l[0] = delete_atom;
if (XSendEvent(wm->display, c->window, false, NoEventMask, &event) != Success)
XKillClient(wm->display, c->window);
wm_client_free(wm, c);
wm_layout(wm, m);

View File

@ -108,33 +108,16 @@ void wm_create_handler(Wm *wm, XCreateWindowEvent e)
//wm_client_focus(c);
}
// TODO
void wm_destroy_handler(Wm *wm, XDestroyWindowEvent e)
{
DEBUG_PRINT("DestroyNotify event\n");
Client *c;
// TODO: make function for linked list management
for (c = wm->smon->clients; c; c = c->next) {
if (e.window == c->window) {
if (c == wm->smon->clients) {
if (c->next)
wm->smon->clients = c->next;
else
wm->smon->clients = NULL;
} else {
if (!c->next)
c->prev->next = NULL;
else {
c->prev->next = c->next;
c->next->prev = c->prev;
}
}
free(c);
}
}
c = wm_client_find(wm, e.window);
if (!c)
return;
wm_client_free(wm, c);
}
void wm_reparent_handler(XReparentEvent e)
@ -142,8 +125,6 @@ void wm_reparent_handler(XReparentEvent e)
DEBUG_PRINT("ReparentNotify event\n");
}
void wm_keyrelease_handler(XKeyReleasedEvent e)
{
DEBUG_PRINT("KeyReleased event, code: %d\n", e.keycode)

10
wm.c
View File

@ -199,7 +199,13 @@ void wm_mstack(Wm *wm, Monitor *m)
}
}
//DEBUG_PRINT("mstack cc_sws: %d\n", cc_sws)
DEBUG_PRINT("mstack cc_sws: %d\n", cc_sws)
if (cc_sws <= 0) {
DEBUG_PRINT("mstack cc_sws <= 0, returning\n")
return;
}
// dynamic
if (cc_sws == 1) {
for (c = m->clients; c; c = c->next) {
@ -220,7 +226,7 @@ void wm_mstack(Wm *wm, Monitor *m)
XConfigureWindow(wm->display, c->window, value_mask, &ch);
wm_client_show(wm, c);
//wm_client_focus(c);
wm_client_focus(wm, c);
}
else {
// FIXME not working with dock