2007-10-03 17:26:14 +02:00
|
|
|
/*
|
2007-09-12 14:29:51 +02:00
|
|
|
* event.c - event handlers
|
2007-10-03 17:26:14 +02:00
|
|
|
*
|
|
|
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2007-09-12 14:29:51 +02:00
|
|
|
*/
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xutil.h>
|
2007-10-03 17:26:14 +02:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#include <X11/extensions/Xrandr.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-14 12:01:39 +02:00
|
|
|
#include "screen.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "event.h"
|
|
|
|
#include "layout.h"
|
|
|
|
#include "tag.h"
|
2007-09-15 15:16:53 +02:00
|
|
|
#include "draw.h"
|
|
|
|
#include "statusbar.h"
|
2007-09-15 15:26:51 +02:00
|
|
|
#include "util.h"
|
2007-10-26 18:23:15 +02:00
|
|
|
#include "window.h"
|
2007-11-13 22:57:57 +01:00
|
|
|
#include "mouse.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/tile.h"
|
|
|
|
#include "layouts/floating.h"
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2007-12-19 04:46:44 +01:00
|
|
|
extern AwesomeConf globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
|
|
|
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
2007-11-11 16:33:59 +01:00
|
|
|
|
|
|
|
static void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(int screen, unsigned int button, unsigned int state,
|
2007-11-12 13:21:28 +01:00
|
|
|
Button *buttons, char *arg)
|
2007-11-11 16:33:59 +01:00
|
|
|
{
|
2007-11-12 13:21:28 +01:00
|
|
|
Button *b;
|
2007-11-11 16:33:59 +01:00
|
|
|
|
2007-11-12 13:21:28 +01:00
|
|
|
for(b = buttons; b; b = b->next)
|
2007-12-16 02:45:38 +01:00
|
|
|
if(button == b->button && CLEANMASK(state) == b->mod && b->func)
|
2007-11-11 16:33:59 +01:00
|
|
|
{
|
|
|
|
if(arg)
|
2007-12-16 02:45:38 +01:00
|
|
|
b->func(screen, arg);
|
2007-11-11 16:33:59 +01:00
|
|
|
else
|
2007-12-16 02:45:38 +01:00
|
|
|
b->func(screen, b->arg);
|
2007-11-11 16:33:59 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_buttonpress(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-11-11 16:33:59 +01:00
|
|
|
int i, screen, x = 0, y = 0;
|
2007-10-03 17:17:46 +02:00
|
|
|
unsigned int udummy;
|
2007-09-05 20:15:00 +02:00
|
|
|
Client *c;
|
2007-10-03 17:17:46 +02:00
|
|
|
Window wdummy;
|
2007-11-11 15:40:01 +01:00
|
|
|
char arg[256];
|
2007-12-14 19:02:38 +01:00
|
|
|
Tag *tag;
|
2007-09-05 20:15:00 +02:00
|
|
|
XButtonPressedEvent *ev = &e->xbutton;
|
|
|
|
|
2007-12-18 09:02:08 +01:00
|
|
|
for(screen = 0; screen < get_screen_count(); screen++)
|
2007-12-18 08:17:46 +01:00
|
|
|
if(globalconf.screens[screen].statusbar->window == ev->window)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
for(i = 1, tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-17 07:35:08 +01:00
|
|
|
x += textwidth_primitive(e->xany.display, globalconf.screens[screen].font, tag->name);
|
2007-12-18 08:17:46 +01:00
|
|
|
if(((globalconf.screens[screen].statusbar->position == BarTop
|
|
|
|
|| globalconf.screens[screen].statusbar->position == BarBot)
|
2007-11-11 22:56:59 +01:00
|
|
|
&& ev->x < x)
|
2007-12-18 08:17:46 +01:00
|
|
|
|| (globalconf.screens[screen].statusbar->position == BarRight && ev->y < x)
|
|
|
|
|| (globalconf.screens[screen].statusbar->position == BarLeft && ev->y > globalconf.screens[screen].statusbar->width - x))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-14 19:02:38 +01:00
|
|
|
snprintf(arg, sizeof(arg), "%d", i);
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.tag, arg);
|
2007-09-16 12:13:34 +02:00
|
|
|
return;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
2007-12-18 08:17:46 +01:00
|
|
|
x += globalconf.screens[screen].statusbar->txtlayoutwidth;
|
|
|
|
if(((globalconf.screens[screen].statusbar->position == BarTop
|
|
|
|
|| globalconf.screens[screen].statusbar->position == BarBot)
|
2007-11-11 22:56:59 +01:00
|
|
|
&& ev->x < x)
|
2007-12-18 08:17:46 +01:00
|
|
|
|| (globalconf.screens[screen].statusbar->position == BarRight && ev->y < x)
|
|
|
|
|| (globalconf.screens[screen].statusbar->position == BarLeft && ev->y > globalconf.screens[screen].statusbar->width - x))
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.layout, NULL);
|
2007-11-11 15:55:13 +01:00
|
|
|
else
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.title, NULL);
|
2007-09-16 12:32:17 +02:00
|
|
|
return;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-09-16 12:13:34 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(c, ev->same_screen, c->screen);
|
|
|
|
if(CLEANMASK(ev->state) == NoSymbol
|
2007-11-14 17:18:16 +01:00
|
|
|
&& ev->button == Button1)
|
2007-10-11 11:33:40 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
restack(c->screen);
|
2007-12-03 00:59:03 +01:00
|
|
|
XAllowEvents(c->display, ReplayPointer, CurrentTime);
|
2007-12-16 02:45:38 +01:00
|
|
|
window_grabbuttons(c->display, c->phys_screen, c->win, True, True);
|
2007-09-16 15:55:37 +02:00
|
|
|
}
|
2007-11-14 17:18:16 +01:00
|
|
|
else
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL);
|
2007-10-16 01:24:04 +02:00
|
|
|
}
|
2007-10-29 20:21:13 +01:00
|
|
|
else
|
2007-09-16 15:04:40 +02:00
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
2007-10-03 17:17:46 +02:00
|
|
|
if(RootWindow(e->xany.display, screen) == ev->window
|
2007-12-18 09:02:08 +01:00
|
|
|
&& XQueryPointer(e->xany.display,
|
|
|
|
ev->window, &wdummy,
|
|
|
|
&wdummy, &x, &y, &i,
|
|
|
|
&i, &udummy))
|
2007-09-16 00:17:05 +02:00
|
|
|
{
|
2007-12-18 09:02:08 +01:00
|
|
|
screen = get_screen_bycoord(x, y);
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_mouse_button_press(screen, ev->button, ev->state,
|
|
|
|
globalconf.buttons.root, NULL);
|
2007-11-12 10:53:48 +01:00
|
|
|
return;
|
2007-09-16 00:17:05 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_configurerequest(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
|
|
|
XWindowChanges wc;
|
2007-11-14 21:30:08 +01:00
|
|
|
int old_screen;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
c->ismax = False;
|
|
|
|
if(ev->value_mask & CWBorderWidth)
|
|
|
|
c->border = ev->border_width;
|
2007-10-16 22:33:10 +02:00
|
|
|
if(c->isfixed || c->isfloating
|
2007-12-16 02:45:38 +01:00
|
|
|
|| get_current_layout(c->screen)->arrange == layout_floating)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
if(ev->value_mask & CWX)
|
2007-11-15 15:14:40 +01:00
|
|
|
c->rx = c->x = ev->x;
|
2007-09-05 20:15:00 +02:00
|
|
|
if(ev->value_mask & CWY)
|
2007-11-15 15:14:40 +01:00
|
|
|
c->ry = c->y = ev->y;
|
2007-09-05 20:15:00 +02:00
|
|
|
if(ev->value_mask & CWWidth)
|
2007-11-15 15:14:40 +01:00
|
|
|
c->rw = c->w = ev->width;
|
2007-09-05 20:15:00 +02:00
|
|
|
if(ev->value_mask & CWHeight)
|
2007-11-15 15:14:40 +01:00
|
|
|
c->rh = c->h = ev->height;
|
2007-09-05 20:15:00 +02:00
|
|
|
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
|
2007-10-17 17:29:21 +02:00
|
|
|
window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border);
|
2007-11-14 21:30:08 +01:00
|
|
|
/* recompute screen */
|
|
|
|
old_screen = c->screen;
|
2007-12-18 09:02:08 +01:00
|
|
|
c->screen = get_screen_bycoord(c->x, c->y);
|
2007-11-14 21:30:08 +01:00
|
|
|
if(old_screen != c->screen)
|
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
move_client_to_screen(c, c->screen, False);
|
|
|
|
statusbar_draw(old_screen);
|
|
|
|
statusbar_draw(c->screen);
|
2007-11-14 21:30:08 +01:00
|
|
|
}
|
2007-12-16 02:45:38 +01:00
|
|
|
tag_client_with_rules(c);
|
2007-11-15 15:43:58 +01:00
|
|
|
XMoveResizeWindow(e->xany.display, c->win, c->rx, c->ry, c->rw, c->rh);
|
2007-12-16 02:45:38 +01:00
|
|
|
arrange(c->screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
2007-10-17 17:29:21 +02:00
|
|
|
window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
XConfigureWindow(e->xany.display, ev->window, ev->value_mask, &wc);
|
|
|
|
}
|
|
|
|
XSync(e->xany.display, False);
|
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_configurenotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XConfigureEvent *ev = &e->xconfigure;
|
2007-10-01 20:58:29 +02:00
|
|
|
int screen;
|
2007-09-27 21:22:35 +02:00
|
|
|
ScreenInfo *si;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-16 00:11:10 +02:00
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
|
|
|
if(ev->window == RootWindow(e->xany.display, screen)
|
|
|
|
&& (ev->width != DisplayWidth(e->xany.display, screen)
|
|
|
|
|| ev->height != DisplayHeight(e->xany.display, screen)))
|
|
|
|
{
|
|
|
|
DisplayWidth(e->xany.display, screen) = ev->width;
|
|
|
|
DisplayHeight(e->xany.display, screen) = ev->height;
|
2007-09-27 21:22:35 +02:00
|
|
|
|
2007-10-11 23:44:35 +02:00
|
|
|
/* update statusbar */
|
2007-12-18 09:02:08 +01:00
|
|
|
si = get_screen_info(screen, NULL, &globalconf.screens[screen].padding);
|
2007-12-18 08:17:46 +01:00
|
|
|
globalconf.screens[screen].statusbar->width = si[screen].width;
|
2007-10-11 23:44:35 +02:00
|
|
|
p_delete(&si);
|
|
|
|
|
|
|
|
XResizeWindow(e->xany.display,
|
2007-12-18 08:17:46 +01:00
|
|
|
globalconf.screens[screen].statusbar->window,
|
|
|
|
globalconf.screens[screen].statusbar->width,
|
|
|
|
globalconf.screens[screen].statusbar->height);
|
2007-10-11 23:44:35 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
statusbar_update_position(e->xany.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding);
|
|
|
|
arrange(screen);
|
2007-09-16 00:11:10 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_destroynotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
|
|
|
client_unmanage(c, WithdrawnState);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_enternotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
2007-09-16 00:11:10 +02:00
|
|
|
int screen;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
|
|
|
return;
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
2007-10-11 11:33:40 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(c, ev->same_screen, c->screen);
|
2007-10-26 23:19:13 +02:00
|
|
|
if (c->isfloating
|
2007-12-16 02:45:38 +01:00
|
|
|
|| get_current_layout(c->screen)->arrange == layout_floating)
|
|
|
|
window_grabbuttons(c->display, c->phys_screen, c->win, True, False);
|
2007-10-11 06:46:28 +02:00
|
|
|
}
|
2007-09-16 00:11:10 +02:00
|
|
|
else
|
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
|
|
|
if(ev->window == RootWindow(e->xany.display, screen))
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(NULL, True, screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_expose(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XExposeEvent *ev = &e->xexpose;
|
2007-09-16 12:13:34 +02:00
|
|
|
int screen;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-16 12:13:34 +02:00
|
|
|
if(!ev->count)
|
2007-12-18 09:02:08 +01:00
|
|
|
for(screen = 0; screen < get_screen_count(); screen++)
|
2007-12-18 08:17:46 +01:00
|
|
|
if(globalconf.screens[screen].statusbar->window == ev->window)
|
2007-12-16 02:45:38 +01:00
|
|
|
statusbar_draw(screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_keypress(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-11-12 17:22:40 +01:00
|
|
|
int screen, x, y, d;
|
2007-09-16 01:05:43 +02:00
|
|
|
unsigned int m;
|
2007-09-05 20:15:00 +02:00
|
|
|
KeySym keysym;
|
|
|
|
XKeyEvent *ev = &e->xkey;
|
2007-09-16 01:05:43 +02:00
|
|
|
Window dummy;
|
2007-11-12 17:22:40 +01:00
|
|
|
Key *k;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0);
|
2007-09-16 12:13:34 +02:00
|
|
|
|
2007-09-24 14:20:04 +02:00
|
|
|
/* find the right screen for this event */
|
2007-10-01 12:43:05 +02:00
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
|
|
|
if(XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), &dummy, &dummy, &x, &y, &d, &d, &m))
|
|
|
|
{
|
|
|
|
/* if screen is 0, we are on first Zaphod screen or on the
|
|
|
|
* only screen in Xinerama, so we can ask for a better screen
|
|
|
|
* number with get_screen_bycoord: we'll get 0 in Zaphod mode
|
|
|
|
* so it's the same, or maybe the real Xinerama screen */
|
2007-10-10 21:48:31 +02:00
|
|
|
if(screen == 0)
|
2007-12-18 09:02:08 +01:00
|
|
|
screen = get_screen_bycoord(x, y);
|
2007-10-10 21:48:31 +02:00
|
|
|
break;
|
2007-10-01 12:43:05 +02:00
|
|
|
}
|
2007-09-24 14:20:04 +02:00
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
for(k = globalconf.keys; k; k = k->next)
|
2007-11-12 17:22:40 +01:00
|
|
|
if(keysym == k->keysym && k->func
|
2007-12-16 02:45:38 +01:00
|
|
|
&& CLEANMASK(k->mod) == CLEANMASK(ev->state))
|
2007-11-15 17:20:22 +01:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
k->func(screen, k->arg);
|
2007-11-15 17:20:22 +01:00
|
|
|
break;
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_leavenotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
2007-09-16 00:11:10 +02:00
|
|
|
int screen;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-16 00:11:10 +02:00
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
|
|
|
if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen)
|
2007-12-16 02:45:38 +01:00
|
|
|
focus(NULL, ev->same_screen, screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_mappingnotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
XMappingEvent *ev = &e->xmapping;
|
2007-09-16 13:51:27 +02:00
|
|
|
int screen;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
XRefreshKeyboardMapping(ev);
|
|
|
|
if(ev->request == MappingKeyboard)
|
2007-09-16 13:51:27 +02:00
|
|
|
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
2007-12-18 09:02:08 +01:00
|
|
|
grabkeys(get_phys_screen(screen));
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_maprequest(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
static XWindowAttributes wa;
|
|
|
|
XMapRequestEvent *ev = &e->xmaprequest;
|
2007-10-12 10:49:03 +02:00
|
|
|
int screen, x, y, d;
|
|
|
|
unsigned int m;
|
|
|
|
Window dummy;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
|
|
|
if(!XGetWindowAttributes(e->xany.display, ev->window, &wa))
|
|
|
|
return;
|
|
|
|
if(wa.override_redirect)
|
|
|
|
return;
|
2007-12-16 02:45:38 +01:00
|
|
|
if(!get_client_bywin(globalconf.clients, ev->window))
|
2007-09-16 00:11:10 +02:00
|
|
|
{
|
|
|
|
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
|
2007-11-12 09:58:04 +01:00
|
|
|
if(screen == 0 && XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
|
|
|
|
&dummy, &dummy, &x, &y, &d, &d, &m))
|
2007-12-18 09:02:08 +01:00
|
|
|
screen = get_screen_bycoord(x, y);
|
2007-12-16 02:45:38 +01:00
|
|
|
client_manage(ev->window, &wa, screen);
|
2007-09-16 00:11:10 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_propertynotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
Window trans;
|
|
|
|
XPropertyEvent *ev = &e->xproperty;
|
|
|
|
|
|
|
|
if(ev->state == PropertyDelete)
|
|
|
|
return; /* ignore */
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
switch (ev->atom)
|
|
|
|
{
|
2007-11-12 09:59:54 +01:00
|
|
|
case XA_WM_TRANSIENT_FOR:
|
2007-09-05 20:15:00 +02:00
|
|
|
XGetTransientForHint(e->xany.display, c->win, &trans);
|
2007-12-16 02:45:38 +01:00
|
|
|
if(!c->isfloating && (c->isfloating = (get_client_bywin(globalconf.clients, trans) != NULL)))
|
|
|
|
arrange(c->screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
break;
|
2007-11-12 09:59:54 +01:00
|
|
|
case XA_WM_NORMAL_HINTS:
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatesizehints(c);
|
2007-09-05 20:15:00 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-09-10 16:49:54 +02:00
|
|
|
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatetitle(c);
|
2007-12-16 02:45:38 +01:00
|
|
|
if(c == globalconf.focus->client)
|
|
|
|
statusbar_draw(c->screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_unmapnotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XUnmapEvent *ev = &e->xunmap;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
if((c = get_client_bywin(globalconf.clients, ev->window))
|
2007-10-23 16:32:55 +02:00
|
|
|
&& ev->event == RootWindow(e->xany.display, c->phys_screen)
|
|
|
|
&& ev->send_event && window_getstate(c->display, c->win) == NormalState)
|
2007-12-16 02:45:38 +01:00
|
|
|
client_unmanage(c, WithdrawnState);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2007-09-13 15:57:35 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_shape(XEvent * e)
|
2007-09-13 15:57:35 +02:00
|
|
|
{
|
|
|
|
XShapeEvent *ev = (XShapeEvent *) e;
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *c = get_client_bywin(globalconf.clients, ev->window);
|
2007-09-13 15:57:35 +02:00
|
|
|
|
|
|
|
if(c)
|
2007-10-26 19:35:07 +02:00
|
|
|
window_setshape(c->display, c->phys_screen, c->win);
|
2007-09-13 15:57:35 +02:00
|
|
|
}
|
|
|
|
|
2007-09-13 16:00:03 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
handle_event_randr_screen_change_notify(XEvent *e)
|
2007-09-13 16:00:03 +02:00
|
|
|
{
|
|
|
|
XRRUpdateConfiguration(e);
|
|
|
|
}
|
|
|
|
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2007-12-16 02:45:38 +01:00
|
|
|
grabkeys(int phys_screen)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-11-12 17:22:40 +01:00
|
|
|
Key *k;
|
2007-09-05 20:15:00 +02:00
|
|
|
KeyCode code;
|
|
|
|
|
2007-12-16 02:45:38 +01:00
|
|
|
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
|
|
|
for(k = globalconf.keys; k; k = k->next)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-12-16 02:45:38 +01:00
|
|
|
if((code = XKeysymToKeycode(globalconf.display, k->keysym)) == NoSymbol)
|
2007-09-16 02:14:37 +02:00
|
|
|
continue;
|
2007-12-16 02:45:38 +01:00
|
|
|
XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
|
|
XGrabKey(globalconf.display, code, k->mod | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
|
|
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
|
|
|
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|