add config.*
This commit is contained in:
parent
0886bbbf5e
commit
0be08c6a4a
@ -28,6 +28,17 @@ client_configure(Client *c)
|
||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ev);
|
||||
}
|
||||
|
||||
Client*
|
||||
client_gb_win(Window *w)
|
||||
{
|
||||
Client *c = SLIST_FIRST(&W->h.client);
|
||||
|
||||
while(c && c->win != w)
|
||||
c = SLIST_NEXT(c, next);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Map a client
|
||||
* \param c Client pointer
|
||||
*/
|
||||
@ -46,6 +57,12 @@ client_unmap(Client *c)
|
||||
XUnmapWindow(W->dpy, c->win);
|
||||
}
|
||||
|
||||
void
|
||||
client_focus(Client *c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Close a client
|
||||
* \param c Client pointer
|
||||
*/
|
||||
|
||||
@ -21,8 +21,10 @@ typedef struct Client
|
||||
} Client;
|
||||
|
||||
void client_configure(Client *c);
|
||||
Client *client_gb_win(Window *w);
|
||||
void client_map(Client *c);
|
||||
void client_unmap(Client *c);
|
||||
void client_focus(Client *c);
|
||||
void client_close(Client *c);
|
||||
Client *client_new(Window w, XWindowAttributes *wa);
|
||||
void client_remove(Client *c);
|
||||
|
||||
10
wmfs2/src/config.c
Normal file
10
wmfs2/src/config.c
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
void
|
||||
config_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
21
wmfs2/src/config.h
Normal file
21
wmfs2/src/config.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* wmfs2 by Martin Duquesnoy <xorg62@gmail.com> { for(i = 2011; i < 2111; ++i) ©(i); }
|
||||
* For license, see COPYING.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
typedef struct Keybind
|
||||
{
|
||||
unsigned int mod;
|
||||
KeySym keysym;
|
||||
void (*func)(Uicb);
|
||||
Uicb cmd;
|
||||
SLIST_ENTRY(Keybind) next;
|
||||
} Keybind;
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
@ -7,6 +7,40 @@
|
||||
#include "util.h"
|
||||
#include "wmfs.h"
|
||||
|
||||
#define EVDPY(e) (e)->xany.display
|
||||
|
||||
static void
|
||||
event_enternotify(XEvent *e)
|
||||
{
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
Client *c;
|
||||
int n;
|
||||
|
||||
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||
&& ev->window != W->root)
|
||||
return;
|
||||
|
||||
if((c = client_gb_win(ev->window)))
|
||||
client_focus(c);
|
||||
}
|
||||
|
||||
static void
|
||||
event_maprequest(XEvent *e)
|
||||
{
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
XWindowAttributes at;
|
||||
|
||||
/* Which windows to manage */
|
||||
if(!XGetWindowAttributes(EVDPY(e), ev->window, &at)
|
||||
|| at.overried_redirect
|
||||
|| client_gb_win(ev->window))
|
||||
return;
|
||||
|
||||
(Client*)client_new(ev->window, at);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
event_dummy(XEvent *e)
|
||||
{
|
||||
|
||||
@ -108,6 +108,24 @@ wmfs_xinit(void)
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
wmfs_grab_keys(void)
|
||||
{
|
||||
KeyCode c;
|
||||
Keybind *k;
|
||||
|
||||
XUngrabKey(W->dpy, AnyKey, AnyModifier, W->root);
|
||||
|
||||
FOREACH(k, &W->h.keybind, next)
|
||||
if((c = XKeysymToKeycode(dpy, k->keysym)))
|
||||
{
|
||||
XGrabKey(W->dpy, c, k->mod, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(W->dpy, c, k->mod | LockMask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(W->dpy, c, k->mod | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(W->dpy, c, k->mod | LockMask | numlockmask, W->root, True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
wmfs_loop(void)
|
||||
{
|
||||
|
||||
@ -24,11 +24,15 @@
|
||||
/* Local */
|
||||
#include "screen.h"
|
||||
#include "client.h"
|
||||
#include "config.h"
|
||||
|
||||
#define ButtonMask (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
|
||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
||||
#define KeyMask (KeyPressMask | KeyReleaseMask)
|
||||
|
||||
typedef unsigned int Flags;
|
||||
typedef const char* Uicb;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x, y, w, h;
|
||||
@ -55,6 +59,7 @@ typedef struct
|
||||
{
|
||||
SLIST_HEAD(, Screen) screen;
|
||||
SLIST_HEAD(, Client) client;
|
||||
SLIST_HEAD(, Keybind) keybind;
|
||||
} h;
|
||||
|
||||
/*
|
||||
@ -65,9 +70,9 @@ typedef struct
|
||||
|
||||
} Wmfs;
|
||||
|
||||
|
||||
int wmfs_error_handler(Display *d, XErrorEvent *event);
|
||||
int wmfs_error_handler_dummy(Display *d, XErrorEvent *event);
|
||||
void wmfs_grab_keys(void);
|
||||
void wmfs_quit(void);
|
||||
|
||||
/* Single global variable */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user