2003-03-16 21:11:39 +00:00
|
|
|
#include "openbox.h"
|
2003-05-10 20:52:32 +00:00
|
|
|
#include "slit.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "client.h"
|
|
|
|
#include "xerror.h"
|
|
|
|
#include "prop.h"
|
2003-04-08 07:31:26 +00:00
|
|
|
#include "config.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "screen.h"
|
|
|
|
#include "frame.h"
|
2003-04-16 05:36:51 +00:00
|
|
|
#include "menu.h"
|
2003-04-13 07:18:28 +00:00
|
|
|
#include "framerender.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "focus.h"
|
2003-04-17 05:28:35 +00:00
|
|
|
#include "moveresize.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
#include "stacking.h"
|
|
|
|
#include "extensions.h"
|
|
|
|
#include "timer.h"
|
2003-03-17 20:16:32 +00:00
|
|
|
#include "dispatch.h"
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/Xatom.h>
|
2003-03-21 20:25:34 +00:00
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
# include <sys/select.h>
|
|
|
|
#endif
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
static void event_process(XEvent *e);
|
|
|
|
static void event_handle_root(XEvent *e);
|
2003-05-10 22:33:24 +00:00
|
|
|
static void event_handle_slit(Slit *s, XEvent *e);
|
2003-05-10 20:52:32 +00:00
|
|
|
static void event_handle_slitapp(SlitApp *app, XEvent *e);
|
2003-03-16 21:11:39 +00:00
|
|
|
static void event_handle_client(Client *c, XEvent *e);
|
2003-04-16 05:36:51 +00:00
|
|
|
static void event_handle_menu(Menu *menu, XEvent *e);
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-04-18 08:45:49 +00:00
|
|
|
#define INVALID_FOCUSIN(e) ((e)->xfocus.detail == NotifyInferior || \
|
|
|
|
(e)->xfocus.detail > NotifyNonlinearVirtual)
|
|
|
|
#define INVALID_FOCUSOUT(e) ((e)->xfocus.mode == NotifyGrab || \
|
|
|
|
(e)->xfocus.detail == NotifyInferior || \
|
|
|
|
(e)->xfocus.detail == NotifyAncestor || \
|
|
|
|
(e)->xfocus.detail > NotifyNonlinearVirtual)
|
|
|
|
|
2003-03-16 21:11:39 +00:00
|
|
|
Time event_lasttime = 0;
|
|
|
|
|
|
|
|
/*! The value of the mask for the NumLock modifier */
|
2003-03-19 18:55:21 +00:00
|
|
|
unsigned int NumLockMask;
|
2003-03-16 21:11:39 +00:00
|
|
|
/*! The value of the mask for the ScrollLock modifier */
|
2003-03-19 18:55:21 +00:00
|
|
|
unsigned int ScrollLockMask;
|
2003-03-16 21:11:39 +00:00
|
|
|
/*! The key codes for the modifier keys */
|
|
|
|
static XModifierKeymap *modmap;
|
|
|
|
/*! Table of the constant modifier masks */
|
|
|
|
static const int mask_table[] = {
|
|
|
|
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
|
|
|
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
|
|
|
};
|
|
|
|
static int mask_table_size;
|
|
|
|
|
|
|
|
void event_startup()
|
|
|
|
{
|
|
|
|
mask_table_size = sizeof(mask_table) / sizeof(mask_table[0]);
|
|
|
|
|
|
|
|
/* get lock masks that are defined by the display (not constant) */
|
|
|
|
modmap = XGetModifierMapping(ob_display);
|
|
|
|
g_assert(modmap);
|
|
|
|
if (modmap && modmap->max_keypermod > 0) {
|
|
|
|
size_t cnt;
|
|
|
|
const size_t size = mask_table_size * modmap->max_keypermod;
|
|
|
|
/* get the values of the keyboard lock modifiers
|
|
|
|
Note: Caps lock is not retrieved the same way as Scroll and Num
|
|
|
|
lock since it doesn't need to be. */
|
|
|
|
const KeyCode num_lock = XKeysymToKeycode(ob_display, XK_Num_Lock);
|
|
|
|
const KeyCode scroll_lock = XKeysymToKeycode(ob_display,
|
|
|
|
XK_Scroll_Lock);
|
|
|
|
|
|
|
|
for (cnt = 0; cnt < size; ++cnt) {
|
|
|
|
if (! modmap->modifiermap[cnt]) continue;
|
|
|
|
|
|
|
|
if (num_lock == modmap->modifiermap[cnt])
|
|
|
|
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
|
|
|
if (scroll_lock == modmap->modifiermap[cnt])
|
|
|
|
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void event_shutdown()
|
|
|
|
{
|
|
|
|
XFreeModifiermap(modmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void event_loop()
|
|
|
|
{
|
|
|
|
fd_set selset;
|
|
|
|
XEvent e;
|
|
|
|
int x_fd;
|
|
|
|
struct timeval *wait;
|
2003-04-16 18:09:11 +00:00
|
|
|
gboolean had_event = FALSE;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
/*
|
|
|
|
There are slightly different event retrieval semantics here for
|
|
|
|
local (or high bandwidth) versus remote (or low bandwidth)
|
|
|
|
connections to the display/Xserver.
|
|
|
|
*/
|
|
|
|
if (ob_remote) {
|
|
|
|
if (!XPending(ob_display))
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
This XSync allows for far more compression of events, which
|
|
|
|
makes things like Motion events perform far far better. Since
|
|
|
|
it also means network traffic for every event instead of every
|
|
|
|
X events (where X is the number retrieved at a time), it
|
|
|
|
probably should not be used for setups where Openbox is
|
|
|
|
running on a remote/low bandwidth display/Xserver.
|
|
|
|
*/
|
|
|
|
XSync(ob_display, FALSE);
|
|
|
|
if (!XEventsQueued(ob_display, QueuedAlready))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
XNextEvent(ob_display, &e);
|
|
|
|
|
|
|
|
event_process(&e);
|
2003-05-10 14:50:39 +00:00
|
|
|
had_event = TRUE;
|
2003-04-16 18:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!had_event) {
|
|
|
|
timer_dispatch((GTimeVal**)&wait);
|
|
|
|
x_fd = ConnectionNumber(ob_display);
|
|
|
|
FD_ZERO(&selset);
|
|
|
|
FD_SET(x_fd, &selset);
|
|
|
|
select(x_fd + 1, &selset, NULL, NULL, wait);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-14 17:07:04 +00:00
|
|
|
static Window event_get_window(XEvent *e)
|
2003-03-16 21:11:39 +00:00
|
|
|
{
|
|
|
|
Window window;
|
|
|
|
|
|
|
|
/* pick a window */
|
|
|
|
switch (e->type) {
|
2003-03-23 19:39:20 +00:00
|
|
|
case MapRequest:
|
|
|
|
window = e->xmap.window;
|
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
case UnmapNotify:
|
|
|
|
window = e->xunmap.window;
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
window = e->xdestroywindow.window;
|
|
|
|
break;
|
|
|
|
case ConfigureRequest:
|
|
|
|
window = e->xconfigurerequest.window;
|
|
|
|
break;
|
2003-05-09 16:57:17 +00:00
|
|
|
case ConfigureNotify:
|
|
|
|
window = e->xconfigure.window;
|
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
default:
|
2003-03-24 19:07:28 +00:00
|
|
|
#ifdef XKB
|
|
|
|
if (extensions_xkb && e->type == extensions_xkb_event_basep) {
|
2003-03-16 21:11:39 +00:00
|
|
|
switch (((XkbAnyEvent*)&e)->xkb_type) {
|
|
|
|
case XkbBellNotify:
|
|
|
|
window = ((XkbBellNotifyEvent*)&e)->window;
|
|
|
|
default:
|
|
|
|
window = None;
|
|
|
|
}
|
2003-03-24 19:07:28 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
window = e->xany.window;
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
2003-04-14 17:07:04 +00:00
|
|
|
return window;
|
|
|
|
}
|
2003-03-28 11:05:38 +00:00
|
|
|
|
2003-04-14 17:07:04 +00:00
|
|
|
static void event_set_lasttime(XEvent *e)
|
|
|
|
{
|
2003-03-16 21:11:39 +00:00
|
|
|
/* grab the lasttime and hack up the state */
|
|
|
|
switch (e->type) {
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
event_lasttime = e->xbutton.time;
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
event_lasttime = e->xkey.time;
|
|
|
|
break;
|
|
|
|
case KeyRelease:
|
|
|
|
event_lasttime = e->xkey.time;
|
2003-04-14 17:07:04 +00:00
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
event_lasttime = e->xmotion.time;
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
event_lasttime = e->xproperty.time;
|
|
|
|
break;
|
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
|
|
|
event_lasttime = e->xcrossing.time;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
event_lasttime = CurrentTime;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STRIP_MODS(s) \
|
|
|
|
s &= ~(LockMask | NumLockMask | ScrollLockMask), \
|
|
|
|
/* kill off the Button1Mask etc, only want the modifiers */ \
|
|
|
|
s &= (ControlMask | ShiftMask | Mod1Mask | \
|
|
|
|
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) \
|
|
|
|
|
|
|
|
static void event_hack_mods(XEvent *e)
|
|
|
|
{
|
|
|
|
KeyCode *kp;
|
|
|
|
int i, k;
|
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
STRIP_MODS(e->xbutton.state);
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
STRIP_MODS(e->xkey.state);
|
|
|
|
break;
|
|
|
|
case KeyRelease:
|
|
|
|
STRIP_MODS(e->xkey.state);
|
2003-03-16 21:11:39 +00:00
|
|
|
/* remove from the state the mask of the modifier being released, if
|
|
|
|
it is a modifier key being released (this is a little ugly..) */
|
|
|
|
kp = modmap->modifiermap;
|
|
|
|
for (i = 0; i < mask_table_size; ++i) {
|
|
|
|
for (k = 0; k < modmap->max_keypermod; ++k) {
|
|
|
|
if (*kp == e->xkey.keycode) { /* found the keycode */
|
|
|
|
/* remove the mask for it */
|
|
|
|
e->xkey.state &= ~mask_table[i];
|
|
|
|
/* cause the first loop to break; */
|
|
|
|
i = mask_table_size;
|
|
|
|
break; /* get outta here! */
|
|
|
|
}
|
|
|
|
++kp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
2003-04-14 17:07:04 +00:00
|
|
|
STRIP_MODS(e->xmotion.state);
|
2003-03-16 21:11:39 +00:00
|
|
|
/* compress events */
|
2003-04-14 17:07:04 +00:00
|
|
|
{
|
|
|
|
XEvent ce;
|
|
|
|
while (XCheckTypedWindowEvent(ob_display, e->xmotion.window,
|
|
|
|
e->type, &ce)) {
|
|
|
|
e->xmotion.x_root = ce.xmotion.x_root;
|
|
|
|
e->xmotion.y_root = ce.xmotion.y_root;
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-04-14 17:07:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean event_ignore(XEvent *e, Client *client)
|
|
|
|
{
|
|
|
|
switch(e->type) {
|
2003-03-16 21:11:39 +00:00
|
|
|
case FocusIn:
|
2003-03-28 10:46:25 +00:00
|
|
|
/* NotifyAncestor is not ignored in FocusIn like it is in FocusOut
|
|
|
|
because of RevertToPointerRoot. If the focus ends up reverting to
|
|
|
|
pointer root on a workspace change, then the FocusIn event that we
|
|
|
|
want will be of type NotifyAncestor. This situation does not occur
|
|
|
|
for FocusOut, so it is safely ignored there.
|
|
|
|
*/
|
2003-04-18 08:45:49 +00:00
|
|
|
if (INVALID_FOCUSIN(e) ||
|
2003-03-31 06:36:59 +00:00
|
|
|
client == NULL) {
|
2003-04-18 08:45:49 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("FocusIn on %lx mode %d detail %d IGNORED", e->xfocus.window,
|
|
|
|
e->xfocus.mode, e->xfocus.detail);
|
|
|
|
#endif
|
2003-03-30 22:58:04 +00:00
|
|
|
/* says a client was not found for the event (or a valid FocusIn
|
|
|
|
event was not found.
|
|
|
|
*/
|
|
|
|
e->xfocus.window = None;
|
2003-04-14 17:07:04 +00:00
|
|
|
return TRUE;
|
2003-03-30 22:58:04 +00:00
|
|
|
}
|
|
|
|
|
2003-04-07 07:29:00 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-04-18 08:45:49 +00:00
|
|
|
g_message("FocusIn on %lx mode %d detail %d", e->xfocus.window,
|
|
|
|
e->xfocus.mode, e->xfocus.detail);
|
2003-04-07 07:29:00 +00:00
|
|
|
#endif
|
2003-03-24 00:46:21 +00:00
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
case FocusOut:
|
2003-04-18 08:45:49 +00:00
|
|
|
if (INVALID_FOCUSOUT(e)) {
|
2003-04-07 07:29:00 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-04-18 08:45:49 +00:00
|
|
|
g_message("FocusOut on %lx mode %d detail %d IGNORED",
|
|
|
|
e->xfocus.window, e->xfocus.mode, e->xfocus.detail);
|
2003-04-07 07:29:00 +00:00
|
|
|
#endif
|
2003-04-18 08:45:49 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-04-07 07:29:00 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-04-18 08:45:49 +00:00
|
|
|
g_message("FocusOut on %lx mode %d detail %d",
|
|
|
|
e->xfocus.window, e->xfocus.mode, e->xfocus.detail);
|
2003-04-07 07:29:00 +00:00
|
|
|
#endif
|
2003-04-18 08:45:49 +00:00
|
|
|
|
2003-03-24 00:46:21 +00:00
|
|
|
{
|
2003-04-18 08:45:49 +00:00
|
|
|
XEvent fe;
|
|
|
|
gboolean fallback = TRUE;
|
2003-03-31 06:36:59 +00:00
|
|
|
|
2003-04-18 08:45:49 +00:00
|
|
|
while (TRUE) {
|
2003-04-19 18:30:58 +00:00
|
|
|
if (!XCheckTypedWindowEvent(ob_display, FocusOut,
|
|
|
|
e->xfocus.window,&fe))
|
2003-04-18 08:45:49 +00:00
|
|
|
if (!XCheckTypedEvent(ob_display, FocusIn, &fe))
|
|
|
|
break;
|
|
|
|
if (fe.type == FocusOut) {
|
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("found pending FocusOut");
|
|
|
|
#endif
|
|
|
|
if (!INVALID_FOCUSOUT(&fe)) {
|
|
|
|
/* if there is a VALID FocusOut still coming, don't
|
|
|
|
fallback focus yet, we'll deal with it then */
|
|
|
|
XPutBackEvent(ob_display, &fe);
|
|
|
|
fallback = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("found pending FocusIn");
|
|
|
|
#endif
|
2003-05-09 16:57:17 +00:00
|
|
|
/* is the focused window getting a FocusOut/In back to
|
|
|
|
itself? */
|
2003-05-10 15:51:44 +00:00
|
|
|
if (fe.xfocus.window == e->xfocus.window &&
|
|
|
|
!event_ignore(&fe, client)) {
|
2003-05-09 16:57:17 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("focused window got an Out/In back to "
|
|
|
|
"itself IGNORED both");
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-04-18 08:45:49 +00:00
|
|
|
/* once all the FocusOut's have been dealt with, if there
|
|
|
|
is a FocusIn still left and it is valid, then use it */
|
|
|
|
event_process(&fe);
|
|
|
|
/* secret magic way of event_process telling us that no
|
|
|
|
client was found for the FocusIn event. ^_^ */
|
|
|
|
if (fe.xfocus.window != None) {
|
|
|
|
fallback = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fallback) {
|
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("no valid FocusIn and no FocusOut events found, "
|
|
|
|
"falling back");
|
|
|
|
#endif
|
2003-04-08 06:14:53 +00:00
|
|
|
focus_fallback(Fallback_NoFocus);
|
2003-04-18 08:45:49 +00:00
|
|
|
}
|
2003-03-24 00:46:21 +00:00
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
break;
|
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
2003-03-26 07:07:55 +00:00
|
|
|
/* NotifyUngrab occurs when a mouse button is released and the event is
|
|
|
|
caused, like when lowering a window */
|
2003-04-18 22:05:39 +00:00
|
|
|
/* NotifyVirtual occurs when ungrabbing the pointer */
|
2003-04-07 22:27:02 +00:00
|
|
|
if (e->xcrossing.mode == NotifyGrab ||
|
2003-04-17 01:48:26 +00:00
|
|
|
e->xcrossing.detail == NotifyInferior ||
|
2003-04-17 08:04:45 +00:00
|
|
|
(e->xcrossing.mode == NotifyUngrab &&
|
2003-04-18 22:05:39 +00:00
|
|
|
e->xcrossing.detail == NotifyVirtual)) {
|
2003-04-18 22:12:34 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-04-18 22:05:39 +00:00
|
|
|
g_message("%sNotify mode %d detail %d on %lx IGNORED",
|
|
|
|
(e->type == EnterNotify ? "Enter" : "Leave"),
|
2003-04-18 21:56:53 +00:00
|
|
|
e->xcrossing.mode,
|
|
|
|
e->xcrossing.detail, client?client->window:0);
|
|
|
|
#endif
|
2003-04-14 17:07:04 +00:00
|
|
|
return TRUE;
|
2003-04-18 21:56:53 +00:00
|
|
|
}
|
2003-04-18 22:12:34 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-04-18 22:05:39 +00:00
|
|
|
g_message("%sNotify mode %d detail %d on %lx",
|
|
|
|
(e->type == EnterNotify ? "Enter" : "Leave"),
|
|
|
|
e->xcrossing.mode,
|
2003-04-18 21:56:53 +00:00
|
|
|
e->xcrossing.detail, client?client->window:0);
|
|
|
|
#endif
|
2003-03-16 21:11:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-04-14 17:07:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_process(XEvent *e)
|
|
|
|
{
|
|
|
|
Window window;
|
2003-05-10 20:52:32 +00:00
|
|
|
Client *client = NULL;
|
2003-05-10 22:33:24 +00:00
|
|
|
Slit *slit = NULL;
|
2003-05-10 20:52:32 +00:00
|
|
|
SlitApp *slitapp = NULL;
|
2003-04-16 05:36:51 +00:00
|
|
|
Menu *menu = NULL;
|
2003-04-14 17:07:04 +00:00
|
|
|
|
|
|
|
window = event_get_window(e);
|
2003-04-16 05:36:51 +00:00
|
|
|
if (!(client = g_hash_table_lookup(client_map, &window)))
|
2003-05-10 22:20:08 +00:00
|
|
|
if (!(slitapp = g_hash_table_lookup(slit_app_map, &window)))
|
2003-05-10 22:33:24 +00:00
|
|
|
if (!(slit = g_hash_table_lookup(slit_map, &window)))
|
|
|
|
menu = g_hash_table_lookup(menu_map, &window);
|
2003-05-09 23:15:28 +00:00
|
|
|
|
2003-04-14 17:07:04 +00:00
|
|
|
event_set_lasttime(e);
|
|
|
|
event_hack_mods(e);
|
|
|
|
if (event_ignore(e, client))
|
|
|
|
return;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
2003-03-17 20:16:32 +00:00
|
|
|
/* deal with it in the kernel */
|
2003-04-16 19:41:22 +00:00
|
|
|
if (menu) {
|
2003-04-16 05:36:51 +00:00
|
|
|
event_handle_menu(menu, e);
|
2003-04-16 19:41:22 +00:00
|
|
|
return;
|
|
|
|
} else if (client)
|
2003-03-16 21:11:39 +00:00
|
|
|
event_handle_client(client, e);
|
2003-05-10 20:52:32 +00:00
|
|
|
else if (slitapp)
|
|
|
|
event_handle_slitapp(slitapp, e);
|
2003-05-10 22:33:24 +00:00
|
|
|
else if (slit)
|
|
|
|
event_handle_slit(slit, e);
|
2003-03-23 19:39:20 +00:00
|
|
|
else if (window == ob_root)
|
2003-03-16 21:11:39 +00:00
|
|
|
event_handle_root(e);
|
2003-03-23 19:39:20 +00:00
|
|
|
else if (e->type == MapRequest)
|
|
|
|
client_manage(window);
|
2003-03-16 21:11:39 +00:00
|
|
|
else if (e->type == ConfigureRequest) {
|
|
|
|
/* unhandled configure requests must be used to configure the
|
|
|
|
window directly */
|
|
|
|
XWindowChanges xwc;
|
|
|
|
|
|
|
|
xwc.x = e->xconfigurerequest.x;
|
|
|
|
xwc.y = e->xconfigurerequest.y;
|
|
|
|
xwc.width = e->xconfigurerequest.width;
|
|
|
|
xwc.height = e->xconfigurerequest.height;
|
|
|
|
xwc.border_width = e->xconfigurerequest.border_width;
|
|
|
|
xwc.sibling = e->xconfigurerequest.above;
|
|
|
|
xwc.stack_mode = e->xconfigurerequest.detail;
|
|
|
|
|
|
|
|
/* we are not to be held responsible if someone sends us an
|
|
|
|
invalid request! */
|
|
|
|
xerror_set_ignore(TRUE);
|
|
|
|
XConfigureWindow(ob_display, window,
|
|
|
|
e->xconfigurerequest.value_mask, &xwc);
|
|
|
|
xerror_set_ignore(FALSE);
|
|
|
|
}
|
|
|
|
|
2003-04-17 05:28:35 +00:00
|
|
|
if (moveresize_in_progress)
|
|
|
|
if (e->type == MotionNotify || e->type == ButtonRelease ||
|
|
|
|
e->type == ButtonPress ||
|
|
|
|
e->type == KeyPress || e->type == KeyRelease) {
|
|
|
|
moveresize_event(e);
|
2003-04-18 22:27:24 +00:00
|
|
|
|
2003-04-18 22:31:00 +00:00
|
|
|
return; /* no dispatch! */
|
|
|
|
|
2003-04-17 05:28:35 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 17:07:04 +00:00
|
|
|
/* user input (action-bound) events */
|
|
|
|
/*
|
|
|
|
if (e->type == ButtonPress || e->type == ButtonRelease ||
|
|
|
|
e->type == MotionNotify)
|
|
|
|
mouse_event(e, client);
|
|
|
|
else if (e->type == KeyPress || e->type == KeyRelease)
|
|
|
|
;
|
|
|
|
*/
|
|
|
|
|
2003-03-17 20:16:32 +00:00
|
|
|
/* dispatch the event to registered handlers */
|
|
|
|
dispatch_x(e, client);
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void event_handle_root(XEvent *e)
|
|
|
|
{
|
|
|
|
Atom msgtype;
|
|
|
|
|
|
|
|
switch(e->type) {
|
|
|
|
case ClientMessage:
|
|
|
|
if (e->xclient.format != 32) break;
|
|
|
|
|
|
|
|
msgtype = e->xclient.message_type;
|
|
|
|
if (msgtype == prop_atoms.net_current_desktop) {
|
|
|
|
unsigned int d = e->xclient.data.l[0];
|
2003-03-26 08:29:34 +00:00
|
|
|
if (d < screen_num_desktops)
|
2003-03-16 21:11:39 +00:00
|
|
|
screen_set_desktop(d);
|
|
|
|
} else if (msgtype == prop_atoms.net_number_of_desktops) {
|
|
|
|
unsigned int d = e->xclient.data.l[0];
|
|
|
|
if (d > 0)
|
|
|
|
screen_set_num_desktops(d);
|
|
|
|
} else if (msgtype == prop_atoms.net_showing_desktop) {
|
|
|
|
screen_show_desktop(e->xclient.data.l[0] != 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
if (e->xproperty.atom == prop_atoms.net_desktop_names)
|
|
|
|
screen_update_desktop_names();
|
|
|
|
else if (e->xproperty.atom == prop_atoms.net_desktop_layout)
|
|
|
|
screen_update_layout();
|
|
|
|
break;
|
2003-05-09 16:57:17 +00:00
|
|
|
case ConfigureNotify:
|
|
|
|
#ifdef XRANDR
|
|
|
|
XRRUpdateConfiguration(e);
|
|
|
|
#endif
|
|
|
|
if (e->xconfigure.width != screen_physical_size.width ||
|
|
|
|
e->xconfigure.height != screen_physical_size.height)
|
|
|
|
screen_resize(e->xconfigure.width, e->xconfigure.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
#ifdef VIDMODE
|
|
|
|
if (extensions_vidmode && e->type == extensions_vidmode_event_basep) {
|
|
|
|
g_message("VIDMODE EVENT");
|
|
|
|
}
|
|
|
|
#endif
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_handle_client(Client *client, XEvent *e)
|
|
|
|
{
|
|
|
|
XEvent ce;
|
|
|
|
Atom msgtype;
|
2003-03-27 23:10:22 +00:00
|
|
|
int i=0;
|
2003-03-16 21:11:39 +00:00
|
|
|
|
|
|
|
switch (e->type) {
|
2003-04-13 07:18:28 +00:00
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
2003-04-13 08:36:38 +00:00
|
|
|
switch (frame_context(client, e->xbutton.window)) {
|
2003-04-13 07:18:28 +00:00
|
|
|
case Context_Maximize:
|
|
|
|
client->frame->max_press = (e->type == ButtonPress);
|
|
|
|
framerender_frame(client->frame);
|
|
|
|
break;
|
|
|
|
case Context_Close:
|
|
|
|
client->frame->close_press = (e->type == ButtonPress);
|
|
|
|
framerender_frame(client->frame);
|
|
|
|
break;
|
|
|
|
case Context_Iconify:
|
|
|
|
client->frame->iconify_press = (e->type == ButtonPress);
|
|
|
|
framerender_frame(client->frame);
|
|
|
|
break;
|
|
|
|
case Context_AllDesktops:
|
|
|
|
client->frame->desk_press = (e->type == ButtonPress);
|
|
|
|
framerender_frame(client->frame);
|
|
|
|
break;
|
|
|
|
case Context_Shade:
|
|
|
|
client->frame->shade_press = (e->type == ButtonPress);
|
|
|
|
framerender_frame(client->frame);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* nothing changes with clicks for any other contexts */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
case FocusIn:
|
2003-05-09 16:57:17 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("FocusIn on client for %lx", client->window);
|
|
|
|
#endif
|
2003-03-27 23:10:22 +00:00
|
|
|
focus_set_client(client);
|
2003-05-09 16:57:17 +00:00
|
|
|
frame_adjust_focus(client->frame, TRUE);
|
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
case FocusOut:
|
2003-04-07 07:29:49 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
2003-05-09 16:57:17 +00:00
|
|
|
g_message("FocusOut on client for %lx", client->window);
|
2003-04-07 07:29:49 +00:00
|
|
|
#endif
|
2003-05-09 16:57:17 +00:00
|
|
|
/* are we a fullscreen window or a transient of one? (checks layer)
|
|
|
|
if we are then we need to be iconified since we are losing focus
|
|
|
|
*/
|
|
|
|
if (client->layer == Layer_Fullscreen && !client->iconic &&
|
|
|
|
!client_search_focus_tree_full(client))
|
|
|
|
/* iconify fullscreen windows when they and their transients
|
|
|
|
aren't focused */
|
|
|
|
client_iconify(client, TRUE, TRUE);
|
|
|
|
frame_adjust_focus(client->frame, FALSE);
|
2003-03-16 21:11:39 +00:00
|
|
|
break;
|
2003-03-27 23:10:22 +00:00
|
|
|
case EnterNotify:
|
2003-03-28 01:13:56 +00:00
|
|
|
if (client_normal(client)) {
|
|
|
|
if (ob_state == State_Starting) {
|
|
|
|
/* move it to the top of the focus order */
|
|
|
|
guint desktop = client->desktop;
|
|
|
|
if (desktop == DESKTOP_ALL) desktop = screen_desktop;
|
|
|
|
focus_order[desktop] = g_list_remove(focus_order[desktop],
|
|
|
|
client);
|
|
|
|
focus_order[desktop] = g_list_prepend(focus_order[desktop],
|
|
|
|
client);
|
2003-04-08 07:31:26 +00:00
|
|
|
} else if (config_focus_follow) {
|
2003-04-07 22:27:02 +00:00
|
|
|
#ifdef DEBUG_FOCUS
|
|
|
|
g_message("EnterNotify on %lx, focusing window",
|
|
|
|
client->window);
|
|
|
|
#endif
|
2003-04-05 20:27:03 +00:00
|
|
|
client_focus(client);
|
2003-04-07 22:27:02 +00:00
|
|
|
}
|
2003-03-27 23:10:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-03-16 21:11:39 +00:00
|
|
|
case ConfigureRequest:
|
|
|
|
/* compress these */
|
|
|
|
while (XCheckTypedWindowEvent(ob_display, client->window,
|
|
|
|
ConfigureRequest, &ce)) {
|
2003-03-24 19:52:09 +00:00
|
|
|
++i;
|
2003-03-16 21:11:39 +00:00
|
|
|
/* XXX if this causes bad things.. we can compress config req's
|
|
|
|
with the same mask. */
|
|
|
|
e->xconfigurerequest.value_mask |=
|
|
|
|
ce.xconfigurerequest.value_mask;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWX)
|
|
|
|
e->xconfigurerequest.x = ce.xconfigurerequest.x;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWY)
|
|
|
|
e->xconfigurerequest.y = ce.xconfigurerequest.y;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWWidth)
|
|
|
|
e->xconfigurerequest.width = ce.xconfigurerequest.width;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWHeight)
|
|
|
|
e->xconfigurerequest.height = ce.xconfigurerequest.height;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWBorderWidth)
|
|
|
|
e->xconfigurerequest.border_width =
|
|
|
|
ce.xconfigurerequest.border_width;
|
|
|
|
if (ce.xconfigurerequest.value_mask & CWStackMode)
|
|
|
|
e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we are iconic (or shaded (fvwm does this)) ignore the event */
|
|
|
|
if (client->iconic || client->shaded) return;
|
|
|
|
|
|
|
|
if (e->xconfigurerequest.value_mask & CWBorderWidth)
|
|
|
|
client->border_width = e->xconfigurerequest.border_width;
|
|
|
|
|
|
|
|
/* resize, then move, as specified in the EWMH section 7.7 */
|
|
|
|
if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
|
|
|
|
CWX | CWY)) {
|
|
|
|
int x, y, w, h;
|
|
|
|
Corner corner;
|
|
|
|
|
|
|
|
x = (e->xconfigurerequest.value_mask & CWX) ?
|
|
|
|
e->xconfigurerequest.x : client->area.x;
|
|
|
|
y = (e->xconfigurerequest.value_mask & CWY) ?
|
|
|
|
e->xconfigurerequest.y : client->area.y;
|
|
|
|
w = (e->xconfigurerequest.value_mask & CWWidth) ?
|
|
|
|
e->xconfigurerequest.width : client->area.width;
|
|
|
|
h = (e->xconfigurerequest.value_mask & CWHeight) ?
|
|
|
|
e->xconfigurerequest.height : client->area.height;
|
|
|
|
|
|
|
|
switch (client->gravity) {
|
|
|
|
case NorthEastGravity:
|
|
|
|
case EastGravity:
|
|
|
|
corner = Corner_TopRight;
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
case SouthGravity:
|
|
|
|
corner = Corner_BottomLeft;
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
corner = Corner_BottomRight;
|
|
|
|
break;
|
|
|
|
default: /* NorthWest, Static, etc */
|
|
|
|
corner = Corner_TopLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
client_configure(client, corner, x, y, w, h, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e->xconfigurerequest.value_mask & CWStackMode) {
|
|
|
|
switch (e->xconfigurerequest.detail) {
|
|
|
|
case Below:
|
|
|
|
case BottomIf:
|
|
|
|
stacking_lower(client);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Above:
|
|
|
|
case TopIf:
|
|
|
|
default:
|
|
|
|
stacking_raise(client);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case UnmapNotify:
|
|
|
|
if (client->ignore_unmaps) {
|
|
|
|
client->ignore_unmaps--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
client_unmanage(client);
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
client_unmanage(client);
|
|
|
|
break;
|
|
|
|
case ReparentNotify:
|
|
|
|
/* this is when the client is first taken captive in the frame */
|
|
|
|
if (e->xreparent.parent == client->frame->plate) break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This event is quite rare and is usually handled in unmapHandler.
|
|
|
|
However, if the window is unmapped when the reparent event occurs,
|
|
|
|
the window manager never sees it because an unmap event is not sent
|
|
|
|
to an already unmapped window.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* we don't want the reparent event, put it back on the stack for the
|
|
|
|
X server to deal with after we unmanage the window */
|
|
|
|
XPutBackEvent(ob_display, e);
|
|
|
|
|
|
|
|
client_unmanage(client);
|
|
|
|
break;
|
|
|
|
case MapRequest:
|
2003-04-10 06:46:44 +00:00
|
|
|
g_message("MapRequest for 0x%lx", client->window);
|
2003-03-25 02:20:16 +00:00
|
|
|
if (!client->iconic) break; /* this normally doesn't happen, but if it
|
2003-03-25 02:18:19 +00:00
|
|
|
does, we don't want it! */
|
2003-03-19 19:56:53 +00:00
|
|
|
if (screen_showing_desktop)
|
|
|
|
screen_show_desktop(FALSE);
|
|
|
|
client_iconify(client, FALSE, TRUE);
|
|
|
|
if (!client->frame->visible)
|
|
|
|
/* if its not visible still, then don't mess with it */
|
|
|
|
break;
|
|
|
|
if (client->shaded)
|
|
|
|
client_shade(client, FALSE);
|
|
|
|
client_focus(client);
|
|
|
|
stacking_raise(client);
|
2003-03-16 21:11:39 +00:00
|
|
|
break;
|
|
|
|
case ClientMessage:
|
|
|
|
/* validate cuz we query stuff off the client here */
|
|
|
|
if (!client_validate(client)) break;
|
|
|
|
|
|
|
|
if (e->xclient.format != 32) return;
|
|
|
|
|
|
|
|
msgtype = e->xclient.message_type;
|
|
|
|
if (msgtype == prop_atoms.wm_change_state) {
|
|
|
|
/* compress changes into a single change */
|
|
|
|
while (XCheckTypedWindowEvent(ob_display, e->type,
|
|
|
|
client->window, &ce)) {
|
|
|
|
/* XXX: it would be nice to compress ALL messages of a
|
|
|
|
type, not just messages in a row without other
|
|
|
|
message types between. */
|
|
|
|
if (ce.xclient.message_type != msgtype) {
|
|
|
|
XPutBackEvent(ob_display, &ce);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
e->xclient = ce.xclient;
|
|
|
|
}
|
|
|
|
client_set_wm_state(client, e->xclient.data.l[0]);
|
|
|
|
} else if (msgtype == prop_atoms.net_wm_desktop) {
|
|
|
|
/* compress changes into a single change */
|
|
|
|
while (XCheckTypedWindowEvent(ob_display, e->type,
|
|
|
|
client->window, &ce)) {
|
|
|
|
/* XXX: it would be nice to compress ALL messages of a
|
|
|
|
type, not just messages in a row without other
|
|
|
|
message types between. */
|
|
|
|
if (ce.xclient.message_type != msgtype) {
|
|
|
|
XPutBackEvent(ob_display, &ce);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
e->xclient = ce.xclient;
|
|
|
|
}
|
2003-03-26 08:29:34 +00:00
|
|
|
if ((unsigned)e->xclient.data.l[0] < screen_num_desktops ||
|
|
|
|
(unsigned)e->xclient.data.l[0] == DESKTOP_ALL)
|
2003-03-28 08:11:02 +00:00
|
|
|
client_set_desktop(client, (unsigned)e->xclient.data.l[0],
|
|
|
|
FALSE);
|
2003-03-16 21:11:39 +00:00
|
|
|
} else if (msgtype == prop_atoms.net_wm_state) {
|
|
|
|
/* can't compress these */
|
2003-03-24 04:56:46 +00:00
|
|
|
g_message("net_wm_state %s %ld %ld for 0x%lx",
|
2003-03-16 21:11:39 +00:00
|
|
|
(e->xclient.data.l[0] == 0 ? "Remove" :
|
|
|
|
e->xclient.data.l[0] == 1 ? "Add" :
|
|
|
|
e->xclient.data.l[0] == 2 ? "Toggle" : "INVALID"),
|
|
|
|
e->xclient.data.l[1], e->xclient.data.l[2],
|
|
|
|
client->window);
|
|
|
|
client_set_state(client, e->xclient.data.l[0],
|
|
|
|
e->xclient.data.l[1], e->xclient.data.l[2]);
|
|
|
|
} else if (msgtype == prop_atoms.net_close_window) {
|
2003-03-24 04:56:46 +00:00
|
|
|
g_message("net_close_window for 0x%lx", client->window);
|
2003-03-16 21:11:39 +00:00
|
|
|
client_close(client);
|
|
|
|
} else if (msgtype == prop_atoms.net_active_window) {
|
2003-03-24 04:56:46 +00:00
|
|
|
g_message("net_active_window for 0x%lx", client->window);
|
2003-05-09 22:53:11 +00:00
|
|
|
client_activate(client);
|
2003-04-17 05:43:41 +00:00
|
|
|
} else if (msgtype == prop_atoms.net_wm_moveresize) {
|
|
|
|
g_message("net_wm_moveresize for 0x%lx", client->window);
|
|
|
|
if ((Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_topleft ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_top ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_topright ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_right ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_right ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_bottomright ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_bottom ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_bottomleft ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_left ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_move ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_size_keyboard ||
|
|
|
|
(Atom)e->xclient.data.l[2] ==
|
|
|
|
prop_atoms.net_wm_moveresize_move_keyboard) {
|
|
|
|
|
|
|
|
moveresize_start(client, e->xclient.data.l[0],
|
2003-04-17 07:00:13 +00:00
|
|
|
e->xclient.data.l[1], e->xclient.data.l[3],
|
|
|
|
e->xclient.data.l[2]);
|
2003-04-17 05:43:41 +00:00
|
|
|
}
|
|
|
|
} else if (msgtype == prop_atoms.net_moveresize_window) {
|
|
|
|
int oldg = client->gravity;
|
|
|
|
int tmpg, x, y, w, h;
|
|
|
|
|
|
|
|
if (e->xclient.data.l[0] & 0xff)
|
|
|
|
tmpg = e->xclient.data.l[0] & 0xff;
|
|
|
|
else
|
|
|
|
tmpg = oldg;
|
|
|
|
|
|
|
|
if (e->xclient.data.l[0] & 1 << 8)
|
|
|
|
x = e->xclient.data.l[1];
|
|
|
|
else
|
|
|
|
x = client->area.x;
|
|
|
|
if (e->xclient.data.l[0] & 1 << 9)
|
|
|
|
y = e->xclient.data.l[2];
|
|
|
|
else
|
|
|
|
y = client->area.y;
|
|
|
|
if (e->xclient.data.l[0] & 1 << 10)
|
|
|
|
w = e->xclient.data.l[3];
|
|
|
|
else
|
|
|
|
w = client->area.y;
|
|
|
|
if (e->xclient.data.l[0] & 1 << 11)
|
|
|
|
h = e->xclient.data.l[4];
|
|
|
|
else
|
|
|
|
h = client->area.y;
|
|
|
|
client->gravity = tmpg;
|
|
|
|
client_configure(client, Corner_TopLeft, x, y, w, h, TRUE, TRUE);
|
|
|
|
client->gravity = oldg;
|
|
|
|
}
|
2003-03-16 21:11:39 +00:00
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
/* validate cuz we query stuff off the client here */
|
|
|
|
if (!client_validate(client)) break;
|
|
|
|
|
|
|
|
/* compress changes to a single property into a single change */
|
|
|
|
while (XCheckTypedWindowEvent(ob_display, e->type,
|
|
|
|
client->window, &ce)) {
|
|
|
|
/* XXX: it would be nice to compress ALL changes to a property,
|
|
|
|
not just changes in a row without other props between. */
|
|
|
|
if (ce.xproperty.atom != e->xproperty.atom) {
|
|
|
|
XPutBackEvent(ob_display, &ce);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msgtype = e->xproperty.atom;
|
|
|
|
if (msgtype == XA_WM_NORMAL_HINTS) {
|
|
|
|
client_update_normal_hints(client);
|
|
|
|
/* normal hints can make a window non-resizable */
|
|
|
|
client_setup_decor_and_functions(client);
|
|
|
|
}
|
|
|
|
else if (msgtype == XA_WM_HINTS)
|
|
|
|
client_update_wmhints(client);
|
|
|
|
else if (msgtype == XA_WM_TRANSIENT_FOR) {
|
|
|
|
client_update_transient_for(client);
|
|
|
|
client_get_type(client);
|
|
|
|
/* type may have changed, so update the layer */
|
|
|
|
client_calc_layer(client);
|
|
|
|
client_setup_decor_and_functions(client);
|
|
|
|
}
|
|
|
|
else if (msgtype == prop_atoms.net_wm_name ||
|
2003-05-09 16:57:17 +00:00
|
|
|
msgtype == prop_atoms.wm_name ||
|
|
|
|
msgtype == prop_atoms.net_wm_icon_name ||
|
2003-03-16 21:11:39 +00:00
|
|
|
msgtype == prop_atoms.wm_icon_name)
|
2003-05-09 16:57:17 +00:00
|
|
|
client_update_title(client);
|
2003-03-16 21:11:39 +00:00
|
|
|
else if (msgtype == prop_atoms.wm_class)
|
|
|
|
client_update_class(client);
|
|
|
|
else if (msgtype == prop_atoms.wm_protocols) {
|
|
|
|
client_update_protocols(client);
|
|
|
|
client_setup_decor_and_functions(client);
|
|
|
|
}
|
|
|
|
else if (msgtype == prop_atoms.net_wm_strut)
|
|
|
|
client_update_strut(client);
|
|
|
|
else if (msgtype == prop_atoms.net_wm_icon)
|
|
|
|
client_update_icons(client);
|
|
|
|
else if (msgtype == prop_atoms.kwm_win_icon)
|
|
|
|
client_update_kwm_icon(client);
|
2003-03-24 19:07:28 +00:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
#ifdef SHAPE
|
|
|
|
if (extensions_shape && e->type == extensions_shape_event_basep) {
|
2003-03-24 19:10:33 +00:00
|
|
|
client->shaped = ((XShapeEvent*)e)->shaped;
|
2003-04-13 07:18:28 +00:00
|
|
|
frame_adjust_shape(client->frame);
|
2003-03-24 19:07:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
2003-03-16 21:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
2003-04-16 05:36:51 +00:00
|
|
|
|
|
|
|
static void event_handle_menu(Menu *menu, XEvent *e)
|
|
|
|
{
|
|
|
|
MenuEntry *entry;
|
|
|
|
|
2003-04-16 18:09:11 +00:00
|
|
|
g_message("EVENT %d", e->type);
|
2003-04-16 05:36:51 +00:00
|
|
|
switch (e->type) {
|
2003-04-16 18:09:11 +00:00
|
|
|
case ButtonPress:
|
2003-05-09 23:15:28 +00:00
|
|
|
g_message("BUTTON PRESS");
|
2003-04-16 18:09:11 +00:00
|
|
|
if (e->xbutton.button == 3)
|
|
|
|
menu_hide(menu);
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
2003-05-09 23:15:28 +00:00
|
|
|
g_message("BUTTON RELEASED");
|
2003-04-16 18:09:11 +00:00
|
|
|
if (!menu->shown) break;
|
|
|
|
|
|
|
|
/* grab_pointer_window(FALSE, None, menu->frame);*/
|
|
|
|
|
|
|
|
entry = menu_find_entry(menu, e->xbutton.window);
|
|
|
|
if (entry) {
|
|
|
|
int junk;
|
|
|
|
Window wjunk;
|
|
|
|
guint ujunk, b, w, h;
|
|
|
|
XGetGeometry(ob_display, e->xbutton.window,
|
|
|
|
&wjunk, &junk, &junk, &w, &h, &b, &ujunk);
|
|
|
|
if (e->xbutton.x >= (signed)-b &&
|
|
|
|
e->xbutton.y >= (signed)-b &&
|
|
|
|
e->xbutton.x < (signed)(w+b) &&
|
|
|
|
e->xbutton.y < (signed)(h+b)) {
|
|
|
|
menu_entry_fire(entry);
|
|
|
|
}
|
2003-05-09 23:15:28 +00:00
|
|
|
|
2003-04-16 18:09:11 +00:00
|
|
|
break;
|
2003-04-16 05:36:51 +00:00
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
|
|
|
g_message("enter/leave");
|
|
|
|
entry = menu_find_entry(menu, e->xcrossing.window);
|
|
|
|
if (entry) {
|
2003-05-09 23:15:28 +00:00
|
|
|
if (menu->mouseover)
|
|
|
|
menu->mouseover(entry, e->type == EnterNotify);
|
|
|
|
else
|
|
|
|
menu_control_mouseover(entry, e->type == EnterNotify);
|
|
|
|
|
2003-04-16 05:36:51 +00:00
|
|
|
menu_entry_render(entry);
|
|
|
|
}
|
|
|
|
break;
|
2003-05-09 23:15:28 +00:00
|
|
|
}
|
2003-04-16 05:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-10 20:52:32 +00:00
|
|
|
|
2003-05-10 22:33:24 +00:00
|
|
|
static void event_handle_slit(Slit *s, XEvent *e)
|
|
|
|
{
|
|
|
|
switch (e->type) {
|
2003-05-11 19:44:33 +00:00
|
|
|
case ButtonPress:
|
|
|
|
stacking_raise(SLIT_AS_WINDOW(s));
|
2003-05-10 22:33:24 +00:00
|
|
|
case EnterNotify:
|
|
|
|
slit_hide(s, FALSE);
|
|
|
|
break;
|
|
|
|
case LeaveNotify:
|
|
|
|
slit_hide(s, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-10 20:52:32 +00:00
|
|
|
static void event_handle_slitapp(SlitApp *app, XEvent *e)
|
|
|
|
{
|
|
|
|
switch (e->type) {
|
2003-05-11 05:15:43 +00:00
|
|
|
case MotionNotify:
|
|
|
|
slit_app_drag(app, &e->xmotion);
|
|
|
|
break;
|
2003-05-10 20:52:32 +00:00
|
|
|
case UnmapNotify:
|
|
|
|
if (app->ignore_unmaps) {
|
|
|
|
app->ignore_unmaps--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
slit_remove(app, TRUE);
|
|
|
|
break;
|
|
|
|
case DestroyNotify:
|
|
|
|
slit_remove(app, FALSE);
|
|
|
|
break;
|
|
|
|
case ReparentNotify:
|
|
|
|
slit_remove(app, FALSE);
|
|
|
|
break;
|
2003-05-10 22:20:08 +00:00
|
|
|
case ConfigureNotify:
|
|
|
|
slit_app_configure(app, e->xconfigure.width, e->xconfigure.height);
|
|
|
|
break;
|
2003-05-10 20:52:32 +00:00
|
|
|
}
|
|
|
|
}
|