Add frame.c/h
This commit is contained in:
@@ -63,23 +63,23 @@ client_unmap(Client *c)
|
||||
static void
|
||||
client_grabbuttons(Client *c, bool focused)
|
||||
{
|
||||
int i, but[] = {Button1, Button2, Button3, Button4, Button5};
|
||||
|
||||
wmfs_numlockmask();
|
||||
|
||||
XUngrabButton(W->dpy, AnyButton, AnyModifier, c->win);
|
||||
|
||||
if(focused)
|
||||
{
|
||||
for(i = 0; i < LEN(but); ++i)
|
||||
int i = 0;
|
||||
|
||||
while(i++ != Button5)
|
||||
{
|
||||
XGrabButton(W->dpy, but[i], CLIENT_MOUSE_MOD, c->win, False,
|
||||
XGrabButton(W->dpy, i, CLIENT_MOUSE_MOD, c->win, False,
|
||||
ButtonMask, GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(W->dpy, but[i], CLIENT_MOUSE_MOD | LockMask, c->win, False,
|
||||
XGrabButton(W->dpy, i, CLIENT_MOUSE_MOD | LockMask, c->win, False,
|
||||
ButtonMask, GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(W->dpy, but[i], CLIENT_MOUSE_MOD | W->numlockmask, c->win, False,
|
||||
XGrabButton(W->dpy, i, CLIENT_MOUSE_MOD | W->numlockmask, c->win, False,
|
||||
ButtonMask, GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(W->dpy, but[i], CLIENT_MOUSE_MOD | LockMask | W->numlockmask, c->win, False,
|
||||
XGrabButton(W->dpy, i, CLIENT_MOUSE_MOD | LockMask | W->numlockmask, c->win, False,
|
||||
ButtonMask, GrabModeAsync, GrabModeSync, None, None);
|
||||
}
|
||||
|
||||
@@ -236,11 +236,11 @@ client_remove(Client *c)
|
||||
if(W->client == c)
|
||||
client_focus(NULL);
|
||||
|
||||
SLIST_REMOVE(&W->h.client, c, Client, next);
|
||||
|
||||
if(c->tag->sel == c)
|
||||
c->tag->sel = SLIST_FIRST(&c->tag->clients);
|
||||
|
||||
SLIST_REMOVE(&W->h.client, c, Client, next);
|
||||
|
||||
tag_client(NULL, c);
|
||||
|
||||
XSync(W->dpy, False);
|
||||
|
||||
@@ -246,7 +246,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;
|
||||
|
||||
85
wmfs2/src/frame.c
Normal file
85
wmfs2/src/frame.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
#include "wmfs.h"
|
||||
#include "frame.h"
|
||||
#include "barwin.h"
|
||||
#include "tag.h"
|
||||
#include "util.h"
|
||||
|
||||
Frame*
|
||||
frame_new(Tag *t)
|
||||
{
|
||||
Geo g = t->screen->ugeo;
|
||||
Frame *f = xcalloc(1, sizeof(Frame));
|
||||
XSetWindowAttributes at =
|
||||
{
|
||||
.override_redirect = True,
|
||||
.background_pixmap = ParentRelative,
|
||||
.event_mask = (BARWIN_MASK | BARWIN_ENTERMASK)
|
||||
};
|
||||
|
||||
f->tag = t;
|
||||
f->geo = g;
|
||||
|
||||
f->win = XCreateWindow(W->dpy, W->root, g.x, g.y, g.w, g.h, 0, W->xdepth,
|
||||
CopyFromParent, DefaultVisual(W->dpy, W->xscreen),
|
||||
(CWOverrideRedirect | CWEventMask), &at);
|
||||
|
||||
SLIST_INIT(&f->clients);
|
||||
|
||||
SLIST_INSERT_HEAD(&t->frames, f, next);
|
||||
}
|
||||
|
||||
static void
|
||||
frame_remove(Frame *f)
|
||||
{
|
||||
SLIST_REMOVE(&f->tag->frames, f, Frame, next);
|
||||
XDestroyWindow(W->dpy, f->win);
|
||||
|
||||
/* frame_arrange(f->tag); */
|
||||
free(f);
|
||||
}
|
||||
|
||||
void
|
||||
frame_free(Tag *t)
|
||||
{
|
||||
Frame *f;
|
||||
|
||||
SLIST_FOREACH(f, &t->frames, next)
|
||||
frame_remove(f);
|
||||
}
|
||||
|
||||
void
|
||||
frame_client(Frame *f, Client *c)
|
||||
{
|
||||
/* Remove client from its previous frame */
|
||||
if(c->frame)
|
||||
SLIST_REMOVE(&c->frame->clients, c, Client, fnext);
|
||||
|
||||
/* Adjust tag with frame's one */
|
||||
if(f->tag != c->tag)
|
||||
tag_client(f->tag, c);
|
||||
|
||||
XReparentWindow(W->dpy, c->win, f->win, 1, 1);
|
||||
|
||||
/* XReparentWindow(W->dpy, c->win, c->titlebar->win, 1, 1); */
|
||||
|
||||
SLIST_INSERT_HEAD(&f->clients, c, next);
|
||||
}
|
||||
|
||||
void
|
||||
frame_update(Frame *f)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
15
wmfs2/src/frame.h
Normal file
15
wmfs2/src/frame.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
#ifndef FRAME_H
|
||||
#define FRAME_H
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
Frame *frame_new(Tag *t);
|
||||
void frame_free(Tag *t);
|
||||
void frame_update(Frame *f);
|
||||
|
||||
#endif /* FRAME_H */
|
||||
@@ -110,6 +110,7 @@ infobar_elem_tag_update(Element *e)
|
||||
barwin_refresh(b);
|
||||
}
|
||||
|
||||
e->infobar->screen->elemupdate &= ~FLAGINT(ElemTag);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -180,7 +181,7 @@ infobar_new(Scr33n *s, Theme *theme, Barpos pos, const char *elem)
|
||||
i->theme = theme;
|
||||
i->elemorder = xstrdup(elem);
|
||||
|
||||
map = infobar_placement(i, (i->pos = pos));
|
||||
map = infobar_placement(i, pos);
|
||||
|
||||
/* Barwin create */
|
||||
i->bar = barwin_new(W->root, i->geo.x, i->geo.y, i->geo.w, i->geo.h,
|
||||
|
||||
@@ -33,6 +33,7 @@ infobar_elem_placement(Element *e)
|
||||
static inline bool
|
||||
infobar_placement(Infobar *i, Barpos p)
|
||||
{
|
||||
i->pos = p;
|
||||
i->geo = i->screen->ugeo;
|
||||
i->geo.h = i->theme->bars_width;
|
||||
|
||||
@@ -63,8 +64,6 @@ infobar_elem_screen_update(Scr33n *s, int addf)
|
||||
|
||||
SLIST_FOREACH(i, &s->infobars, next)
|
||||
infobar_elem_update(i);
|
||||
|
||||
s->elemupdate &= ~FLAGINT(addf);
|
||||
}
|
||||
|
||||
#endif /* INFOBAR_H */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "util.h"
|
||||
#include "infobar.h"
|
||||
#include "client.h"
|
||||
#include "frame.h"
|
||||
|
||||
Tag*
|
||||
tag_new(Scr33n *s, char *name)
|
||||
@@ -20,6 +21,14 @@ tag_new(Scr33n *s, char *name)
|
||||
t->flags = 0;
|
||||
t->sel = NULL;
|
||||
|
||||
SLIST_INIT(&t->clients);
|
||||
SLIST_INIT(&t->frames);
|
||||
|
||||
/*
|
||||
* tmp
|
||||
*/
|
||||
t->frame = frame_new(t);
|
||||
|
||||
TAILQ_INSERT_TAIL(&s->tags, t, next);
|
||||
|
||||
return t;
|
||||
@@ -28,11 +37,26 @@ tag_new(Scr33n *s, char *name)
|
||||
void
|
||||
tag_screen(Scr33n *s, Tag *t)
|
||||
{
|
||||
Frame *f;
|
||||
Client *c;
|
||||
|
||||
/* Hide previous tag's clients */
|
||||
if(s->seltag)
|
||||
SLIST_FOREACH(c, &s->seltag->clients, tnext)
|
||||
client_unmap(c);
|
||||
|
||||
s->seltag = t;
|
||||
|
||||
/* Unhide selected tag's clients */
|
||||
SLIST_FOREACH(c, &t->clients, tnext)
|
||||
client_map(c);
|
||||
|
||||
client_focus(t->sel);
|
||||
|
||||
infobar_elem_screen_update(s, ElemTag);
|
||||
|
||||
SLIST_FOREACH(f, &t->frames, next)
|
||||
frame_update(f);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -107,6 +131,18 @@ uicb_tag_prev(Uicb cmd)
|
||||
tag_screen(W->screen, TAILQ_LAST(&W->screen->tags, tsub));
|
||||
}
|
||||
|
||||
static void
|
||||
tag_remove(Tag *t)
|
||||
{
|
||||
Frame *f;
|
||||
|
||||
free(t->name);
|
||||
|
||||
frame_free(t);
|
||||
|
||||
free(t);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tag_free(Scr33n *s)
|
||||
@@ -116,7 +152,6 @@ tag_free(Scr33n *s)
|
||||
TAILQ_FOREACH(t, &s->tags, next)
|
||||
{
|
||||
TAILQ_REMOVE(&s->tags, t, next);
|
||||
free(t->name);
|
||||
free(t);
|
||||
tag_remove(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef struct Barwin Barwin;
|
||||
typedef struct Scr33n Scr33n;
|
||||
typedef struct Tag Tag;
|
||||
typedef struct Client Client;
|
||||
typedef struct Frame Frame;
|
||||
typedef struct Keybind Keybind;
|
||||
typedef struct Mousebind Mousebind;
|
||||
typedef struct Theme Theme;
|
||||
@@ -110,6 +111,8 @@ struct Tag
|
||||
Scr33n *screen;
|
||||
Flags flags;
|
||||
Client *sel;
|
||||
Frame *frame;
|
||||
SLIST_HEAD(, Frame) frames;
|
||||
SLIST_HEAD(, Client) clients;
|
||||
TAILQ_ENTRY(Tag) next;
|
||||
};
|
||||
@@ -119,12 +122,26 @@ struct Client
|
||||
{
|
||||
Tag *tag;
|
||||
Scr33n *screen;
|
||||
Frame *frame;
|
||||
Barwin *titlebar;
|
||||
Geo geo;
|
||||
Flags flags;
|
||||
char *title;
|
||||
Window win;
|
||||
SLIST_ENTRY(Client) next; /* Global list */
|
||||
SLIST_ENTRY(Client) tnext; /* Tag list */
|
||||
SLIST_ENTRY(Client) fnext; /* Frame list */
|
||||
};
|
||||
|
||||
/* Frame */
|
||||
struct Frame
|
||||
{
|
||||
Tag *tag;
|
||||
Geo geo;
|
||||
Window win;
|
||||
Color fg, bg;
|
||||
SLIST_HEAD(, Client) clients;
|
||||
SLIST_ENTRY(Frame) next;
|
||||
};
|
||||
|
||||
/* Config */
|
||||
|
||||
Reference in New Issue
Block a user