2006-10-12 18:10:57 +04:00
|
|
|
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2007-03-03 07:40:24 +03:00
|
|
|
* (C)opyright MMVI-MMVII Kris Maglione <fbsdaemon@gmail.com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <X11/keysym.h>
|
2007-03-04 21:54:02 +03:00
|
|
|
#include "wmii.h"
|
2007-02-15 07:20:47 +03:00
|
|
|
#include "printevent.h"
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2007-02-12 09:24:24 +03:00
|
|
|
uint
|
2007-03-04 00:01:38 +03:00
|
|
|
flush_masked_events(long event_mask) {
|
2006-04-25 17:48:33 +04:00
|
|
|
XEvent ev;
|
2007-02-12 09:24:24 +03:00
|
|
|
uint n = 0;
|
2007-03-04 00:01:38 +03:00
|
|
|
while(XCheckMaskEvent(blz.dpy, event_mask, &ev)) n++;
|
2006-05-01 22:40:33 +04:00
|
|
|
return n;
|
2006-04-25 17:48:33 +04:00
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
buttonrelease(XEvent *e) {
|
2006-06-28 10:20:17 +04:00
|
|
|
Frame *f;
|
2006-06-08 12:54:19 +04:00
|
|
|
Bar *b;
|
2006-03-23 16:22:43 +03:00
|
|
|
XButtonPressedEvent *ev = &e->xbutton;
|
2006-06-30 04:02:52 +04:00
|
|
|
if(ev->window == screen->barwin) {
|
|
|
|
for(b=screen->lbar; b; b=b->next)
|
2006-10-30 11:54:22 +03:00
|
|
|
if(ispointinrect(ev->x, ev->y, &b->brush.rect)) {
|
|
|
|
write_event("LeftBarClick %d %s\n",
|
2006-06-23 08:37:59 +04:00
|
|
|
ev->button, b->name);
|
2006-10-30 11:54:22 +03:00
|
|
|
return;
|
|
|
|
}
|
2006-06-30 04:02:52 +04:00
|
|
|
for(b=screen->rbar; b; b=b->next)
|
2006-10-30 11:54:22 +03:00
|
|
|
if(ispointinrect(ev->x, ev->y, &b->brush.rect)) {
|
|
|
|
write_event("RightBarClick %d %s\n",
|
2006-06-23 08:37:59 +04:00
|
|
|
ev->button, b->name);
|
2006-10-30 11:54:22 +03:00
|
|
|
return;
|
|
|
|
}
|
2006-02-10 00:48:01 +03:00
|
|
|
}
|
2007-02-10 00:42:03 +03:00
|
|
|
else if((f = frame_of_win(ev->window)))
|
2007-02-02 19:43:22 +03:00
|
|
|
write_event("ClientClick 0x%x %d\n", f->client->win, ev->button);
|
2006-04-25 20:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
buttonpress(XEvent *e) {
|
2006-06-28 10:20:17 +04:00
|
|
|
Frame *f;
|
2007-02-10 00:27:10 +03:00
|
|
|
Bool inclient;
|
|
|
|
XButtonPressedEvent *ev;
|
2007-02-24 07:09:58 +03:00
|
|
|
|
2007-02-10 00:27:10 +03:00
|
|
|
ev = &e->xbutton;
|
2006-06-28 10:20:17 +04:00
|
|
|
if((f = frame_of_win(ev->window))) {
|
2007-02-10 00:42:03 +03:00
|
|
|
inclient = (ev->subwindow == f->client->win);
|
2006-07-06 16:11:09 +04:00
|
|
|
if((ev->state & def.mod) == def.mod) {
|
2006-05-04 16:34:44 +04:00
|
|
|
switch(ev->button) {
|
|
|
|
case Button1:
|
2007-02-10 23:13:35 +03:00
|
|
|
do_mouse_resize(f->client, False, CENTER);
|
2007-02-09 04:39:10 +03:00
|
|
|
focus(f->client, True);
|
|
|
|
frame_to_top(f);
|
|
|
|
focus(f->client, True);
|
2006-05-04 16:34:44 +04:00
|
|
|
break;
|
|
|
|
case Button3:
|
2007-02-10 23:13:35 +03:00
|
|
|
do_mouse_resize(f->client, False,
|
2007-02-18 21:27:51 +03:00
|
|
|
quadofcoord(&f->rect, ev->x_root, ev->y_root));
|
2007-02-09 04:39:10 +03:00
|
|
|
frame_to_top(f);
|
|
|
|
focus(f->client, True);
|
2007-02-10 02:07:59 +03:00
|
|
|
break;
|
|
|
|
default: break;
|
2007-02-22 23:12:36 +03:00
|
|
|
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
2006-01-13 15:24:55 +03:00
|
|
|
}
|
2007-02-08 06:04:18 +03:00
|
|
|
}else{
|
2007-02-08 07:23:18 +03:00
|
|
|
if(ev->button == Button1) {
|
2007-02-10 02:16:15 +03:00
|
|
|
if(frame_to_top(f))
|
|
|
|
restack_view(f->view);
|
2007-02-21 01:31:42 +03:00
|
|
|
if(ispointinrect(ev->x, ev->y, &f->grabbox))
|
2007-02-10 23:13:35 +03:00
|
|
|
do_mouse_resize(f->client, True, CENTER);
|
2007-02-15 07:20:47 +03:00
|
|
|
else if(!ev->subwindow
|
2007-02-21 01:31:42 +03:00
|
|
|
&& !ispointinrect(ev->x, ev->y, &f->titlebar))
|
2007-02-10 23:13:35 +03:00
|
|
|
do_mouse_resize(f->client, False,
|
2007-02-18 21:27:51 +03:00
|
|
|
quadofcoord(&f->rect, ev->x_root, ev->y_root));
|
2007-02-10 02:16:15 +03:00
|
|
|
if(f->client != sel_client())
|
|
|
|
focus(f->client, True);
|
2007-02-08 07:23:18 +03:00
|
|
|
}
|
2007-02-22 23:12:36 +03:00
|
|
|
if(ev->subwindow)
|
|
|
|
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
2007-02-26 12:27:03 +03:00
|
|
|
else {
|
|
|
|
XUngrabPointer(blz.dpy, ev->time);
|
|
|
|
XSync(blz.dpy, False);
|
|
|
|
write_event("ClientMouseDown 0x%x %d\n", f->client->win, ev->button);
|
|
|
|
}
|
2006-01-13 15:24:55 +03:00
|
|
|
}
|
2007-02-10 00:27:10 +03:00
|
|
|
}else
|
2007-02-22 23:12:36 +03:00
|
|
|
XAllowEvents(blz.dpy, ReplayPointer, ev->time);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
configurerequest(XEvent *e) {
|
2006-03-23 16:22:43 +03:00
|
|
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
|
|
|
XWindowChanges wc;
|
2006-06-26 06:18:00 +04:00
|
|
|
XRectangle *frect;
|
2006-03-23 16:22:43 +03:00
|
|
|
Client *c;
|
2007-02-15 10:43:33 +03:00
|
|
|
Frame *f;
|
2005-12-21 18:18:11 +03:00
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
c = client_of_win(ev->window);
|
2007-02-13 02:18:00 +03:00
|
|
|
|
2006-03-23 16:22:43 +03:00
|
|
|
if(c) {
|
2007-02-15 10:43:33 +03:00
|
|
|
f = c->sel;
|
2006-06-26 06:18:00 +04:00
|
|
|
gravitate_client(c, True);
|
|
|
|
if(ev->value_mask & CWX)
|
|
|
|
c->rect.x = ev->x;
|
|
|
|
if(ev->value_mask & CWY)
|
2007-02-16 22:04:09 +03:00
|
|
|
c->rect.y = ev->y;
|
2006-06-26 06:18:00 +04:00
|
|
|
if(ev->value_mask & CWWidth)
|
2007-02-16 22:04:09 +03:00
|
|
|
c->rect.width = ev->width;
|
2006-06-26 06:18:00 +04:00
|
|
|
if(ev->value_mask & CWHeight)
|
2007-02-16 22:04:09 +03:00
|
|
|
c->rect.height = ev->height;
|
2006-06-26 06:18:00 +04:00
|
|
|
if(ev->value_mask & CWBorderWidth)
|
|
|
|
c->border = ev->border_width;
|
|
|
|
gravitate_client(c, False);
|
2007-03-03 09:36:03 +03:00
|
|
|
|
2007-03-03 07:40:24 +03:00
|
|
|
if((c->rect.height == screen->rect.height)
|
|
|
|
&&(c->rect.width == screen->rect.width)) {
|
|
|
|
c->fullscreen = True;
|
|
|
|
if(c->sel) {
|
|
|
|
if(!c->sel->area->floating)
|
|
|
|
send_to_area(c->sel->view->area, c->sel);
|
2007-03-03 09:36:03 +03:00
|
|
|
focus_client(c);
|
2007-03-03 07:40:24 +03:00
|
|
|
restack_view(c->sel->view);
|
|
|
|
}
|
|
|
|
}
|
2007-02-13 02:18:00 +03:00
|
|
|
|
2007-02-15 10:43:33 +03:00
|
|
|
if(c->sel->area->floating)
|
|
|
|
frect=&c->sel->rect;
|
|
|
|
else
|
|
|
|
frect=&c->sel->revert;
|
2007-02-13 02:18:00 +03:00
|
|
|
|
2007-02-15 10:43:33 +03:00
|
|
|
*frect = c->rect;
|
2007-02-16 21:41:23 +03:00
|
|
|
frect->y -= labelh(&def.font);
|
|
|
|
frect->x -= def.border;
|
2007-02-15 10:43:33 +03:00
|
|
|
frect->width += 2 * def.border;
|
|
|
|
frect->height += frame_delta_h();
|
2007-02-13 02:18:00 +03:00
|
|
|
|
2007-03-03 07:40:24 +03:00
|
|
|
if(c->sel->area->floating || c->fullscreen)
|
2007-02-15 10:43:33 +03:00
|
|
|
resize_client(c, frect);
|
|
|
|
else
|
|
|
|
configure_client(c);
|
|
|
|
}else{
|
|
|
|
wc.x = ev->x;
|
|
|
|
wc.y = ev->y;
|
|
|
|
wc.width = ev->width;
|
|
|
|
wc.height = ev->height;
|
|
|
|
wc.border_width = ev->border_width;
|
|
|
|
wc.sibling = ev->above;
|
|
|
|
wc.stack_mode = ev->detail;
|
2007-02-16 21:41:23 +03:00
|
|
|
ev->value_mask &= ~(CWStackMode|CWSibling);
|
2007-02-15 10:43:33 +03:00
|
|
|
XConfigureWindow(blz.dpy, ev->window, ev->value_mask, &wc);
|
|
|
|
XSync(blz.dpy, False);
|
|
|
|
}
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
destroynotify(XEvent *e) {
|
2006-03-23 16:22:43 +03:00
|
|
|
Client *c;
|
|
|
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
2006-03-09 22:25:50 +03:00
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
if((c = client_of_win(ev->window)))
|
2006-03-09 22:25:50 +03:00
|
|
|
destroy_client(c);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2006-04-25 17:48:33 +04:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
enternotify(XEvent *e) {
|
2006-04-25 17:48:33 +04:00
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
|
|
|
Client *c;
|
2007-02-24 00:03:20 +03:00
|
|
|
Frame *f;
|
2006-04-25 17:48:33 +04:00
|
|
|
|
2007-02-24 00:03:20 +03:00
|
|
|
if(ev->mode != NotifyNormal)
|
2006-04-25 17:48:33 +04:00
|
|
|
return;
|
2007-03-03 09:36:03 +03:00
|
|
|
|
2006-04-26 10:59:55 +04:00
|
|
|
if((c = client_of_win(ev->window))) {
|
2007-03-05 22:56:36 +03:00
|
|
|
if(ev->detail != NotifyInferior) {
|
|
|
|
if(screen->focus != c) {
|
|
|
|
if(verbose)
|
|
|
|
fprintf(stderr, "enter_notify(c) => %s\n", c->name);
|
|
|
|
focus(c, False);
|
|
|
|
}
|
2007-02-24 00:03:20 +03:00
|
|
|
set_cursor(c, cursor[CurNormal]);
|
2007-03-03 09:36:03 +03:00
|
|
|
}else if(verbose)
|
|
|
|
fprintf(stderr, "enter_notify(c[NotifyInferior]) => %s\n", c->name);
|
2007-02-24 00:03:20 +03:00
|
|
|
}
|
2007-03-05 22:56:36 +03:00
|
|
|
else if((f = frame_of_win(ev->window))) {
|
|
|
|
if(screen->focus != c) {
|
|
|
|
if(verbose)
|
|
|
|
fprintf(stderr, "enter_notify(f) => %s\n", f->client->name);
|
|
|
|
if(f->area->floating || !f->collapsed)
|
|
|
|
focus(f->client, False);
|
|
|
|
}
|
2007-02-24 00:03:20 +03:00
|
|
|
set_frame_cursor(f, ev->x, ev->y);
|
2006-06-16 10:52:13 +04:00
|
|
|
}
|
2006-06-22 13:03:42 +04:00
|
|
|
else if(ev->window == blz.root) {
|
2006-06-16 10:52:13 +04:00
|
|
|
sel_screen = True;
|
2006-06-20 16:32:19 +04:00
|
|
|
draw_frames();
|
2006-06-16 10:52:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
leavenotify(XEvent *e) {
|
2006-06-16 10:52:13 +04:00
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
if((ev->window == blz.root) && !ev->same_screen) {
|
2006-06-16 10:52:13 +04:00
|
|
|
sel_screen = True;
|
2006-06-20 16:32:19 +04:00
|
|
|
draw_frames();
|
2006-04-25 17:48:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-03 07:40:24 +03:00
|
|
|
void
|
|
|
|
print_focus(Client *c, char *to) {
|
|
|
|
if(verbose) {
|
|
|
|
fprintf(stderr, "screen->focus: %p => %p\n",
|
|
|
|
screen->focus, c);
|
|
|
|
fprintf(stderr, "\t%s => %s\n",
|
|
|
|
screen->focus ? screen->focus->name : "<nil>",
|
|
|
|
to);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-22 00:34:12 +03:00
|
|
|
static void
|
|
|
|
focusin(XEvent *e) {
|
|
|
|
Client *c, *old;
|
2007-03-04 00:01:38 +03:00
|
|
|
XEvent me;
|
2007-02-22 00:34:12 +03:00
|
|
|
XFocusChangeEvent *ev = &e->xfocus;
|
|
|
|
|
|
|
|
/* Yes, we're focusing in on nothing, here. */
|
|
|
|
if(ev->detail == NotifyDetailNone) {
|
|
|
|
XSetInputFocus(blz.dpy, screen->barwin, RevertToParent, CurrentTime);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!((ev->detail == NotifyNonlinear)
|
|
|
|
||(ev->detail == NotifyNonlinearVirtual)
|
2007-03-03 07:40:24 +03:00
|
|
|
||(ev->detail == NotifyVirtual)
|
2007-02-22 00:34:12 +03:00
|
|
|
||(ev->detail == NotifyInferior)
|
|
|
|
||(ev->detail == NotifyAncestor)))
|
|
|
|
return;
|
2007-03-04 05:33:43 +03:00
|
|
|
if((ev->mode == NotifyWhileGrabbed)
|
|
|
|
&&(screen->hasgrab != &c_magic))
|
2007-02-22 00:34:12 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
c = client_of_win(ev->window);
|
|
|
|
old = screen->focus;
|
|
|
|
if(c) {
|
2007-03-03 07:40:24 +03:00
|
|
|
print_focus(c, c->name);
|
2007-02-22 00:34:12 +03:00
|
|
|
if(ev->mode == NotifyGrab)
|
|
|
|
screen->hasgrab = c;
|
|
|
|
screen->focus = c;
|
2007-03-03 07:40:24 +03:00
|
|
|
if(c != old) {
|
|
|
|
update_client_grab(c);
|
|
|
|
if(c->sel)
|
|
|
|
draw_frame(c->sel);
|
|
|
|
if(old && old->sel)
|
|
|
|
draw_frame(old->sel);
|
2007-02-22 00:34:12 +03:00
|
|
|
}
|
2007-03-03 07:40:24 +03:00
|
|
|
}else if(ev->window == screen->barwin) {
|
|
|
|
print_focus(nil, "<nil>");
|
2007-02-22 00:34:12 +03:00
|
|
|
screen->focus = nil;
|
|
|
|
}else if(ev->mode == NotifyGrab) {
|
2007-03-04 00:01:38 +03:00
|
|
|
if(ev->window == blz.root) {
|
|
|
|
if(XCheckMaskEvent(blz.dpy, KeyPressMask, &me)) {
|
2007-03-04 05:33:43 +03:00
|
|
|
screen->hasgrab = &c_magic;
|
2007-03-04 00:01:38 +03:00
|
|
|
handler[me.xany.type](&me);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-03-03 07:40:24 +03:00
|
|
|
if((c = screen->focus)) {
|
|
|
|
/* Some unmanaged window has focus */
|
|
|
|
print_focus(&c_magic, "<magic>");
|
2007-02-23 08:07:30 +03:00
|
|
|
screen->focus = &c_magic;
|
2007-02-22 00:34:12 +03:00
|
|
|
if(c->sel)
|
|
|
|
draw_frame(c->sel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
focusout(XEvent *e) {
|
|
|
|
Client *c;
|
|
|
|
XFocusChangeEvent *ev = &e->xfocus;
|
|
|
|
|
|
|
|
if(!((ev->detail == NotifyNonlinear)
|
|
|
|
||(ev->detail == NotifyNonlinearVirtual)))
|
|
|
|
return;
|
|
|
|
if(ev->mode == NotifyUngrab)
|
|
|
|
screen->hasgrab = nil;
|
|
|
|
|
|
|
|
c = client_of_win(ev->window);
|
|
|
|
if(c) {
|
2007-03-04 05:33:43 +03:00
|
|
|
if((ev->mode == NotifyWhileGrabbed)
|
|
|
|
&&(screen->hasgrab != &c_magic)) {
|
2007-03-03 07:40:24 +03:00
|
|
|
if((screen->focus)
|
|
|
|
&&(screen->hasgrab != screen->focus))
|
2007-02-22 00:34:12 +03:00
|
|
|
screen->hasgrab = screen->focus;
|
|
|
|
if(screen->hasgrab == c)
|
|
|
|
return;
|
2007-03-04 00:01:38 +03:00
|
|
|
}else if(ev->mode != NotifyGrab && ev->window != blz.root) {
|
2007-03-03 07:40:24 +03:00
|
|
|
if(screen->focus == c) {
|
|
|
|
print_focus(&c_magic, "<magic>");
|
|
|
|
screen->focus = &c_magic;
|
|
|
|
}
|
|
|
|
update_client_grab(c);
|
|
|
|
if(c->sel)
|
|
|
|
draw_frame(c->sel);
|
2007-02-22 00:34:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
expose(XEvent *e) {
|
2006-02-10 00:48:01 +03:00
|
|
|
XExposeEvent *ev = &e->xexpose;
|
2006-06-28 10:20:17 +04:00
|
|
|
static Frame *f;
|
2006-06-30 10:02:44 +04:00
|
|
|
|
2006-03-23 16:22:43 +03:00
|
|
|
if(ev->count == 0) {
|
2006-06-30 04:02:52 +04:00
|
|
|
if(ev->window == screen->barwin)
|
|
|
|
draw_bar(screen);
|
2006-06-30 10:02:44 +04:00
|
|
|
else if((f = frame_of_win(ev->window)) && f->view == screen->sel)
|
2006-06-28 10:20:17 +04:00
|
|
|
draw_frame(f);
|
2006-03-23 16:22:43 +03:00
|
|
|
}
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
keypress(XEvent *e) {
|
2006-02-09 21:40:12 +03:00
|
|
|
XKeyEvent *ev = &e->xkey;
|
2007-03-02 00:37:00 +03:00
|
|
|
Frame *f;
|
2006-07-04 19:31:37 +04:00
|
|
|
KeySym k = 0;
|
2006-07-03 14:14:26 +04:00
|
|
|
char buf[32];
|
|
|
|
int n;
|
|
|
|
|
2006-02-09 21:40:12 +03:00
|
|
|
ev->state &= valid_mask;
|
2006-07-03 14:14:26 +04:00
|
|
|
if((f = frame_of_win(ev->window))) {
|
|
|
|
buf[0] = 0;
|
2006-07-03 14:22:46 +04:00
|
|
|
n = XLookupString(ev, buf, sizeof(buf), &k, 0);
|
2006-07-03 14:14:26 +04:00
|
|
|
if(IsFunctionKey(k) || IsKeypadKey(k) || IsMiscFunctionKey(k)
|
|
|
|
|| IsPFKey(k) || IsPrivateKeypadKey(k))
|
|
|
|
return;
|
|
|
|
buf[n] = 0;
|
|
|
|
}
|
2007-03-02 00:37:00 +03:00
|
|
|
else {
|
2006-07-11 10:42:15 +04:00
|
|
|
kpress(blz.root, ev->state, (KeyCode) ev->keycode);
|
2007-03-02 00:37:00 +03:00
|
|
|
}
|
2006-02-09 21:40:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
mappingnotify(XEvent *e) {
|
2006-08-14 20:41:59 +04:00
|
|
|
XMappingEvent *ev = &e->xmapping;
|
|
|
|
|
|
|
|
XRefreshKeyboardMapping(ev);
|
|
|
|
if(ev->request == MappingKeyboard)
|
|
|
|
update_keys();
|
2006-02-09 21:40:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
maprequest(XEvent *e) {
|
2006-03-23 16:22:43 +03:00
|
|
|
XMapRequestEvent *ev = &e->xmaprequest;
|
|
|
|
static XWindowAttributes wa;
|
2005-12-21 18:18:11 +03:00
|
|
|
|
2006-07-03 20:41:14 +04:00
|
|
|
if(!XGetWindowAttributes(blz.dpy, ev->window, &wa))
|
2006-03-23 16:22:43 +03:00
|
|
|
return;
|
|
|
|
if(wa.override_redirect) {
|
2006-07-03 20:41:14 +04:00
|
|
|
XSelectInput(blz.dpy, ev->window,
|
2006-03-23 16:22:43 +03:00
|
|
|
(StructureNotifyMask | PropertyChangeMask));
|
|
|
|
return;
|
|
|
|
}
|
2006-04-12 12:44:07 +04:00
|
|
|
if(!client_of_win(ev->window))
|
|
|
|
manage_client(create_client(ev->window, &wa));
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2007-02-21 02:29:16 +03:00
|
|
|
static void
|
|
|
|
motionnotify(XEvent *e) {
|
|
|
|
XMotionEvent *ev = &e->xmotion;
|
|
|
|
Frame *f;
|
2007-02-24 07:09:58 +03:00
|
|
|
|
2007-02-24 00:03:20 +03:00
|
|
|
if((f = frame_of_win(ev->window)))
|
|
|
|
set_frame_cursor(f, ev->x, ev->y);
|
2007-02-21 02:29:16 +03:00
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
propertynotify(XEvent *e) {
|
2006-03-23 16:22:43 +03:00
|
|
|
XPropertyEvent *ev = &e->xproperty;
|
|
|
|
Client *c;
|
2005-12-12 21:06:10 +03:00
|
|
|
|
2006-03-23 16:22:43 +03:00
|
|
|
if(ev->state == PropertyDelete)
|
|
|
|
return; /* ignore */
|
2006-04-12 12:44:07 +04:00
|
|
|
if((c = client_of_win(ev->window)))
|
2007-03-02 11:13:32 +03:00
|
|
|
prop_client(c, ev->atom);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2007-03-05 09:11:12 +03:00
|
|
|
static void
|
|
|
|
mapnotify(XEvent *e) {
|
|
|
|
Client *c;
|
|
|
|
XMapEvent *ev = &e->xmap;
|
|
|
|
|
|
|
|
if((c = client_of_win(ev->window)))
|
|
|
|
if(c == sel_client())
|
|
|
|
focus_client(c);
|
|
|
|
}
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
unmapnotify(XEvent *e) {
|
2006-03-23 16:22:43 +03:00
|
|
|
Client *c;
|
|
|
|
XUnmapEvent *ev = &e->xunmap;
|
2006-03-09 22:25:50 +03:00
|
|
|
|
2006-04-12 12:44:07 +04:00
|
|
|
if((c = client_of_win(ev->window)))
|
2007-02-10 06:06:07 +03:00
|
|
|
if(!c->unmapped--)
|
|
|
|
destroy_client(c);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
2007-03-03 07:40:24 +03:00
|
|
|
|
2007-02-09 05:26:45 +03:00
|
|
|
void (*handler[LASTEvent]) (XEvent *) = {
|
|
|
|
[ButtonPress] = buttonpress,
|
|
|
|
[ButtonRelease] = buttonrelease,
|
2007-02-21 02:29:16 +03:00
|
|
|
[ConfigureRequest]=configurerequest,
|
2007-02-09 05:26:45 +03:00
|
|
|
[DestroyNotify] = destroynotify,
|
|
|
|
[EnterNotify] = enternotify,
|
|
|
|
[Expose] = expose,
|
2007-02-21 02:29:16 +03:00
|
|
|
[FocusIn] = focusin,
|
|
|
|
[FocusOut] = focusout,
|
2007-02-09 05:26:45 +03:00
|
|
|
[KeyPress] = keypress,
|
2007-02-21 02:29:16 +03:00
|
|
|
[LeaveNotify] = leavenotify,
|
2007-03-05 09:11:12 +03:00
|
|
|
[MapNotify] = mapnotify,
|
2007-02-09 05:26:45 +03:00
|
|
|
[MapRequest] = maprequest,
|
2007-02-21 02:29:16 +03:00
|
|
|
[MappingNotify] = mappingnotify,
|
|
|
|
[MotionNotify] = motionnotify,
|
2007-02-09 05:26:45 +03:00
|
|
|
[PropertyNotify]= propertynotify,
|
2007-02-15 07:20:47 +03:00
|
|
|
[UnmapNotify] = unmapnotify,
|
2007-02-21 02:29:16 +03:00
|
|
|
|
2007-02-09 05:26:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
check_x_event(IXPConn *c) {
|
|
|
|
XEvent ev;
|
2007-02-22 00:34:12 +03:00
|
|
|
while(XPending(blz.dpy)) {
|
2007-02-09 05:26:45 +03:00
|
|
|
XNextEvent(blz.dpy, &ev);
|
2007-03-03 22:46:12 +03:00
|
|
|
if(verbose)
|
2007-02-15 07:20:47 +03:00
|
|
|
printevent(&ev);
|
2007-02-09 05:26:45 +03:00
|
|
|
if(handler[ev.type])
|
2007-02-22 00:34:12 +03:00
|
|
|
handler[ev.type](&ev);
|
2007-02-09 05:26:45 +03:00
|
|
|
}
|
|
|
|
}
|