From 60bd64e59e5ea8048893636e6d5f15c7c61c0ffd Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 9 Sep 2011 17:48:35 +0200 Subject: [PATCH] Work on tag frame --- wmfs2/src/client.c | 3 +-- wmfs2/src/config.c | 3 +-- wmfs2/src/event.c | 5 ++--- wmfs2/src/event.h | 2 +- wmfs2/src/infobar.c | 2 -- wmfs2/src/layout.c | 8 ++++++++ wmfs2/src/layout.h | 12 ++++++++++++ wmfs2/src/screen.c | 9 +++++---- wmfs2/src/tag.c | 26 ++++++++++++++++---------- wmfs2/src/wmfs.c | 17 ++++++++--------- 10 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 wmfs2/src/layout.c create mode 100644 wmfs2/src/layout.h diff --git a/wmfs2/src/client.c b/wmfs2/src/client.c index 6465272..e8b7c92 100644 --- a/wmfs2/src/client.c +++ b/wmfs2/src/client.c @@ -9,6 +9,7 @@ #include "config.h" #include "util.h" #include "barwin.h" +#include "ewmh.h" #define CLIENT_MOUSE_MOD Mod1Mask @@ -221,8 +222,6 @@ client_new(Window w, XWindowAttributes *wa) void client_remove(struct client *c) { - struct client *cc; - XGrabServer(W->dpy); XSetErrorHandler(wmfs_error_handler_dummy); XReparentWindow(W->dpy, c->win, W->root, c->geo.x, c->geo.y); diff --git a/wmfs2/src/config.c b/wmfs2/src/config.c index 65ac340..f037e1c 100644 --- a/wmfs2/src/config.c +++ b/wmfs2/src/config.c @@ -19,7 +19,6 @@ config_theme(void) struct theme *t; size_t i, n; struct conf_sec *sec, **ks; - char *name; /* [themes] */ sec = fetch_section_first(NULL, "themes"); @@ -96,7 +95,7 @@ config_bars(void) SLIST_FOREACH(s, &W->h.screen, next) if(screenid == s->id || screenid == -1) - (struct Infobar*)infobar_new(s, t, pos, elem); + infobar_new(s, t, pos, elem); } free(ks); diff --git a/wmfs2/src/event.c b/wmfs2/src/event.c index 6cac1d2..b5d4352 100644 --- a/wmfs2/src/event.c +++ b/wmfs2/src/event.c @@ -9,6 +9,7 @@ #include "wmfs.h" #include "client.h" #include "barwin.h" +#include "screen.h" #define EVDPY(e) (e)->xany.display @@ -104,8 +105,6 @@ event_destroynotify(XEvent *e) static void event_focusin(XEvent *e) { - struct client *c; - if(W->client && e->xfocus.window != W->client->win) client_focus(W->client); } @@ -246,7 +245,7 @@ event_init(void) event_handle[DestroyNotify] = event_destroynotify; event_handle[EnterNotify] = event_enternotify; event_handle[Expose] = event_expose; - /*event_handle[FocusIn] = event_focusin;*/ + event_handle[FocusIn] = event_focusin; event_handle[KeyPress] = event_keypress; /*event_handle[MapNotify] = event_mapnotify;*/ event_handle[MapRequest] = event_maprequest; diff --git a/wmfs2/src/event.h b/wmfs2/src/event.h index 3ee8942..b43e2e8 100644 --- a/wmfs2/src/event.h +++ b/wmfs2/src/event.h @@ -11,7 +11,7 @@ #define MAX_EV 256 #define KEYPRESS_MASK(m) (m & ~(W->numlockmask | LockMask)) -#define HANDLE_EVENT(e) event_handle[(e)->type](e); +#define EVENT_HANDLE(e) event_handle[(e)->type](e); void event_init(void); diff --git a/wmfs2/src/infobar.c b/wmfs2/src/infobar.c index 471e92d..b043263 100644 --- a/wmfs2/src/infobar.c +++ b/wmfs2/src/infobar.c @@ -171,8 +171,6 @@ struct infobar* infobar_new(struct screen *s, struct theme *theme, Barpos pos, const char *elem) { bool map; - int n; - struct infobar *i = (struct infobar*)xcalloc(1, sizeof(struct infobar)); i->screen = s; diff --git a/wmfs2/src/layout.c b/wmfs2/src/layout.c new file mode 100644 index 0000000..ae951c4 --- /dev/null +++ b/wmfs2/src/layout.c @@ -0,0 +1,8 @@ +/* + * wmfs2 by Martin Duquesnoy { for(i = 2011; i < 2111; ++i) ©(i); } + * For license, see COPYING. + */ + +#include "layout.h" + + diff --git a/wmfs2/src/layout.h b/wmfs2/src/layout.h new file mode 100644 index 0000000..d10e13e --- /dev/null +++ b/wmfs2/src/layout.h @@ -0,0 +1,12 @@ +/* + * wmfs2 by Martin Duquesnoy { for(i = 2011; i < 2111; ++i) ©(i); } + * For license, see COPYING. + */ + +#ifndef LAYOUT_H +#define LAYOUT_H + +#include "wmfs.h" + +#endif /* LAYOUT_H */ + diff --git a/wmfs2/src/screen.c b/wmfs2/src/screen.c index d88d847..c320ef6 100644 --- a/wmfs2/src/screen.c +++ b/wmfs2/src/screen.c @@ -37,7 +37,6 @@ screen_new(struct geo *g, int id) void screen_init(void) { - struct screen *s; struct geo g; SLIST_INIT(&W->h.screen); @@ -57,7 +56,7 @@ screen_init(void) g.w = xsi[i].width; g.h = xsi[i].height; - s = screen_new(&g, i); + screen_new(&g, i); } XFree(xsi); @@ -69,7 +68,7 @@ screen_init(void) g.w = DisplayWidth(W->dpy, W->xscreen); g.h = DisplayHeight(W->dpy, W->xscreen); - s = screen_new(&g, 0); + screen_new(&g, 0); } } @@ -92,9 +91,11 @@ screen_update_sel(void) if(INAREA(x, y, s->geo)) break; - W->screen = s; + return (W->screen = s); } #endif /* HAVE_XINERAMA */ + + return W->screen; } void diff --git a/wmfs2/src/tag.c b/wmfs2/src/tag.c index 9942f0e..cf1c899 100644 --- a/wmfs2/src/tag.c +++ b/wmfs2/src/tag.c @@ -11,6 +11,7 @@ #include "client.h" #include "config.h" #include "barwin.h" +#include "ewmh.h" struct tag* tag_new(struct screen *s, char *name) @@ -32,15 +33,15 @@ tag_new(struct screen *s, char *name) t->sel = NULL; /* Frame window */ - t->frame = XCreateWindow(W->dpy, W->root, - s->ugeo.x, s->ugeo.y, - s->ugeo.w, s->ugeo.h, - 0, CopyFromParent, - InputOutput, - CopyFromParent, - (CWOverrideRedirect | CWBackPixmap - | CWBackPixel | CWEventMask), - &at); + t->frame = XCreateWindow(W->dpy, W->root, + s->ugeo.x, s->ugeo.y, + s->ugeo.w, s->ugeo.h, + 0, CopyFromParent, + InputOutput, + CopyFromParent, + (CWOverrideRedirect | CWBackPixmap + | CWBackPixel | CWEventMask), + &at); SLIST_INIT(&t->clients); @@ -94,7 +95,10 @@ tag_client(struct tag *t, struct client *c) c->tag->sel = NULL; } - /* Case of client remove */ + /* + * Case of client removing: umap frame if empty + * TODO: arrange layout + */ if(!t) { /* Unmap frame if tag is now empty */ @@ -113,6 +117,8 @@ tag_client(struct tag *t, struct client *c) /* Reparent client win in frame win */ XReparentWindow(W->dpy, c->win, t->frame, 0, 0); + /* tag_frame_client */ + /* Insert in new tag list */ SLIST_INSERT_HEAD(&t->clients, c, tnext); } diff --git a/wmfs2/src/wmfs.c b/wmfs2/src/wmfs.c index 27c3266..3e3dc57 100644 --- a/wmfs2/src/wmfs.c +++ b/wmfs2/src/wmfs.c @@ -101,9 +101,13 @@ wmfs_init_font(char *font, struct theme *t) static void wmfs_xinit(void) { - int i, j; - XModifierKeymap *mm; - XSetWindowAttributes at; + XSetWindowAttributes at = + { + .event_mask = (KeyMask | ButtonMask | MouseMask + | PropertyChangeMask | SubstructureRedirectMask + | SubstructureNotifyMask | StructureNotifyMask), + .cursor = XCreateFontCursor(W->dpy, XC_left_ptr) + }; /* * X Error handler @@ -121,11 +125,6 @@ wmfs_xinit(void) * Root window/cursor */ W->root = RootWindow(W->dpy, W->xscreen); - - at.event_mask = KeyMask | ButtonMask | MouseMask | PropertyChangeMask - | SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask; - at.cursor = XCreateFontCursor(W->dpy, XC_left_ptr); - XChangeWindowAttributes(W->dpy, W->root, CWEventMask | CWCursor, &at); /* @@ -236,7 +235,7 @@ wmfs_loop(void) while(XPending(W->dpy)) while(W->running && !XNextEvent(W->dpy, &ev)) - HANDLE_EVENT(&ev); + EVENT_HANDLE(&ev); } static inline void