indenting

This commit is contained in:
Dana Jansens 2003-10-03 07:07:57 +00:00
parent aa6bedd78b
commit 2572f111e0

View file

@ -1,19 +1,19 @@
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
event.c for the Openbox window manager event.c for the Openbox window manager
Copyright (c) 2003 Ben Jansens Copyright (c) 2003 Ben Jansens
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
See the COPYING file for a copy of the GNU General Public License. See the COPYING file for a copy of the GNU General Public License.
*/ */
#include "event.h" #include "event.h"
@ -123,23 +123,23 @@ void event_startup(gboolean reconfig)
modmap = XGetModifierMapping(ob_display); modmap = XGetModifierMapping(ob_display);
g_assert(modmap); g_assert(modmap);
if (modmap && modmap->max_keypermod > 0) { if (modmap && modmap->max_keypermod > 0) {
size_t cnt; size_t cnt;
const size_t size = mask_table_size * modmap->max_keypermod; const size_t size = mask_table_size * modmap->max_keypermod;
/* get the values of the keyboard lock modifiers /* get the values of the keyboard lock modifiers
Note: Caps lock is not retrieved the same way as Scroll and Num Note: Caps lock is not retrieved the same way as Scroll and Num
lock since it doesn't need to be. */ lock since it doesn't need to be. */
const KeyCode num_lock = XKeysymToKeycode(ob_display, XK_Num_Lock); const KeyCode num_lock = XKeysymToKeycode(ob_display, XK_Num_Lock);
const KeyCode scroll_lock = XKeysymToKeycode(ob_display, const KeyCode scroll_lock = XKeysymToKeycode(ob_display,
XK_Scroll_Lock); XK_Scroll_Lock);
for (cnt = 0; cnt < size; ++cnt) { for (cnt = 0; cnt < size; ++cnt) {
if (! modmap->modifiermap[cnt]) continue; if (! modmap->modifiermap[cnt]) continue;
if (num_lock == modmap->modifiermap[cnt]) if (num_lock == modmap->modifiermap[cnt])
NumLockMask = mask_table[cnt / modmap->max_keypermod]; NumLockMask = mask_table[cnt / modmap->max_keypermod];
if (scroll_lock == modmap->modifiermap[cnt]) if (scroll_lock == modmap->modifiermap[cnt])
ScrollLockMask = mask_table[cnt / modmap->max_keypermod]; ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
} }
} }
ob_main_loop_x_add(ob_main_loop, event_process, event_done, NULL, NULL); ob_main_loop_x_add(ob_main_loop, event_process, event_done, NULL, NULL);
@ -174,29 +174,29 @@ static Window event_get_window(XEvent *e)
window = RootWindow(ob_display, ob_screen); window = RootWindow(ob_display, ob_screen);
break; break;
case MapRequest: case MapRequest:
window = e->xmap.window; window = e->xmap.window;
break; break;
case UnmapNotify: case UnmapNotify:
window = e->xunmap.window; window = e->xunmap.window;
break; break;
case DestroyNotify: case DestroyNotify:
window = e->xdestroywindow.window; window = e->xdestroywindow.window;
break; break;
case ConfigureRequest: case ConfigureRequest:
window = e->xconfigurerequest.window; window = e->xconfigurerequest.window;
break; break;
case ConfigureNotify: case ConfigureNotify:
window = e->xconfigure.window; window = e->xconfigure.window;
break; break;
default: default:
#ifdef XKB #ifdef XKB
if (extensions_xkb && e->type == extensions_xkb_event_basep) { if (extensions_xkb && e->type == extensions_xkb_event_basep) {
switch (((XkbAnyEvent*)e)->xkb_type) { switch (((XkbAnyEvent*)e)->xkb_type) {
case XkbBellNotify: case XkbBellNotify:
window = ((XkbBellNotifyEvent*)e)->window; window = ((XkbBellNotifyEvent*)e)->window;
default: default:
window = None; window = None;
} }
} else } else
#endif #endif
window = e->xany.window; window = e->xany.window;
@ -212,24 +212,24 @@ static void event_set_lasttime(XEvent *e)
switch (e->type) { switch (e->type) {
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
t = e->xbutton.time; t = e->xbutton.time;
break; break;
case KeyPress: case KeyPress:
t = e->xkey.time; t = e->xkey.time;
break; break;
case KeyRelease: case KeyRelease:
t = e->xkey.time; t = e->xkey.time;
break; break;
case MotionNotify: case MotionNotify:
t = e->xmotion.time; t = e->xmotion.time;
break; break;
case PropertyNotify: case PropertyNotify:
t = e->xproperty.time; t = e->xproperty.time;
break; break;
case EnterNotify: case EnterNotify:
case LeaveNotify: case LeaveNotify:
t = e->xcrossing.time; t = e->xcrossing.time;
break; break;
default: default:
/* if more event types are anticipated, get their timestamp /* if more event types are anticipated, get their timestamp
explicitly */ explicitly */
@ -255,31 +255,31 @@ static void event_hack_mods(XEvent *e)
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
STRIP_MODS(e->xbutton.state); STRIP_MODS(e->xbutton.state);
break; break;
case KeyPress: case KeyPress:
STRIP_MODS(e->xkey.state); STRIP_MODS(e->xkey.state);
break; break;
case KeyRelease: case KeyRelease:
STRIP_MODS(e->xkey.state); STRIP_MODS(e->xkey.state);
/* remove from the state the mask of the modifier being released, if /* remove from the state the mask of the modifier being released, if
it is a modifier key being released (this is a little ugly..) */ it is a modifier key being released (this is a little ugly..) */
kp = modmap->modifiermap; kp = modmap->modifiermap;
for (i = 0; i < mask_table_size; ++i) { for (i = 0; i < mask_table_size; ++i) {
for (k = 0; k < modmap->max_keypermod; ++k) { for (k = 0; k < modmap->max_keypermod; ++k) {
if (*kp == e->xkey.keycode) { /* found the keycode */ if (*kp == e->xkey.keycode) { /* found the keycode */
/* remove the mask for it */ /* remove the mask for it */
e->xkey.state &= ~mask_table[i]; e->xkey.state &= ~mask_table[i];
/* cause the first loop to break; */ /* cause the first loop to break; */
i = mask_table_size; i = mask_table_size;
break; /* get outta here! */ break; /* get outta here! */
} }
++kp; ++kp;
} }
} }
break; break;
case MotionNotify: case MotionNotify:
STRIP_MODS(e->xmotion.state); STRIP_MODS(e->xmotion.state);
/* compress events */ /* compress events */
{ {
XEvent ce; XEvent ce;
while (XCheckTypedWindowEvent(ob_display, e->xmotion.window, while (XCheckTypedWindowEvent(ob_display, e->xmotion.window,
@ -287,8 +287,8 @@ static void event_hack_mods(XEvent *e)
e->xmotion.x_root = ce.xmotion.x_root; e->xmotion.x_root = ce.xmotion.x_root;
e->xmotion.y_root = ce.xmotion.y_root; e->xmotion.y_root = ce.xmotion.y_root;
} }
} }
break; break;
} }
} }
@ -409,20 +409,20 @@ static void event_process(const XEvent *ec, gpointer data)
window directly */ window directly */
XWindowChanges xwc; XWindowChanges xwc;
xwc.x = e->xconfigurerequest.x; xwc.x = e->xconfigurerequest.x;
xwc.y = e->xconfigurerequest.y; xwc.y = e->xconfigurerequest.y;
xwc.width = e->xconfigurerequest.width; xwc.width = e->xconfigurerequest.width;
xwc.height = e->xconfigurerequest.height; xwc.height = e->xconfigurerequest.height;
xwc.border_width = e->xconfigurerequest.border_width; xwc.border_width = e->xconfigurerequest.border_width;
xwc.sibling = e->xconfigurerequest.above; xwc.sibling = e->xconfigurerequest.above;
xwc.stack_mode = e->xconfigurerequest.detail; xwc.stack_mode = e->xconfigurerequest.detail;
/* we are not to be held responsible if someone sends us an /* we are not to be held responsible if someone sends us an
invalid request! */ invalid request! */
xerror_set_ignore(TRUE); xerror_set_ignore(TRUE);
XConfigureWindow(ob_display, window, XConfigureWindow(ob_display, window,
e->xconfigurerequest.value_mask, &xwc); e->xconfigurerequest.value_mask, &xwc);
xerror_set_ignore(FALSE); xerror_set_ignore(FALSE);
} }
/* user input (action-bound) events */ /* user input (action-bound) events */
@ -473,27 +473,27 @@ static void event_handle_root(XEvent *e)
break; break;
case ClientMessage: case ClientMessage:
if (e->xclient.format != 32) break; if (e->xclient.format != 32) break;
msgtype = e->xclient.message_type; msgtype = e->xclient.message_type;
if (msgtype == prop_atoms.net_current_desktop) { if (msgtype == prop_atoms.net_current_desktop) {
unsigned int d = e->xclient.data.l[0]; unsigned int d = e->xclient.data.l[0];
if (d < screen_num_desktops) if (d < screen_num_desktops)
screen_set_desktop(d); screen_set_desktop(d);
} else if (msgtype == prop_atoms.net_number_of_desktops) { } else if (msgtype == prop_atoms.net_number_of_desktops) {
unsigned int d = e->xclient.data.l[0]; unsigned int d = e->xclient.data.l[0];
if (d > 0) if (d > 0)
screen_set_num_desktops(d); screen_set_num_desktops(d);
} else if (msgtype == prop_atoms.net_showing_desktop) { } else if (msgtype == prop_atoms.net_showing_desktop) {
screen_show_desktop(e->xclient.data.l[0] != 0); screen_show_desktop(e->xclient.data.l[0] != 0);
} }
break; break;
case PropertyNotify: case PropertyNotify:
if (e->xproperty.atom == prop_atoms.net_desktop_names) if (e->xproperty.atom == prop_atoms.net_desktop_names)
screen_update_desktop_names(); screen_update_desktop_names();
else if (e->xproperty.atom == prop_atoms.net_desktop_layout) else if (e->xproperty.atom == prop_atoms.net_desktop_layout)
screen_update_layout(); screen_update_layout();
break; break;
case ConfigureNotify: case ConfigureNotify:
#ifdef XRANDR #ifdef XRANDR
XRRUpdateConfiguration(e); XRRUpdateConfiguration(e);
@ -584,7 +584,8 @@ static void event_handle_client(ObClient *client, XEvent *e)
case FocusIn: case FocusIn:
#ifdef DEBUG_FOCUS #ifdef DEBUG_FOCUS
ob_debug("FocusIn on client for %lx (client %lx) mode %d detail %d\n", ob_debug("FocusIn on client for %lx (client %lx) mode %d detail %d\n",
e->xfocus.window, client->window, e->xfocus.mode, e->xfocus.detail); e->xfocus.window, client->window,
e->xfocus.mode, e->xfocus.detail);
#endif #endif
focus_in = client; focus_in = client;
if (focus_out == client) if (focus_out == client)
@ -593,7 +594,8 @@ static void event_handle_client(ObClient *client, XEvent *e)
case FocusOut: case FocusOut:
#ifdef DEBUG_FOCUS #ifdef DEBUG_FOCUS
ob_debug("FocusOut on client for %lx (client %lx) mode %d detail %d\n", ob_debug("FocusOut on client for %lx (client %lx) mode %d detail %d\n",
e->xfocus.window, client->window, e->xfocus.mode, e->xfocus.detail); e->xfocus.window, client->window,
e->xfocus.mode, e->xfocus.detail);
#endif #endif
if (focus_in == client) if (focus_in == client)
focus_in = NULL; focus_in = NULL;
@ -625,10 +627,10 @@ static void event_handle_client(ObClient *client, XEvent *e)
break; break;
case OB_FRAME_CONTEXT_FRAME: case OB_FRAME_CONTEXT_FRAME:
/* /*
if (config_focus_follow && config_focus_delay) if (config_focus_follow && config_focus_delay)
ob_main_loop_timeout_remove_data(ob_main_loop, ob_main_loop_timeout_remove_data(ob_main_loop,
focus_delay_func, focus_delay_func,
client); client);
*/ */
break; break;
default: default:
@ -695,50 +697,50 @@ static void event_handle_client(ObClient *client, XEvent *e)
break; break;
} }
case ConfigureRequest: case ConfigureRequest:
/* compress these */ /* compress these */
while (XCheckTypedWindowEvent(ob_display, client->window, while (XCheckTypedWindowEvent(ob_display, client->window,
ConfigureRequest, &ce)) { ConfigureRequest, &ce)) {
++i; ++i;
/* XXX if this causes bad things.. we can compress config req's /* XXX if this causes bad things.. we can compress config req's
with the same mask. */ with the same mask. */
e->xconfigurerequest.value_mask |= e->xconfigurerequest.value_mask |=
ce.xconfigurerequest.value_mask; ce.xconfigurerequest.value_mask;
if (ce.xconfigurerequest.value_mask & CWX) if (ce.xconfigurerequest.value_mask & CWX)
e->xconfigurerequest.x = ce.xconfigurerequest.x; e->xconfigurerequest.x = ce.xconfigurerequest.x;
if (ce.xconfigurerequest.value_mask & CWY) if (ce.xconfigurerequest.value_mask & CWY)
e->xconfigurerequest.y = ce.xconfigurerequest.y; e->xconfigurerequest.y = ce.xconfigurerequest.y;
if (ce.xconfigurerequest.value_mask & CWWidth) if (ce.xconfigurerequest.value_mask & CWWidth)
e->xconfigurerequest.width = ce.xconfigurerequest.width; e->xconfigurerequest.width = ce.xconfigurerequest.width;
if (ce.xconfigurerequest.value_mask & CWHeight) if (ce.xconfigurerequest.value_mask & CWHeight)
e->xconfigurerequest.height = ce.xconfigurerequest.height; e->xconfigurerequest.height = ce.xconfigurerequest.height;
if (ce.xconfigurerequest.value_mask & CWBorderWidth) if (ce.xconfigurerequest.value_mask & CWBorderWidth)
e->xconfigurerequest.border_width = e->xconfigurerequest.border_width =
ce.xconfigurerequest.border_width; ce.xconfigurerequest.border_width;
if (ce.xconfigurerequest.value_mask & CWStackMode) if (ce.xconfigurerequest.value_mask & CWStackMode)
e->xconfigurerequest.detail = ce.xconfigurerequest.detail; e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
} }
/* if we are iconic (or shaded (fvwm does this)) ignore the event */ /* if we are iconic (or shaded (fvwm does this)) ignore the event */
if (client->iconic || client->shaded) return; if (client->iconic || client->shaded) return;
/* resize, then move, as specified in the EWMH section 7.7 */ /* resize, then move, as specified in the EWMH section 7.7 */
if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight | if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
CWX | CWY | CWX | CWY |
CWBorderWidth)) { CWBorderWidth)) {
int x, y, w, h; int x, y, w, h;
ObCorner corner; ObCorner corner;
if (e->xconfigurerequest.value_mask & CWBorderWidth) if (e->xconfigurerequest.value_mask & CWBorderWidth)
client->border_width = e->xconfigurerequest.border_width; client->border_width = e->xconfigurerequest.border_width;
x = (e->xconfigurerequest.value_mask & CWX) ? x = (e->xconfigurerequest.value_mask & CWX) ?
e->xconfigurerequest.x : client->area.x; e->xconfigurerequest.x : client->area.x;
y = (e->xconfigurerequest.value_mask & CWY) ? y = (e->xconfigurerequest.value_mask & CWY) ?
e->xconfigurerequest.y : client->area.y; e->xconfigurerequest.y : client->area.y;
w = (e->xconfigurerequest.value_mask & CWWidth) ? w = (e->xconfigurerequest.value_mask & CWWidth) ?
e->xconfigurerequest.width : client->area.width; e->xconfigurerequest.width : client->area.width;
h = (e->xconfigurerequest.value_mask & CWHeight) ? h = (e->xconfigurerequest.value_mask & CWHeight) ?
e->xconfigurerequest.height : client->area.height; e->xconfigurerequest.height : client->area.height;
{ {
int newx = x; int newx = x;
@ -755,68 +757,68 @@ static void event_handle_client(ObClient *client, XEvent *e)
y = newy; y = newy;
} }
switch (client->gravity) { switch (client->gravity) {
case NorthEastGravity: case NorthEastGravity:
case EastGravity: case EastGravity:
corner = OB_CORNER_TOPRIGHT; corner = OB_CORNER_TOPRIGHT;
break; break;
case SouthWestGravity: case SouthWestGravity:
case SouthGravity: case SouthGravity:
corner = OB_CORNER_BOTTOMLEFT; corner = OB_CORNER_BOTTOMLEFT;
break; break;
case SouthEastGravity: case SouthEastGravity:
corner = OB_CORNER_BOTTOMRIGHT; corner = OB_CORNER_BOTTOMRIGHT;
break; break;
default: /* NorthWest, Static, etc */ default: /* NorthWest, Static, etc */
corner = OB_CORNER_TOPLEFT; corner = OB_CORNER_TOPLEFT;
} }
client_configure_full(client, corner, x, y, w, h, FALSE, TRUE, client_configure_full(client, corner, x, y, w, h, FALSE, TRUE,
TRUE); TRUE);
} }
if (e->xconfigurerequest.value_mask & CWStackMode) { if (e->xconfigurerequest.value_mask & CWStackMode) {
switch (e->xconfigurerequest.detail) { switch (e->xconfigurerequest.detail) {
case Below: case Below:
case BottomIf: case BottomIf:
client_lower(client); client_lower(client);
break; break;
case Above: case Above:
case TopIf: case TopIf:
default: default:
client_raise(client); client_raise(client);
break; break;
} }
} }
break; break;
case UnmapNotify: case UnmapNotify:
if (client->ignore_unmaps) { if (client->ignore_unmaps) {
client->ignore_unmaps--; client->ignore_unmaps--;
break; break;
} }
client_unmanage(client); client_unmanage(client);
break; break;
case DestroyNotify: case DestroyNotify:
client_unmanage(client); client_unmanage(client);
break; break;
case ReparentNotify: case ReparentNotify:
/* this is when the client is first taken captive in the frame */ /* this is when the client is first taken captive in the frame */
if (e->xreparent.parent == client->frame->plate) break; if (e->xreparent.parent == client->frame->plate) break;
/* /*
This event is quite rare and is usually handled in unmapHandler. This event is quite rare and is usually handled in unmapHandler.
However, if the window is unmapped when the reparent event occurs, However, if the window is unmapped when the reparent event occurs,
the window manager never sees it because an unmap event is not sent the window manager never sees it because an unmap event is not sent
to an already unmapped window. to an already unmapped window.
*/ */
/* we don't want the reparent event, put it back on the stack for the /* 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 */ X server to deal with after we unmanage the window */
XPutBackEvent(ob_display, e); XPutBackEvent(ob_display, e);
client_unmanage(client); client_unmanage(client);
break; break;
case MapRequest: case MapRequest:
ob_debug("MapRequest for 0x%lx\n", client->window); ob_debug("MapRequest for 0x%lx\n", client->window);
if (!client->iconic) break; /* this normally doesn't happen, but if it if (!client->iconic) break; /* this normally doesn't happen, but if it