mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-08-01 20:52:01 -07:00
sowm: subscribe to less window events!
This commit is contained in:
27
sowm.c
27
sowm.c
@@ -34,7 +34,6 @@ struct desktop{client *list;};
|
|||||||
static void button_press(XEvent *e);
|
static void button_press(XEvent *e);
|
||||||
static void button_release();
|
static void button_release();
|
||||||
static void configure_request(XEvent *e);
|
static void configure_request(XEvent *e);
|
||||||
static void key_grab();
|
|
||||||
static void key_press(XEvent *e);
|
static void key_press(XEvent *e);
|
||||||
static void map_request(XEvent *e);
|
static void map_request(XEvent *e);
|
||||||
static void notify_destroy(XEvent *e);
|
static void notify_destroy(XEvent *e);
|
||||||
@@ -158,7 +157,7 @@ void notify_destroy(XEvent *e) {
|
|||||||
void notify_enter(XEvent *e) {
|
void notify_enter(XEvent *e) {
|
||||||
while(XCheckTypedEvent(d, EnterNotify, e));
|
while(XCheckTypedEvent(d, EnterNotify, e));
|
||||||
|
|
||||||
if (e->xcrossing.window != root) win_focus(e->xcrossing.window)
|
win_focus(e->xcrossing.window)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -193,17 +192,6 @@ void notify_motion(XEvent *e) {
|
|||||||
wh + (mouse.button == 3 ? yd : 0));
|
wh + (mouse.button == 3 ? yd : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
This function initializes all key bindings defined in 'config.h'.
|
|
||||||
Simple stuff, nothing fancy or different from other window
|
|
||||||
managers happens here.
|
|
||||||
*/
|
|
||||||
void key_grab() {
|
|
||||||
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
|
|
||||||
XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod,
|
|
||||||
root, True, GrabModeAsync, GrabModeAsync);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function fires on a key press and checks to see if there
|
This function fires on a key press and checks to see if there
|
||||||
is a matching and defined key binding. If there is a match the
|
is a matching and defined key binding. If there is a match the
|
||||||
@@ -507,8 +495,7 @@ void configure_request(XEvent *e) {
|
|||||||
void map_request(XEvent *e) {
|
void map_request(XEvent *e) {
|
||||||
Window w = e->xmaprequest.window;
|
Window w = e->xmaprequest.window;
|
||||||
|
|
||||||
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
|
XSelectInput(d, w, StructureNotifyMask|EnterWindowMask|LeaveWindowMask);
|
||||||
EnterWindowMask|FocusChangeMask);
|
|
||||||
|
|
||||||
win_center((Arg){.i = w});
|
win_center((Arg){.i = w});
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
@@ -552,13 +539,13 @@ int main(void) {
|
|||||||
sw = XDisplayWidth(d, s);
|
sw = XDisplayWidth(d, s);
|
||||||
sh = XDisplayHeight(d, s);
|
sh = XDisplayHeight(d, s);
|
||||||
|
|
||||||
key_grab();
|
XSelectInput(d, root, SubstructureNotifyMask|SubstructureRedirectMask);
|
||||||
|
|
||||||
XSelectInput(d, root, SubstructureNotifyMask|
|
|
||||||
SubstructureRedirectMask|EnterWindowMask|LeaveWindowMask);
|
|
||||||
|
|
||||||
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
||||||
|
|
||||||
|
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
|
||||||
|
XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod,
|
||||||
|
root, True, GrabModeAsync, GrabModeAsync);
|
||||||
|
|
||||||
for (int i=1; i<4; i+=2)
|
for (int i=1; i<4; i+=2)
|
||||||
XGrabButton(d, i, MOD, root, True,
|
XGrabButton(d, i, MOD, root, True,
|
||||||
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
|
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
|
||||||
|
Reference in New Issue
Block a user