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
|
|
|
*
|
2008-01-02 16:59:43 +01:00
|
|
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
2007-10-03 17:26:14 +02:00
|
|
|
*
|
|
|
|
* 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 "tag.h"
|
2007-09-15 15:16:53 +02:00
|
|
|
#include "statusbar.h"
|
2007-10-26 18:23:15 +02:00
|
|
|
#include "window.h"
|
2007-11-13 22:57:57 +01:00
|
|
|
#include "mouse.h"
|
2007-12-27 20:49:38 +01:00
|
|
|
#include "ewmh.h"
|
2008-01-01 17:25:48 +01:00
|
|
|
#include "client.h"
|
2008-01-07 18:12:38 +01:00
|
|
|
#include "widget.h"
|
2008-01-13 16:30:43 +01:00
|
|
|
#include "rules.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/tile.h"
|
|
|
|
#include "layouts/floating.h"
|
2008-03-13 09:05:34 +01:00
|
|
|
#include "common/xscreen.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
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle mouse button click
|
|
|
|
* \param screen screen number
|
|
|
|
* \param button button number
|
|
|
|
* \param state modkeys state
|
|
|
|
* \param buttons buttons list to check for
|
|
|
|
* \param arg optional arg passed to uicb, otherwise buttons' arg are used
|
|
|
|
*/
|
2007-11-11 16:33:59 +01:00
|
|
|
static void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_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
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XButtonPressed events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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-12-27 15:49:00 +01:00
|
|
|
Widget *widget;
|
2007-12-30 21:00:34 +01:00
|
|
|
Statusbar *statusbar;
|
2007-09-05 20:15:00 +02:00
|
|
|
XButtonPressedEvent *ev = &e->xbutton;
|
|
|
|
|
2008-03-13 09:28:21 +01:00
|
|
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
2007-12-30 21:00:34 +01:00
|
|
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
2008-01-23 15:54:30 +01:00
|
|
|
if(statusbar->sw->window == ev->window || statusbar->sw->window == ev->subwindow)
|
2008-01-24 20:28:45 +01:00
|
|
|
{
|
2008-01-05 11:57:24 +01:00
|
|
|
switch(statusbar->position)
|
2008-01-04 13:04:15 +01:00
|
|
|
{
|
2008-01-05 11:57:24 +01:00
|
|
|
case Top:
|
|
|
|
case Bottom:
|
2007-12-30 21:00:34 +01:00
|
|
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
2008-01-05 12:51:40 +01:00
|
|
|
if(ev->x >= widget->area.x && ev->x < widget->area.x + widget->area.width
|
|
|
|
&& ev->y >= widget->area.y && ev->y < widget->area.y + widget->area.height)
|
2007-12-30 21:00:34 +01:00
|
|
|
{
|
|
|
|
widget->button_press(widget, ev);
|
|
|
|
return;
|
|
|
|
}
|
2008-01-05 11:57:24 +01:00
|
|
|
break;
|
|
|
|
case Right:
|
2007-12-30 21:00:34 +01:00
|
|
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
2008-01-05 12:51:40 +01:00
|
|
|
if(ev->y >= widget->area.x && ev->y < widget->area.x + widget->area.width
|
2008-02-08 15:35:09 +01:00
|
|
|
&& statusbar->sw->geometry.width - ev->x >= widget->area.y
|
|
|
|
&& statusbar->sw->geometry.width - ev->x
|
2008-01-23 16:05:52 +01:00
|
|
|
< widget->area.y + widget->area.height)
|
2007-12-30 21:00:34 +01:00
|
|
|
{
|
|
|
|
widget->button_press(widget, ev);
|
|
|
|
return;
|
|
|
|
}
|
2008-01-05 11:57:24 +01:00
|
|
|
break;
|
2008-01-24 20:22:39 +01:00
|
|
|
case Left:
|
2007-12-30 21:00:34 +01:00
|
|
|
for(widget = statusbar->widgets; widget; widget = widget->next)
|
2008-02-08 15:35:09 +01:00
|
|
|
if(statusbar->sw->geometry.height - ev->y >= widget->area.x
|
|
|
|
&& statusbar->sw->geometry.height - ev->y
|
2008-01-23 16:05:52 +01:00
|
|
|
< widget->area.x + widget->area.width
|
2008-01-05 12:51:40 +01:00
|
|
|
&& ev->x >= widget->area.y && ev->x < widget->area.y + widget->area.height)
|
2007-12-30 21:00:34 +01:00
|
|
|
{
|
|
|
|
widget->button_press(widget, ev);
|
|
|
|
return;
|
|
|
|
}
|
2008-01-05 11:57:24 +01:00
|
|
|
break;
|
2008-01-24 20:22:39 +01:00
|
|
|
case Off:
|
|
|
|
break;
|
2008-01-04 13:04:15 +01:00
|
|
|
}
|
2008-01-24 20:28:45 +01:00
|
|
|
/* return if no widget match */
|
|
|
|
return;
|
|
|
|
}
|
2007-09-16 12:13:34 +02:00
|
|
|
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-02-09 23:12:40 +01:00
|
|
|
client_focus(c, c->screen, True);
|
2007-12-16 02:45:38 +01:00
|
|
|
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-27 23:10:43 +01:00
|
|
|
XAllowEvents(globalconf.display, ReplayPointer, CurrentTime);
|
2008-01-26 13:11:12 +01:00
|
|
|
window_grabbuttons(get_phys_screen(c->screen), c->win);
|
2007-09-16 15:55:37 +02:00
|
|
|
}
|
2007-11-14 17:18:16 +01:00
|
|
|
else
|
2008-03-06 09:09:59 +01:00
|
|
|
event_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
|
|
|
{
|
2008-03-13 09:28:21 +01:00
|
|
|
screen = screen_get_bycoord(globalconf.screens_info, screen, x, y);
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_mouse_button_press(screen, ev->button, ev->state,
|
2007-12-16 02:45:38 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XConfigureRequest events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_configurerequest(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
|
|
|
XWindowChanges wc;
|
2008-01-06 21:50:03 +01:00
|
|
|
int old_screen;
|
2008-03-14 09:37:25 +01:00
|
|
|
area_t geometry;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-01-06 14:40:23 +01:00
|
|
|
geometry = c->geometry;
|
|
|
|
|
|
|
|
if(ev->value_mask & CWX)
|
|
|
|
geometry.x = ev->x;
|
|
|
|
if(ev->value_mask & CWY)
|
|
|
|
geometry.y = ev->y;
|
|
|
|
if(ev->value_mask & CWWidth)
|
|
|
|
geometry.width = ev->width;
|
|
|
|
if(ev->value_mask & CWHeight)
|
|
|
|
geometry.height = ev->height;
|
|
|
|
|
|
|
|
if(geometry.x != c->geometry.x || geometry.y != c->geometry.y
|
|
|
|
|| geometry.width != c->geometry.width || geometry.height != c->geometry.height)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-01-05 18:31:01 +01:00
|
|
|
old_screen = c->screen;
|
2008-01-06 14:40:23 +01:00
|
|
|
|
2008-03-14 15:21:53 +01:00
|
|
|
client_resize(c, geometry);
|
2008-01-06 21:28:49 +01:00
|
|
|
|
2008-01-13 16:30:43 +01:00
|
|
|
tag_client_with_rule(c, rule_matching_client(c));
|
2008-01-22 21:00:11 +01:00
|
|
|
|
|
|
|
if(!c->isfloating)
|
|
|
|
globalconf.screens[c->screen].need_arrange = True;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2008-01-05 18:31:01 +01:00
|
|
|
else
|
2008-01-06 14:40:23 +01:00
|
|
|
window_configure(c->win, geometry, 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XConfigure events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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-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)))
|
2008-01-25 23:15:27 +01:00
|
|
|
/* it's not that we panic, but restart */
|
|
|
|
uicb_exec(0, globalconf.argv);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XDestroyWindow events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_destroynotify(XEvent *e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
|
|
|
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
2008-01-06 21:57:53 +01:00
|
|
|
client_unmanage(c);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XCrossing events on enter
|
2008-03-04 10:14:13 +01:00
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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
|
|
|
|
2008-03-04 10:14:13 +01:00
|
|
|
if(ev->mode != NotifyNormal
|
|
|
|
|| (ev->x_root == globalconf.pointer_x
|
|
|
|
&& ev->y_root == globalconf.pointer_y))
|
2007-09-05 20:15:00 +02:00
|
|
|
return;
|
2008-01-24 18:31:44 +01:00
|
|
|
|
2008-03-04 10:14:13 +01:00
|
|
|
/* the idea behing saving pointer_x and pointer_y is Bob Marley powered */
|
|
|
|
globalconf.pointer_x = ev->x_root;
|
|
|
|
globalconf.pointer_y = ev->y_root;
|
|
|
|
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_bywin(globalconf.clients, ev->window)))
|
2007-10-11 11:33:40 +02:00
|
|
|
{
|
2008-01-26 13:11:12 +01:00
|
|
|
window_grabbuttons(get_phys_screen(c->screen), c->win);
|
2008-01-25 12:55:44 +01:00
|
|
|
if(globalconf.screens[c->screen].sloppy_focus)
|
2008-02-09 23:12:40 +01:00
|
|
|
client_focus(c, c->screen,
|
|
|
|
(globalconf.screens[c->screen].sloppy_focus
|
|
|
|
&& globalconf.screens[c->screen].sloppy_focus_raise));
|
2007-10-11 06:46:28 +02:00
|
|
|
}
|
2008-01-11 11:41:38 +01:00
|
|
|
else
|
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))
|
2008-01-25 12:55:44 +01:00
|
|
|
window_root_grabbuttons(screen);
|
2008-03-04 10:14:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XMotion events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2008-03-04 10:14:13 +01:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_motionnotify(XEvent *e)
|
2008-03-04 10:14:13 +01:00
|
|
|
{
|
|
|
|
XMotionEvent *ev = &e->xmotion;
|
|
|
|
|
|
|
|
globalconf.pointer_x = ev->x_root;
|
|
|
|
globalconf.pointer_y = ev->y_root;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XExpose events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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-12-30 21:00:34 +01:00
|
|
|
Statusbar *statusbar;
|
2008-03-14 14:27:56 +01:00
|
|
|
Client *c;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2007-09-16 12:13:34 +02:00
|
|
|
if(!ev->count)
|
2008-03-14 14:27:56 +01:00
|
|
|
{
|
2008-03-13 09:28:21 +01:00
|
|
|
for(screen = 0; screen < globalconf.screens_info->nscreen; screen++)
|
2007-12-30 21:00:34 +01:00
|
|
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
2008-01-23 15:54:30 +01:00
|
|
|
if(statusbar->sw->window == ev->window)
|
2007-12-30 21:00:34 +01:00
|
|
|
{
|
|
|
|
statusbar_display(statusbar);
|
|
|
|
return;
|
|
|
|
}
|
2008-03-14 14:27:56 +01:00
|
|
|
|
|
|
|
for(c = globalconf.clients; c; c = c->next)
|
2008-03-14 16:32:58 +01:00
|
|
|
if(c->titlebar.position && c->titlebar.sw->window == ev->window)
|
2008-03-14 14:27:56 +01:00
|
|
|
{
|
2008-03-14 16:32:58 +01:00
|
|
|
simplewindow_refresh_drawable(c->titlebar.sw, get_phys_screen(c->screen));
|
2008-03-14 14:27:56 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XKey events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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
|
|
|
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
|
|
|
|
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
|
2008-01-29 19:06:44 +01:00
|
|
|
* number with screen_get_bycoord: we'll get 0 in Zaphod mode
|
2007-10-01 12:43:05 +02:00
|
|
|
* so it's the same, or maybe the real Xinerama screen */
|
2008-03-13 09:28:21 +01:00
|
|
|
screen = screen_get_bycoord(globalconf.screens_info, screen, 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)
|
2008-02-08 14:35:32 +01:00
|
|
|
if(ev->keycode == k->keycode &&
|
|
|
|
k->func && 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
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XCrossing events on leave
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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)
|
2008-02-09 23:12:40 +01:00
|
|
|
client_focus(NULL, screen, True);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XMapping events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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++)
|
2008-03-06 16:16:39 +01:00
|
|
|
window_root_grabkeys(screen);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XMapRequest events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_maprequest(XEvent *e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
static XWindowAttributes wa;
|
|
|
|
XMapRequestEvent *ev = &e->xmaprequest;
|
2008-02-25 13:19:39 +01:00
|
|
|
int screen = 0, x, y, d;
|
2007-10-12 10:49:03 +02:00
|
|
|
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;
|
2008-01-29 08:21:05 +01:00
|
|
|
if(!client_get_bywin(globalconf.clients, ev->window))
|
2007-09-16 00:11:10 +02:00
|
|
|
{
|
2008-03-13 09:31:35 +01:00
|
|
|
if(globalconf.screens_info->xinerama_is_active
|
2008-02-25 13:19:39 +01:00
|
|
|
&& XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen),
|
|
|
|
&dummy, &dummy, &x, &y, &d, &d, &m))
|
2008-03-13 09:28:21 +01:00
|
|
|
screen = screen_get_bycoord(globalconf.screens_info, screen, x, y);
|
2008-02-25 13:19:39 +01:00
|
|
|
else
|
|
|
|
for(screen = 0; wa.screen != ScreenOfDisplay(e->xany.display, screen); screen++);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XProperty events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_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 */
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_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);
|
2008-01-17 19:17:53 +01:00
|
|
|
if(!c->isfloating
|
2008-01-29 08:21:05 +01:00
|
|
|
&& (c->isfloating = (client_get_bywin(globalconf.clients, trans) != NULL)))
|
2008-01-17 19:17:53 +01:00
|
|
|
globalconf.screens[c->screen].need_arrange = True;
|
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-12-23 15:16:10 +01:00
|
|
|
case XA_WM_HINTS:
|
|
|
|
client_updatewmhints(c);
|
|
|
|
break;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2007-12-27 23:10:43 +01:00
|
|
|
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(globalconf.display, "_NET_WM_NAME", False))
|
2007-12-14 16:05:10 +01:00
|
|
|
client_updatetitle(c);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XUnmap events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-07 12:29:54 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_unmapnotify(XEvent * e)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
|
|
|
Client *c;
|
|
|
|
XUnmapEvent *ev = &e->xunmap;
|
|
|
|
|
2008-01-29 08:21:05 +01:00
|
|
|
if((c = client_get_bywin(globalconf.clients, ev->window))
|
2008-01-02 19:26:55 +01:00
|
|
|
&& ev->event == RootWindow(e->xany.display, get_phys_screen(c->screen))
|
2007-12-30 15:24:51 +01:00
|
|
|
&& ev->send_event && window_getstate(c->win) == NormalState)
|
2008-01-06 21:57:53 +01:00
|
|
|
client_unmanage(c);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XShape events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-13 15:57:35 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_shape(XEvent * e)
|
2007-09-13 15:57:35 +02:00
|
|
|
{
|
|
|
|
XShapeEvent *ev = (XShapeEvent *) e;
|
2008-01-29 08:21:05 +01:00
|
|
|
Client *c = client_get_bywin(globalconf.clients, ev->window);
|
2007-09-13 15:57:35 +02:00
|
|
|
|
|
|
|
if(c)
|
2008-01-02 19:26:55 +01:00
|
|
|
window_setshape(get_phys_screen(c->screen), c->win);
|
2007-09-13 15:57:35 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XRandR events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-13 16:00:03 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_randr_screen_change_notify(XEvent *e)
|
2007-09-13 16:00:03 +02:00
|
|
|
{
|
|
|
|
XRRUpdateConfiguration(e);
|
2008-01-11 13:40:08 +01:00
|
|
|
uicb_exec(0, globalconf.argv);
|
2007-09-13 16:00:03 +02:00
|
|
|
}
|
|
|
|
|
2008-03-06 09:05:15 +01:00
|
|
|
/** Handle XClientMessage events
|
|
|
|
* \param e XEvent
|
|
|
|
*/
|
2007-09-05 20:15:00 +02:00
|
|
|
void
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_clientmessage(XEvent *e)
|
2007-12-27 20:49:38 +01:00
|
|
|
{
|
|
|
|
ewmh_process_client_message(&e->xclient);
|
|
|
|
}
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|