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
|
|
|
*/
|
|
|
|
|
2008-06-26 18:10:45 +02:00
|
|
|
#include <xcb/xcb.h>
|
2008-06-26 22:42:58 +02:00
|
|
|
#include <xcb/randr.h>
|
2008-09-16 15:36:44 +02:00
|
|
|
#include <xcb/xcb_atom.h>
|
2008-07-28 17:54:33 +02:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2008-09-16 15:36:44 +02:00
|
|
|
#include <xcb/xcb_event.h>
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-09-02 17:12:10 +02:00
|
|
|
#include "awesome.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "event.h"
|
2008-06-27 22:50:10 +02:00
|
|
|
#include "tag.h"
|
2007-10-26 18:23:15 +02:00
|
|
|
#include "window.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-03-15 16:38:51 +01:00
|
|
|
#include "titlebar.h"
|
Put keybindings in binary searchable arrays.
This patch sorts keybindings in arrays by keycode or keysym to speed up look
up using binary searches. This is a preliminary work to enable more powerful
keybindings stuff, where keybindings can be cascaded or why not, attached to
specific clients.
Interstingly enough, this patch saves 100ko of initial memory (Heap) usage here.
The underlying idea is that we should be able to define keybindings_t as
trees of keybindings_t which would then define key sequences.
The OO approach kind of make sense in fact, since you create a base
keybinding (e.g. reacting on Mod4-w) and then you will probably (with
appropriate apis) be able to populate new submaps from that point more or
less dynamically.
And if you have two keybindings on Mod4-w, then adding them will replace the
previous one. This means that you can fake per-client bindings with e.g.:
k_default = keybindings.new({"Mod4"}, "w", something);
k_mplayer = keybindings.new({"Mod4"}, "w", something_else);
k_default:add()
and in your focus hook:
if /* code for testing if it's mplayer */ then
k_mplayer:add()
else
k_default:add()
end
This would not work before, it does now.
It will take way more sense with submaps of course.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
2008-06-25 01:00:25 +02:00
|
|
|
#include "keybinding.h"
|
2008-06-10 16:50:55 +02:00
|
|
|
#include "keygrabber.h"
|
2008-05-20 15:39:47 +02:00
|
|
|
#include "lua.h"
|
2008-06-14 18:12:16 +02:00
|
|
|
#include "systray.h"
|
2008-08-25 14:34:56 +02:00
|
|
|
#include "statusbar.h"
|
2007-09-05 20:15:00 +02:00
|
|
|
#include "layouts/floating.h"
|
2008-06-30 18:55:14 +02:00
|
|
|
#include "common/atoms.h"
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2008-05-24 08:59:27 +02:00
|
|
|
extern awesome_t globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2008-08-12 13:23:10 +02:00
|
|
|
/** Handle mouse button events.
|
2008-06-13 18:20:20 +02:00
|
|
|
* \param c The client on which the event happened or NULL.
|
2008-08-12 13:23:10 +02:00
|
|
|
* \param type Event type, press or release.
|
|
|
|
* \param button Button number.
|
|
|
|
* \param state Modkeys state.
|
|
|
|
* \param buttons Buttons array to check for.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2007-11-11 16:33:59 +01:00
|
|
|
static void
|
2008-08-12 13:23:10 +02:00
|
|
|
event_handle_mouse_button(client_t *c,
|
|
|
|
uint8_t type,
|
|
|
|
xcb_button_t button,
|
|
|
|
uint16_t state,
|
|
|
|
button_array_t *buttons)
|
2007-11-11 16:33:59 +01:00
|
|
|
{
|
2008-08-12 13:23:10 +02:00
|
|
|
for(int i = 0; i < buttons->len; i++)
|
|
|
|
if(button == buttons->tab[i]->button
|
|
|
|
&& XUTIL_MASK_CLEAN(state) == buttons->tab[i]->mod)
|
2008-05-26 16:17:57 +02:00
|
|
|
{
|
|
|
|
if(c)
|
|
|
|
{
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-08-12 13:23:10 +02:00
|
|
|
luaA_dofunction(globalconf.L,
|
|
|
|
type == XCB_BUTTON_PRESS ?
|
|
|
|
buttons->tab[i]->press : buttons->tab[i]->release,
|
|
|
|
1, 0);
|
2008-05-26 16:17:57 +02:00
|
|
|
}
|
|
|
|
else
|
2008-08-12 13:23:10 +02:00
|
|
|
luaA_dofunction(globalconf.L,
|
|
|
|
type == XCB_BUTTON_PRESS ?
|
|
|
|
buttons->tab[i]->press : buttons->tab[i]->release,
|
|
|
|
0, 0);
|
2008-05-26 16:17:57 +02:00
|
|
|
}
|
2007-11-11 16:33:59 +01:00
|
|
|
}
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2008-08-25 13:40:55 +02:00
|
|
|
/** Get a widget node from a statusbar by coords.
|
|
|
|
* \param Container position.
|
|
|
|
* \param widgets The widget list.
|
|
|
|
* \param height The container height.
|
|
|
|
* \param width The container width.
|
|
|
|
* \param x X coordinate of the widget.
|
|
|
|
* \param y Y coordinate of the widget.
|
|
|
|
* \return A widget node.
|
|
|
|
*/
|
|
|
|
static widget_node_t *
|
|
|
|
widget_getbycoords(position_t position, widget_node_t *widgets, int height, int width, int x, int y)
|
|
|
|
{
|
|
|
|
int tmp;
|
|
|
|
widget_node_t *w;
|
|
|
|
|
|
|
|
/* Need to transform coordinates like it was top/bottom */
|
|
|
|
switch(position)
|
|
|
|
{
|
|
|
|
case Right:
|
|
|
|
tmp = y;
|
|
|
|
y = height - x;
|
|
|
|
x = tmp;
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
tmp = y;
|
|
|
|
y = x;
|
|
|
|
x = width - tmp;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(w = widgets; w; w = w->next)
|
|
|
|
if(x >= w->area.x && x < w->area.x + w->area.width
|
|
|
|
&& y >= w->area.y && y < w->area.y + w->area.height)
|
|
|
|
return w;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The button press event handler.
|
2008-08-12 13:23:10 +02:00
|
|
|
* \param data The type of mouse event.
|
2008-06-13 18:20:20 +02:00
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-08-12 13:23:10 +02:00
|
|
|
event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-08-25 13:40:55 +02:00
|
|
|
int screen;
|
2008-05-20 20:30:07 +02:00
|
|
|
const int nb_screen = xcb_setup_roots_length(xcb_get_setup(connection));
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-05-20 15:39:47 +02:00
|
|
|
widget_node_t *w;
|
2008-04-11 11:27:36 +02:00
|
|
|
statusbar_t *statusbar;
|
2008-04-09 18:27:25 +02:00
|
|
|
|
2008-08-12 13:23:10 +02:00
|
|
|
/* ev->state is
|
|
|
|
* button status (8 bits) + modifiers status (8 bits)
|
|
|
|
* we don't care for button status that we get, especially on release, so
|
|
|
|
* drop them */
|
|
|
|
ev->state &= 0x00ff;
|
|
|
|
|
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-05-27 15:15:48 +02:00
|
|
|
if(statusbar->sw
|
|
|
|
&& (statusbar->sw->window == ev->event || statusbar->sw->window == ev->child))
|
2008-01-24 20:28:45 +01:00
|
|
|
{
|
2008-05-25 14:01:09 +02:00
|
|
|
/* If the statusbar is child, then x,y are
|
|
|
|
* relative to root window */
|
|
|
|
if(statusbar->sw->window == ev->child)
|
|
|
|
{
|
|
|
|
ev->event_x -= statusbar->sw->geometry.x;
|
|
|
|
ev->event_y -= statusbar->sw->geometry.y;
|
|
|
|
}
|
2008-08-25 13:40:55 +02:00
|
|
|
if((w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
|
|
|
statusbar->width, statusbar->height,
|
|
|
|
ev->event_x, ev->event_y)))
|
|
|
|
w->widget->button(w, ev, statusbar->screen, statusbar, AWESOME_TYPE_STATUSBAR);
|
|
|
|
/* return even if no widget match */
|
2008-03-21 16:50:17 +01:00
|
|
|
return 0;
|
2008-01-24 20:28:45 +01:00
|
|
|
}
|
2007-09-16 12:13:34 +02:00
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
if((c = client_getbytitlebarwin(ev->event)))
|
2008-06-03 18:41:54 +02:00
|
|
|
{
|
2008-08-25 13:40:55 +02:00
|
|
|
if((w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
|
|
|
c->titlebar->width, c->titlebar->height,
|
|
|
|
ev->event_x, ev->event_y)))
|
|
|
|
w->widget->button(w, ev, c->screen, c->titlebar, AWESOME_TYPE_TITLEBAR);
|
|
|
|
/* return even if no widget match */
|
2008-06-03 18:41:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-04-08 16:11:13 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
if((c = client_getbywin(ev->event)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-08-12 13:23:10 +02:00
|
|
|
event_handle_mouse_button(c, ev->response_type, ev->detail, ev->state, &c->buttons);
|
|
|
|
xcb_allow_events(globalconf.connection,
|
|
|
|
XCB_ALLOW_REPLAY_POINTER,
|
|
|
|
XCB_CURRENT_TIME);
|
2007-10-16 01:24:04 +02:00
|
|
|
}
|
2007-10-29 20:21:13 +01:00
|
|
|
else
|
2008-05-20 20:30:07 +02:00
|
|
|
for(screen = 0; screen < nb_screen; screen++)
|
2008-06-17 16:55:24 +02:00
|
|
|
if(xutil_screen_get(connection, screen)->root == ev->event)
|
2007-09-16 00:17:05 +02:00
|
|
|
{
|
2008-08-12 13:23:10 +02:00
|
|
|
event_handle_mouse_button(NULL, ev->response_type, ev->detail, ev->state, &globalconf.buttons);
|
2008-03-21 16:50:17 +01:00
|
|
|
return 0;
|
2007-09-16 00:17:05 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The configure event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_configurerequest(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection, xcb_configure_request_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-03-14 09:37:25 +01:00
|
|
|
area_t geometry;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
if((c = client_getbywin(ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-01-06 14:40:23 +01:00
|
|
|
geometry = c->geometry;
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
2008-01-06 14:40:23 +01:00
|
|
|
geometry.x = ev->x;
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
|
2008-01-06 14:40:23 +01:00
|
|
|
geometry.y = ev->y;
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
|
2008-01-06 14:40:23 +01:00
|
|
|
geometry.width = ev->width;
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
|
2008-01-06 14:40:23 +01:00
|
|
|
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-08-21 17:52:44 +02:00
|
|
|
if(c->isfloating || c->isfullscreen || layout_get_current(c->screen) == layout_floating)
|
2008-07-31 17:39:20 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
client_resize(c, geometry, false);
|
2008-07-31 17:39:20 +02:00
|
|
|
titlebar_draw(c);
|
|
|
|
}
|
2008-03-24 14:37:57 +01:00
|
|
|
else
|
2008-03-26 09:52:54 +01:00
|
|
|
{
|
2008-08-21 15:36:54 +02:00
|
|
|
client_need_arrange(c);
|
2008-03-26 09:52:54 +01:00
|
|
|
/* If we do not resize the client, at least tell it that it
|
|
|
|
* has its new configuration. That fixes at least
|
|
|
|
* gnome-terminal */
|
|
|
|
window_configure(c->win, c->geometry, c->border);
|
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2008-01-05 18:31:01 +01:00
|
|
|
else
|
2008-03-15 16:38:51 +01:00
|
|
|
{
|
2008-06-04 11:50:21 +02:00
|
|
|
titlebar_update_geometry_floating(c);
|
2008-01-06 14:40:23 +01:00
|
|
|
window_configure(c->win, geometry, c->border);
|
2008-03-15 16:38:51 +01:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-22 19:48:58 +01:00
|
|
|
uint16_t config_win_mask = 0;
|
|
|
|
uint32_t config_win_vals[7];
|
|
|
|
unsigned short i = 0;
|
|
|
|
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_X;
|
|
|
|
config_win_vals[i++] = ev->x;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_Y)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_Y;
|
|
|
|
config_win_vals[i++] = ev->y;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_WIDTH;
|
|
|
|
config_win_vals[i++] = ev->width;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_HEIGHT;
|
|
|
|
config_win_vals[i++] = ev->height;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
|
|
|
|
config_win_vals[i++] = ev->border_width;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_SIBLING)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_SIBLING;
|
|
|
|
config_win_vals[i++] = ev->sibling;
|
|
|
|
}
|
|
|
|
if(ev->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
|
|
|
|
{
|
|
|
|
config_win_mask |= XCB_CONFIG_WINDOW_STACK_MODE;
|
|
|
|
config_win_vals[i++] = ev->stack_mode;
|
|
|
|
}
|
|
|
|
|
2008-04-09 18:27:25 +02:00
|
|
|
xcb_configure_window(connection, ev->window, config_win_mask, config_win_vals);
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The configure notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_configurenotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection, xcb_configure_notify_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
int screen_nbr;
|
|
|
|
const xcb_screen_t *screen;
|
|
|
|
|
2008-03-22 14:29:15 +01:00
|
|
|
for(screen_nbr = 0; screen_nbr < xcb_setup_roots_length(xcb_get_setup (connection)); screen_nbr++)
|
2008-06-17 16:55:24 +02:00
|
|
|
if((screen = xutil_screen_get(connection, screen_nbr)) != NULL
|
2008-03-27 16:05:37 +01:00
|
|
|
&& ev->window == screen->root
|
2008-03-21 16:50:17 +01:00
|
|
|
&& (ev->width != screen->width_in_pixels
|
|
|
|
|| ev->height != screen->height_in_pixels))
|
2008-01-25 23:15:27 +01:00
|
|
|
/* it's not that we panic, but restart */
|
2008-09-02 17:12:10 +02:00
|
|
|
awesome_restart();
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The destroy notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_destroynotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection __attribute__ ((unused)),
|
|
|
|
xcb_destroy_notify_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-06-29 13:38:02 +02:00
|
|
|
xembed_window_t *emwin;
|
|
|
|
int i;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-06-05 09:25:38 +02:00
|
|
|
if((c = client_getbywin(ev->window)))
|
2008-01-06 21:57:53 +01:00
|
|
|
client_unmanage(c);
|
2008-06-29 13:38:02 +02:00
|
|
|
else if((emwin = xembed_getbywin(globalconf.embedded, ev->event)))
|
|
|
|
{
|
|
|
|
xembed_window_list_detach(&globalconf.embedded, emwin);
|
|
|
|
for(i = 0; i < globalconf.screens_info->nscreen; i++)
|
|
|
|
widget_invalidate_cache(i, WIDGET_CACHE_EMBEDDED);
|
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-08-25 14:34:56 +02:00
|
|
|
/** Handle a motion notify over widgets.
|
|
|
|
* \param object The object.
|
|
|
|
* \param type The object type.
|
|
|
|
* \param mouse_over The pointer to the registered mouse over widget.
|
|
|
|
* \param w The new widget the mouse is over.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
event_handle_widget_motionnotify(void *object,
|
|
|
|
awesome_type_t type,
|
|
|
|
widget_node_t **mouse_over,
|
|
|
|
widget_node_t *w)
|
|
|
|
{
|
|
|
|
if(w != *mouse_over)
|
|
|
|
{
|
|
|
|
if(*mouse_over)
|
|
|
|
{
|
|
|
|
/* call mouse leave function on old widget */
|
|
|
|
luaA_pushpointer(globalconf.L, object, type);
|
|
|
|
luaA_dofunction(globalconf.L, (*mouse_over)->widget->mouse_leave, 1, 0);
|
|
|
|
}
|
|
|
|
if(w)
|
|
|
|
{
|
|
|
|
/* call mouse enter function on new widget and register it */
|
|
|
|
*mouse_over = w;
|
|
|
|
luaA_pushpointer(globalconf.L, object, type);
|
|
|
|
luaA_dofunction(globalconf.L, w->widget->mouse_enter, 1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** The motion notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
event_handle_motionnotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection,
|
|
|
|
xcb_motion_notify_event_t *ev)
|
|
|
|
{
|
|
|
|
statusbar_t *statusbar = statusbar_getbywin(ev->event);
|
|
|
|
client_t *c;
|
|
|
|
widget_node_t *w;
|
|
|
|
|
|
|
|
if(statusbar)
|
|
|
|
{
|
|
|
|
w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
|
|
|
statusbar->width, statusbar->height,
|
|
|
|
ev->event_x, ev->event_y);
|
|
|
|
event_handle_widget_motionnotify(statusbar,
|
|
|
|
AWESOME_TYPE_STATUSBAR,
|
|
|
|
&statusbar->mouse_over, w);
|
|
|
|
}
|
|
|
|
else if((c = client_getbytitlebarwin(ev->event)))
|
|
|
|
{
|
|
|
|
w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
|
|
|
c->titlebar->width, c->titlebar->height,
|
|
|
|
ev->event_x, ev->event_y);
|
|
|
|
event_handle_widget_motionnotify(c->titlebar,
|
|
|
|
AWESOME_TYPE_TITLEBAR,
|
|
|
|
&c->titlebar->mouse_over, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** The leave notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
event_handle_leavenotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection,
|
|
|
|
xcb_leave_notify_event_t *ev)
|
|
|
|
{
|
|
|
|
statusbar_t *statusbar = statusbar_getbywin(ev->event);
|
|
|
|
client_t *c;
|
|
|
|
|
|
|
|
if(statusbar)
|
|
|
|
{
|
|
|
|
if(statusbar->mouse_over)
|
|
|
|
{
|
|
|
|
/* call mouse leave function on widget the mouse was over */
|
|
|
|
luaA_statusbar_userdata_new(globalconf.L, statusbar);
|
|
|
|
luaA_dofunction(globalconf.L, statusbar->mouse_over->widget->mouse_leave, 1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((c = client_getbytitlebarwin(ev->event)))
|
|
|
|
{
|
|
|
|
if(c->titlebar->mouse_over)
|
|
|
|
{
|
|
|
|
/* call mouse leave function on widget the mouse was over */
|
|
|
|
luaA_titlebar_userdata_new(globalconf.L, c->titlebar);
|
|
|
|
luaA_dofunction(globalconf.L, c->titlebar->mouse_over->widget->mouse_leave, 1, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The enter notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-04 10:14:13 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_enternotify(void *data __attribute__ ((unused)),
|
2008-06-14 18:12:16 +02:00
|
|
|
xcb_connection_t *connection,
|
2008-05-20 15:39:47 +02:00
|
|
|
xcb_enter_notify_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-06-14 18:12:16 +02:00
|
|
|
client_t *c;
|
|
|
|
xembed_window_t *emwin;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->mode != XCB_NOTIFY_MODE_NORMAL
|
|
|
|
|| (ev->root_x == globalconf.pointer_x
|
|
|
|
&& ev->root_y == globalconf.pointer_y))
|
|
|
|
return 0;
|
2008-01-24 18:31:44 +01:00
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
if((c = client_getbytitlebarwin(ev->event))
|
2008-06-05 09:25:38 +02:00
|
|
|
|| (c = client_getbywin(ev->event)))
|
2007-10-11 11:33:40 +02:00
|
|
|
{
|
2008-08-12 13:23:10 +02:00
|
|
|
window_buttons_grab(c->win, ev->root, &c->buttons);
|
2008-06-14 18:12:16 +02:00
|
|
|
/* The idea behind saving pointer_x and pointer_y is Bob Marley powered.
|
2008-03-28 17:49:11 +01:00
|
|
|
* this will allow us top drop some EnterNotify events and thus not giving
|
|
|
|
* focus to windows appering under the cursor without a cursor move */
|
2008-03-21 16:50:17 +01:00
|
|
|
globalconf.pointer_x = ev->root_x;
|
|
|
|
globalconf.pointer_y = ev->root_y;
|
2008-03-28 17:49:11 +01:00
|
|
|
|
2008-06-18 18:31:35 +02:00
|
|
|
luaA_client_userdata_new(globalconf.L, c);
|
2008-08-25 15:35:17 +02:00
|
|
|
luaA_dofunction(globalconf.L, globalconf.hooks.mouse_over, 1, 0);
|
2007-10-11 06:46:28 +02:00
|
|
|
}
|
2008-06-14 18:12:16 +02:00
|
|
|
else if((emwin = xembed_getbywin(globalconf.embedded, ev->event)))
|
|
|
|
xcb_ungrab_button(globalconf.connection, XCB_BUTTON_INDEX_ANY,
|
2008-06-17 16:55:24 +02:00
|
|
|
xutil_screen_get(connection, emwin->phys_screen)->root,
|
2008-08-19 10:59:40 +02:00
|
|
|
XCB_BUTTON_MASK_ANY);
|
2008-01-11 11:41:38 +01:00
|
|
|
else
|
2008-08-13 19:06:20 +02:00
|
|
|
window_root_buttons_grab(ev->root);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2008-03-04 10:14:13 +01:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The expose event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_expose(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection __attribute__ ((unused)),
|
|
|
|
xcb_expose_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2007-09-16 12:13:34 +02:00
|
|
|
int screen;
|
2008-04-11 11:27:36 +02:00
|
|
|
statusbar_t *statusbar;
|
2008-06-04 11:50:21 +02:00
|
|
|
client_t *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-05-27 15:15:48 +02:00
|
|
|
if(statusbar->sw
|
|
|
|
&& statusbar->sw->window == ev->window)
|
2007-12-30 21:00:34 +01:00
|
|
|
{
|
2008-06-04 16:13:41 +02:00
|
|
|
simplewindow_refresh_pixmap(statusbar->sw);
|
2008-03-21 16:50:17 +01:00
|
|
|
return 0;
|
2007-12-30 21:00:34 +01:00
|
|
|
}
|
2008-03-14 14:27:56 +01:00
|
|
|
|
2008-06-04 11:50:21 +02:00
|
|
|
if((c = client_getbytitlebarwin(ev->window)))
|
2008-06-04 16:13:41 +02:00
|
|
|
simplewindow_refresh_pixmap(c->titlebar->sw);
|
2008-03-14 14:27:56 +01:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The key press event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_keypress(void *data __attribute__ ((unused)),
|
2008-05-20 15:39:47 +02:00
|
|
|
xcb_connection_t *connection __attribute__ ((unused)),
|
|
|
|
xcb_key_press_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-06-10 16:50:55 +02:00
|
|
|
if(globalconf.keygrabber != LUA_REFNIL)
|
|
|
|
{
|
|
|
|
lua_rawgeti(globalconf.L, LUA_REGISTRYINDEX, globalconf.keygrabber);
|
2008-06-10 22:37:45 +02:00
|
|
|
if(keygrabber_handlekpress(globalconf.L, ev))
|
2008-06-10 16:50:55 +02:00
|
|
|
{
|
2008-06-10 22:37:45 +02:00
|
|
|
if(lua_pcall(globalconf.L, 2, 1, 0))
|
|
|
|
{
|
|
|
|
warn("error running function: %s", lua_tostring(globalconf.L, -1));
|
|
|
|
keygrabber_ungrab();
|
|
|
|
}
|
|
|
|
else if(!lua_isboolean(globalconf.L, -1) || !lua_toboolean(globalconf.L, -1))
|
|
|
|
keygrabber_ungrab();
|
2008-06-10 16:50:55 +02:00
|
|
|
}
|
2008-06-10 22:37:45 +02:00
|
|
|
lua_pop(globalconf.L, 1); /* pop returned value or function if not called */
|
2008-06-10 16:50:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-30 22:49:10 +02:00
|
|
|
keybinding_t *k = keybinding_find(ev);
|
2008-06-26 13:06:55 +02:00
|
|
|
if (k && k->fct != LUA_REFNIL)
|
2008-07-09 12:12:52 +02:00
|
|
|
luaA_dofunction(globalconf.L, k->fct, 0, 0);
|
2008-06-10 16:50:55 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The map request event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_maprequest(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection, xcb_map_request_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-06-30 13:06:23 +02:00
|
|
|
int screen_nbr = 0, ret = 0;
|
2008-05-20 20:30:07 +02:00
|
|
|
client_t *c;
|
2008-04-09 18:27:25 +02:00
|
|
|
xcb_get_window_attributes_cookie_t wa_c;
|
|
|
|
xcb_get_window_attributes_reply_t *wa_r;
|
2008-06-05 18:13:11 +02:00
|
|
|
xcb_query_pointer_cookie_t qp_c = { 0 };
|
2008-04-09 18:27:25 +02:00
|
|
|
xcb_query_pointer_reply_t *qp_r = NULL;
|
|
|
|
xcb_get_geometry_cookie_t geom_c;
|
|
|
|
xcb_get_geometry_reply_t *geom_r;
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_screen_iterator_t iter;
|
|
|
|
|
2008-06-21 12:56:51 +02:00
|
|
|
wa_c = xcb_get_window_attributes_unchecked(connection, ev->window);
|
2008-04-09 18:27:25 +02:00
|
|
|
|
|
|
|
if(!(wa_r = xcb_get_window_attributes_reply(connection, wa_c, NULL)))
|
2008-03-21 16:50:17 +01:00
|
|
|
return -1;
|
2008-04-09 18:27:25 +02:00
|
|
|
|
|
|
|
if(wa_r->override_redirect)
|
2008-06-05 18:13:11 +02:00
|
|
|
goto bailout;
|
2008-03-30 15:46:58 +02:00
|
|
|
|
2008-06-14 18:12:16 +02:00
|
|
|
if(xembed_getbywin(globalconf.embedded, ev->window))
|
|
|
|
{
|
|
|
|
xcb_map_window(connection, ev->window);
|
|
|
|
xembed_window_activate(connection, ev->window);
|
|
|
|
}
|
2008-06-27 22:50:10 +02:00
|
|
|
else if((c = client_getbywin(ev->window)))
|
|
|
|
{
|
2008-08-11 11:57:57 +02:00
|
|
|
if(client_maybevisible(c, c->screen))
|
2008-06-28 11:47:29 +02:00
|
|
|
{
|
2008-08-11 11:57:57 +02:00
|
|
|
c->ishidden = false;
|
2008-08-11 12:30:18 +02:00
|
|
|
globalconf.screens[c->screen].need_arrange = true;
|
2008-06-28 11:47:29 +02:00
|
|
|
xcb_map_window(globalconf.connection, ev->window);
|
|
|
|
/* it will be raised, so just update ourself */
|
|
|
|
client_raise(c);
|
|
|
|
}
|
2008-06-27 22:50:10 +02:00
|
|
|
}
|
|
|
|
else
|
2008-05-20 20:30:07 +02:00
|
|
|
{
|
2008-06-21 12:56:51 +02:00
|
|
|
geom_c = xcb_get_geometry_unchecked(connection, ev->window);
|
2008-05-20 20:30:07 +02:00
|
|
|
|
|
|
|
if(globalconf.screens_info->xinerama_is_active)
|
2008-06-21 12:56:51 +02:00
|
|
|
qp_c = xcb_query_pointer_unchecked(connection, xutil_screen_get(globalconf.connection,
|
|
|
|
screen_nbr)->root);
|
2008-05-20 20:30:07 +02:00
|
|
|
|
2008-04-09 18:27:25 +02:00
|
|
|
if(!(geom_r = xcb_get_geometry_reply(connection, geom_c, NULL)))
|
2008-05-20 20:30:07 +02:00
|
|
|
{
|
|
|
|
if(globalconf.screens_info->xinerama_is_active)
|
|
|
|
{
|
|
|
|
qp_r = xcb_query_pointer_reply(connection, qp_c, NULL);
|
|
|
|
p_delete(&qp_r);
|
|
|
|
}
|
2008-06-30 13:06:23 +02:00
|
|
|
ret = -1;
|
|
|
|
goto bailout;
|
2008-05-20 20:30:07 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-03-13 09:31:35 +01:00
|
|
|
if(globalconf.screens_info->xinerama_is_active
|
2008-04-09 18:27:25 +02:00
|
|
|
&& (qp_r = xcb_query_pointer_reply(connection, qp_c, NULL)))
|
2008-03-30 15:46:58 +02:00
|
|
|
{
|
|
|
|
screen_nbr = screen_get_bycoord(globalconf.screens_info, screen_nbr,
|
2008-04-09 18:27:25 +02:00
|
|
|
qp_r->root_x, qp_r->root_y);
|
|
|
|
p_delete(&qp_r);
|
2008-03-30 15:46:58 +02:00
|
|
|
}
|
|
|
|
else
|
2008-04-09 18:27:25 +02:00
|
|
|
for(iter = xcb_setup_roots_iterator(xcb_get_setup(connection)), screen_nbr = 0;
|
|
|
|
iter.rem && iter.data->root != geom_r->root; xcb_screen_next (&iter), ++screen_nbr);
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-04-09 18:27:25 +02:00
|
|
|
client_manage(ev->window, geom_r, screen_nbr);
|
|
|
|
p_delete(&geom_r);
|
2007-09-16 00:11:10 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-06-05 18:13:11 +02:00
|
|
|
bailout:
|
|
|
|
p_delete(&wa_r);
|
2008-06-30 13:06:23 +02:00
|
|
|
return ret;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The property notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_propertynotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection, xcb_property_notify_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-06-14 18:12:16 +02:00
|
|
|
xembed_window_t *emwin;
|
2007-09-05 20:15:00 +02:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->state == XCB_PROPERTY_DELETE)
|
|
|
|
return 0; /* ignore */
|
2008-07-28 17:13:30 +02:00
|
|
|
else if((emwin = xembed_getbywin(globalconf.embedded, ev->window)))
|
2008-06-14 18:12:16 +02:00
|
|
|
xembed_property_update(connection, emwin);
|
|
|
|
else if((c = client_getbywin(ev->window)))
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
if(ev->atom == WM_TRANSIENT_FOR)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-08-21 17:52:44 +02:00
|
|
|
if(!c->isfloating && !c->isfullscreen)
|
2008-08-21 15:36:54 +02:00
|
|
|
{
|
|
|
|
xcb_window_t trans;
|
|
|
|
xcb_get_wm_transient_for_reply(connection,
|
|
|
|
xcb_get_wm_transient_for_unchecked(connection,
|
|
|
|
c->win),
|
|
|
|
&trans, NULL);
|
|
|
|
if(client_getbywin(trans))
|
|
|
|
client_setfloating(c, true);
|
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
}
|
|
|
|
else if (ev->atom == WM_NORMAL_HINTS)
|
2008-08-26 16:07:53 +02:00
|
|
|
client_updatesizehints(c);
|
2008-03-21 16:50:17 +01:00
|
|
|
else if (ev->atom == WM_HINTS)
|
2007-12-23 15:16:10 +01:00
|
|
|
client_updatewmhints(c);
|
2008-07-08 08:42:39 +02:00
|
|
|
else if(ev->atom == WM_NAME || ev->atom == _NET_WM_NAME)
|
2008-07-08 18:04:08 +02:00
|
|
|
client_updatetitle(c);
|
2008-08-11 23:10:02 +02:00
|
|
|
else if(ev->atom == _NET_WM_ICON)
|
|
|
|
{
|
2008-08-13 02:02:19 +02:00
|
|
|
xcb_get_property_cookie_t icon_q = ewmh_window_icon_get_unchecked(c->win);
|
2008-08-11 23:10:02 +02:00
|
|
|
netwm_icon_delete(&c->icon);
|
|
|
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
2008-08-13 02:02:19 +02:00
|
|
|
c->icon = ewmh_window_icon_get_reply(icon_q);
|
2008-08-11 23:10:02 +02:00
|
|
|
}
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
2008-03-21 16:50:17 +01:00
|
|
|
|
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The unmap notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_unmapnotify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection, xcb_unmap_notify_event_t *ev)
|
2007-09-05 20:15:00 +02:00
|
|
|
{
|
2008-04-11 11:35:11 +02:00
|
|
|
client_t *c;
|
2008-06-14 18:12:16 +02:00
|
|
|
xembed_window_t *em;
|
|
|
|
int i;
|
2008-03-21 16:50:17 +01:00
|
|
|
|
2008-06-29 13:38:02 +02:00
|
|
|
if((c = client_getbywin(ev->window)))
|
|
|
|
{
|
|
|
|
if(ev->event == xutil_screen_get(connection, c->phys_screen)->root
|
2008-09-16 15:36:44 +02:00
|
|
|
&& XCB_EVENT_SENT(ev)
|
2008-09-09 16:14:36 +02:00
|
|
|
&& window_state_get_reply(window_state_get_unchecked(c->win)) == XCB_WM_STATE_NORMAL)
|
2008-06-29 13:38:02 +02:00
|
|
|
client_unmanage(c);
|
|
|
|
}
|
|
|
|
else if((em = xembed_getbywin(globalconf.embedded, ev->window)))
|
2008-06-14 18:12:16 +02:00
|
|
|
{
|
|
|
|
xembed_window_list_detach(&globalconf.embedded, em);
|
|
|
|
for(i = 0; i < globalconf.screens_info->nscreen; i++)
|
|
|
|
widget_invalidate_cache(i, WIDGET_CACHE_EMBEDDED);
|
|
|
|
}
|
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
return 0;
|
2007-09-05 20:15:00 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The randr screen change notify event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_randr_screen_change_notify(void *data __attribute__ ((unused)),
|
|
|
|
xcb_connection_t *connection __attribute__ ((unused)),
|
|
|
|
xcb_randr_screen_change_notify_event_t *ev)
|
2007-09-13 16:00:03 +02:00
|
|
|
{
|
2008-03-21 16:50:17 +01:00
|
|
|
if(!globalconf.have_randr)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Code of XRRUpdateConfiguration Xlib function ported to XCB
|
|
|
|
* (only the code relevant to RRScreenChangeNotify) as the latter
|
|
|
|
* doesn't provide this kind of function */
|
|
|
|
if(ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270))
|
|
|
|
xcb_randr_set_screen_size(connection, ev->root, ev->height, ev->width,
|
|
|
|
ev->mheight, ev->mwidth);
|
|
|
|
else
|
|
|
|
xcb_randr_set_screen_size(connection, ev->root, ev->width, ev->height,
|
|
|
|
ev->mwidth, ev->mheight);
|
|
|
|
|
2008-03-28 22:59:05 +01:00
|
|
|
/* XRRUpdateConfiguration also executes the following instruction
|
|
|
|
* but it's not useful because SubpixelOrder is not used at all at
|
|
|
|
* the moment
|
2008-03-21 16:50:17 +01:00
|
|
|
*
|
|
|
|
* XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order);
|
|
|
|
*/
|
|
|
|
|
2008-09-02 17:12:10 +02:00
|
|
|
awesome_restart();
|
2008-07-18 20:08:03 +02:00
|
|
|
|
2008-03-21 16:50:17 +01:00
|
|
|
return 0;
|
2007-09-13 16:00:03 +02:00
|
|
|
}
|
|
|
|
|
2008-06-13 18:20:20 +02:00
|
|
|
/** The client message event handler.
|
|
|
|
* \param data currently unused.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
2008-03-06 09:05:15 +01:00
|
|
|
*/
|
2008-06-26 22:42:58 +02:00
|
|
|
static int
|
2008-03-21 16:50:17 +01:00
|
|
|
event_handle_clientmessage(void *data __attribute__ ((unused)),
|
2008-06-14 18:12:16 +02:00
|
|
|
xcb_connection_t *connection,
|
2008-03-21 16:50:17 +01:00
|
|
|
xcb_client_message_event_t *ev)
|
2007-12-27 20:49:38 +01:00
|
|
|
{
|
2008-07-28 17:13:30 +02:00
|
|
|
client_t *c;
|
|
|
|
|
|
|
|
if(ev->type == WM_CHANGE_STATE)
|
|
|
|
{
|
|
|
|
if((c = client_getbywin(ev->window))
|
|
|
|
&& ev->format == 32
|
2008-09-09 16:14:36 +02:00
|
|
|
&& ev->data.data32[0] == XCB_WM_STATE_ICONIC)
|
2008-07-28 17:13:30 +02:00
|
|
|
{
|
2008-08-21 15:36:54 +02:00
|
|
|
client_need_arrange(c);
|
2008-07-28 17:13:30 +02:00
|
|
|
c->ishidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ev->type == _XEMBED)
|
2008-06-14 18:12:16 +02:00
|
|
|
return xembed_process_client_message(ev);
|
2008-06-30 18:55:14 +02:00
|
|
|
else if(ev->type == _NET_SYSTEM_TRAY_OPCODE)
|
2008-06-14 18:12:16 +02:00
|
|
|
return systray_process_client_message(ev);
|
|
|
|
return ewmh_process_client_message(ev);
|
2007-12-27 20:49:38 +01:00
|
|
|
}
|
|
|
|
|
2008-09-07 23:22:53 +02:00
|
|
|
/** The keymap change notify event handler.
|
|
|
|
* \param data Unused data.
|
|
|
|
* \param connection The connection to the X server.
|
|
|
|
* \param ev The event.
|
|
|
|
* \return Status code, 0 if everything's fine.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
event_handle_mappingnotify(void *data,
|
|
|
|
xcb_connection_t *connection,
|
|
|
|
xcb_mapping_notify_event_t *ev)
|
|
|
|
{
|
|
|
|
xcb_get_modifier_mapping_cookie_t xmapping_cookie;
|
|
|
|
|
|
|
|
if(ev->request == XCB_MAPPING_MODIFIER
|
|
|
|
|| ev->request == XCB_MAPPING_KEYBOARD)
|
|
|
|
{
|
|
|
|
/* Send the request to get the NumLock, ShiftLock and CapsLock masks */
|
|
|
|
xmapping_cookie = xcb_get_modifier_mapping_unchecked(globalconf.connection);
|
|
|
|
|
|
|
|
/* Free and then allocate the key symbols */
|
|
|
|
xcb_key_symbols_free(globalconf.keysyms);
|
|
|
|
globalconf.keysyms = xcb_key_symbols_alloc(globalconf.connection);
|
|
|
|
|
|
|
|
/* Process the reply of previously sent mapping request */
|
|
|
|
xutil_lock_mask_get(globalconf.connection, xmapping_cookie,
|
|
|
|
globalconf.keysyms, &globalconf.numlockmask,
|
|
|
|
&globalconf.shiftlockmask, &globalconf.capslockmask);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-26 22:42:58 +02:00
|
|
|
void a_xcb_set_event_handlers(void)
|
|
|
|
{
|
|
|
|
const xcb_query_extension_reply_t *randr_query;
|
|
|
|
|
2008-08-12 13:23:10 +02:00
|
|
|
xcb_event_set_button_press_handler(&globalconf.evenths, event_handle_button, NULL);
|
|
|
|
xcb_event_set_button_release_handler(&globalconf.evenths, event_handle_button, NULL);
|
2008-09-16 15:36:44 +02:00
|
|
|
xcb_event_set_configure_request_handler(&globalconf.evenths, event_handle_configurerequest, NULL);
|
|
|
|
xcb_event_set_configure_notify_handler(&globalconf.evenths, event_handle_configurenotify, NULL);
|
|
|
|
xcb_event_set_destroy_notify_handler(&globalconf.evenths, event_handle_destroynotify, NULL);
|
|
|
|
xcb_event_set_enter_notify_handler(&globalconf.evenths, event_handle_enternotify, NULL);
|
2008-08-25 14:34:56 +02:00
|
|
|
xcb_event_set_leave_notify_handler(&globalconf.evenths, event_handle_leavenotify, NULL);
|
|
|
|
xcb_event_set_motion_notify_handler(&globalconf.evenths, event_handle_motionnotify, NULL);
|
2008-09-16 15:36:44 +02:00
|
|
|
xcb_event_set_expose_handler(&globalconf.evenths, event_handle_expose, NULL);
|
|
|
|
xcb_event_set_key_press_handler(&globalconf.evenths, event_handle_keypress, NULL);
|
|
|
|
xcb_event_set_map_request_handler(&globalconf.evenths, event_handle_maprequest, NULL);
|
|
|
|
xcb_event_set_property_notify_handler(&globalconf.evenths, event_handle_propertynotify, NULL);
|
|
|
|
xcb_event_set_unmap_notify_handler(&globalconf.evenths, event_handle_unmapnotify, NULL);
|
|
|
|
xcb_event_set_client_message_handler(&globalconf.evenths, event_handle_clientmessage, NULL);
|
|
|
|
xcb_event_set_mapping_notify_handler(&globalconf.evenths, event_handle_mappingnotify, NULL);
|
2008-06-26 22:42:58 +02:00
|
|
|
|
|
|
|
/* check for randr extension */
|
|
|
|
randr_query = xcb_get_extension_data(globalconf.connection, &xcb_randr_id);
|
|
|
|
if((globalconf.have_randr = randr_query->present))
|
2008-09-16 15:36:44 +02:00
|
|
|
xcb_event_set_handler(&globalconf.evenths,
|
|
|
|
randr_query->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY,
|
2008-06-26 22:42:58 +02:00
|
|
|
(xcb_generic_event_handler_t) event_handle_randr_screen_change_notify,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|