all repos — openbox @ 276b2be581c6cb138b439537761ff2ca42201805

openbox fork - make it a bit more like ryudo

add misc.h with some standard enumerations with proper prefixing and capitalizations.

use the new enums throughout.

provide keycodes and cursors through ob_cursor and ob_keycode functions, which use the new misc.h enums for picking the cursor and keycode.
Dana Jansens danakj@orodu.net
commit

276b2be581c6cb138b439537761ff2ca42201805

parent

6357583c396382dd6ed8ac42004177f204fabe62

M openbox/action.copenbox/action.c

@@ -41,42 +41,42 @@ }

void setup_action_directional_focus_north(Action *a) { - a->data.diraction.direction = Direction_North; + a->data.diraction.direction = OB_DIRECTION_NORTH; } void setup_action_directional_focus_east(Action *a) { - a->data.diraction.direction = Direction_East; + a->data.diraction.direction = OB_DIRECTION_EAST; } void setup_action_directional_focus_south(Action *a) { - a->data.diraction.direction = Direction_South; + a->data.diraction.direction = OB_DIRECTION_SOUTH; } void setup_action_directional_focus_west(Action *a) { - a->data.diraction.direction = Direction_West; + a->data.diraction.direction = OB_DIRECTION_WEST; } void setup_action_directional_focus_northeast(Action *a) { - a->data.diraction.direction = Direction_NorthEast; + a->data.diraction.direction = OB_DIRECTION_NORTHEAST; } void setup_action_directional_focus_southeast(Action *a) { - a->data.diraction.direction = Direction_SouthEast; + a->data.diraction.direction = OB_DIRECTION_SOUTHEAST; } void setup_action_directional_focus_southwest(Action *a) { - a->data.diraction.direction = Direction_SouthWest; + a->data.diraction.direction = OB_DIRECTION_SOUTHWEST; } void setup_action_directional_focus_northwest(Action *a) { - a->data.diraction.direction = Direction_NorthWest; + a->data.diraction.direction = OB_DIRECTION_NORTHWEST; } void setup_action_send_to_desktop(Action *a)

@@ -141,22 +141,22 @@ }

void setup_action_movetoedge_north(Action *a) { - a->data.diraction.direction = Direction_North; + a->data.diraction.direction = OB_DIRECTION_NORTH; } void setup_action_movetoedge_south(Action *a) { - a->data.diraction.direction = Direction_South; + a->data.diraction.direction = OB_DIRECTION_SOUTH; } void setup_action_movetoedge_east(Action *a) { - a->data.diraction.direction = Direction_East; + a->data.diraction.direction = OB_DIRECTION_EAST; } void setup_action_movetoedge_west(Action *a) { - a->data.diraction.direction = Direction_West; + a->data.diraction.direction = OB_DIRECTION_WEST; } void setup_action_top_layer(Action *a)

@@ -702,7 +702,7 @@ void action_move_relative_horz(union ActionData *data)

{ Client *c = data->relative.c; if (c) - client_configure(c, Corner_TopLeft, + client_configure(c, OB_CORNER_TOPLEFT, c->area.x + data->relative.delta, c->area.y, c->area.width, c->area.height, TRUE, TRUE); }

@@ -711,7 +711,7 @@ void action_move_relative_vert(union ActionData *data)

{ Client *c = data->relative.c; if (c) - client_configure(c, Corner_TopLeft, + client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y + data->relative.delta, c->area.width, c->area.height, TRUE, TRUE); }

@@ -720,7 +720,7 @@ void action_resize_relative_horz(union ActionData *data)

{ Client *c = data->relative.c; if (c) - client_configure(c, Corner_TopLeft, c->area.x, c->area.y, + client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y, c->area.width + data->relative.delta * c->size_inc.width, c->area.height, TRUE, TRUE);

@@ -730,7 +730,7 @@ void action_resize_relative_vert(union ActionData *data)

{ Client *c = data->relative.c; if (c && !c->shaded) - client_configure(c, Corner_TopLeft, c->area.x, c->area.y, + client_configure(c, OB_CORNER_TOPLEFT, c->area.x, c->area.y, c->area.width, c->area.height + data->relative.delta * c->size_inc.height, TRUE, TRUE);

@@ -815,23 +815,23 @@

static void cur_row_col(guint *r, guint *c) { switch (screen_desktop_layout.orientation) { - case Orientation_Horz: + case OB_ORIENTATION_HORZ: switch (screen_desktop_layout.start_corner) { - case Corner_TopLeft: + case OB_CORNER_TOPLEFT: *r = screen_desktop / screen_desktop_layout.columns; *c = screen_desktop % screen_desktop_layout.columns; break; - case Corner_BottomLeft: + case OB_CORNER_BOTTOMLEFT: *r = screen_desktop_layout.rows - 1 - screen_desktop / screen_desktop_layout.columns; *c = screen_desktop % screen_desktop_layout.columns; break; - case Corner_TopRight: + case OB_CORNER_TOPRIGHT: *r = screen_desktop / screen_desktop_layout.columns; *c = screen_desktop_layout.columns - 1 - screen_desktop % screen_desktop_layout.columns; break; - case Corner_BottomRight: + case OB_CORNER_BOTTOMRIGHT: *r = screen_desktop_layout.rows - 1 - screen_desktop / screen_desktop_layout.columns; *c = screen_desktop_layout.columns - 1 -

@@ -839,23 +839,23 @@ screen_desktop % screen_desktop_layout.columns;

break; } break; - case Orientation_Vert: + case OB_ORIENTATION_VERT: switch (screen_desktop_layout.start_corner) { - case Corner_TopLeft: + case OB_CORNER_TOPLEFT: *r = screen_desktop % screen_desktop_layout.rows; *c = screen_desktop / screen_desktop_layout.rows; break; - case Corner_BottomLeft: + case OB_CORNER_BOTTOMLEFT: *r = screen_desktop_layout.rows - 1 - screen_desktop % screen_desktop_layout.rows; *c = screen_desktop / screen_desktop_layout.rows; break; - case Corner_TopRight: + case OB_CORNER_TOPRIGHT: *r = screen_desktop % screen_desktop_layout.rows; *c = screen_desktop_layout.columns - 1 - screen_desktop / screen_desktop_layout.rows; break; - case Corner_BottomRight: + case OB_CORNER_BOTTOMRIGHT: *r = screen_desktop_layout.rows - 1 - screen_desktop % screen_desktop_layout.rows; *c = screen_desktop_layout.columns - 1 -

@@ -869,46 +869,46 @@

static guint translate_row_col(guint r, guint c) { switch (screen_desktop_layout.orientation) { - case Orientation_Horz: + case OB_ORIENTATION_HORZ: switch (screen_desktop_layout.start_corner) { - case Corner_TopLeft: + case OB_CORNER_TOPLEFT: return r % screen_desktop_layout.rows * screen_desktop_layout.columns + c % screen_desktop_layout.columns; - case Corner_BottomLeft: + case OB_CORNER_BOTTOMLEFT: return (screen_desktop_layout.rows - 1 - r % screen_desktop_layout.rows) * screen_desktop_layout.columns + c % screen_desktop_layout.columns; - case Corner_TopRight: + case OB_CORNER_TOPRIGHT: return r % screen_desktop_layout.rows * screen_desktop_layout.columns + (screen_desktop_layout.columns - 1 - c % screen_desktop_layout.columns); - case Corner_BottomRight: + case OB_CORNER_BOTTOMRIGHT: return (screen_desktop_layout.rows - 1 - r % screen_desktop_layout.rows) * screen_desktop_layout.columns + (screen_desktop_layout.columns - 1 - c % screen_desktop_layout.columns); } - case Orientation_Vert: + case OB_ORIENTATION_VERT: switch (screen_desktop_layout.start_corner) { - case Corner_TopLeft: + case OB_CORNER_TOPLEFT: return c % screen_desktop_layout.columns * screen_desktop_layout.rows + r % screen_desktop_layout.rows; - case Corner_BottomLeft: + case OB_CORNER_BOTTOMLEFT: return c % screen_desktop_layout.columns * screen_desktop_layout.rows + (screen_desktop_layout.rows - 1 - r % screen_desktop_layout.rows); - case Corner_TopRight: + case OB_CORNER_TOPRIGHT: return (screen_desktop_layout.columns - 1 - c % screen_desktop_layout.columns) * screen_desktop_layout.rows + r % screen_desktop_layout.rows; - case Corner_BottomRight: + case OB_CORNER_BOTTOMRIGHT: return (screen_desktop_layout.columns - 1 - c % screen_desktop_layout.columns) * screen_desktop_layout.rows +

@@ -1167,21 +1167,23 @@

h = screen_area(c->desktop)->height; w = screen_area(c->desktop)->width; switch(data->diraction.direction) { - case Direction_North: + case OB_DIRECTION_NORTH: y = 0; break; - case Direction_West: + case OB_DIRECTION_WEST: x = 0; break; - case Direction_South: + case OB_DIRECTION_SOUTH: y = h - c->frame->area.height; break; - case Direction_East: + case OB_DIRECTION_EAST: x = w - c->frame->area.width; break; + default: + g_assert_not_reached(); } frame_frame_gravity(c->frame, &x, &y); - client_configure(c, Corner_TopLeft, + client_configure(c, OB_CORNER_TOPLEFT, x, y, c->area.width, c->area.height, TRUE, TRUE); }
M openbox/action.hopenbox/action.h

@@ -15,7 +15,7 @@ };

struct DirectionalAction{ Client *c; - int direction; + ObDirection direction; }; struct Execute {
M openbox/client.copenbox/client.c

@@ -254,7 +254,7 @@ /* update the focus lists */

focus_order_add_new(self); /* focus the new window? */ - if (ob_state != State_Starting && config_focus_new && + if (ob_state != OB_STATE_STARTING && config_focus_new && (self->type == Type_Normal || self->type == Type_Dialog)) { gboolean group_foc = FALSE;

@@ -403,7 +403,7 @@ /* reparent the window out of the frame, and free the frame */

frame_release_client(self->frame, self); self->frame = NULL; - if (ob_state != State_Exiting) { + if (ob_state != OB_STATE_EXITING) { /* these values should not be persisted across a window unmapping/mapping */ prop_erase(self->window, prop_atoms.net_wm_desktop);

@@ -453,7 +453,7 @@ y = a->y;

frame_frame_gravity(self->frame, &x, &y); /* get where the client should be */ - client_configure(self , Corner_TopLeft, x, y, + client_configure(self, OB_CORNER_TOPLEFT, x, y, self->area.width, self->area.height, TRUE, TRUE); }

@@ -1095,7 +1095,7 @@ {

/* by making this pass FALSE for user, we avoid the emacs event storm where every configurenotify causes an update in its normal hints, i think this is generally what we want anyways... */ - client_configure(self, Corner_TopLeft, self->area.x, self->area.y, + client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y, self->area.width, self->area.height, FALSE, TRUE); }

@@ -1114,7 +1114,7 @@ self->can_focus = hints->input;

/* only do this when first managing the window *AND* when we aren't starting up! */ - if (ob_state != State_Starting && self->frame == NULL) + if (ob_state != OB_STATE_STARTING && self->frame == NULL) if (hints->flags & StateHint) self->iconic = hints->initial_state == IconicState;

@@ -1594,7 +1594,8 @@ below

*/ } -void client_configure(Client *self, Corner anchor, int x, int y, int w, int h, +void client_configure(Client *self, ObCorner anchor, + int x, int y, int w, int h, gboolean user, gboolean final) { gboolean moved = FALSE, resized = FALSE;

@@ -1753,15 +1754,15 @@ }

} switch (anchor) { - case Corner_TopLeft: + case OB_CORNER_TOPLEFT: break; - case Corner_TopRight: + case OB_CORNER_TOPRIGHT: x -= w - self->area.width; break; - case Corner_BottomLeft: + case OB_CORNER_BOTTOMLEFT: y -= h - self->area.height; break; - case Corner_BottomRight: + case OB_CORNER_BOTTOMRIGHT: x -= w - self->area.width; y -= h - self->area.height; break;

@@ -1865,7 +1866,7 @@ }

client_setup_decor_and_functions(self); - client_configure(self, Corner_TopLeft, x, y, w, h, TRUE, TRUE); + client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE); /* try focus us when we go into fullscreen mode */ client_focus(self);

@@ -2042,7 +2043,7 @@ client_change_state(self); /* change the state hints on the client */

/* figure out where the client should be going */ frame_frame_gravity(self->frame, &x, &y); - client_configure(self, Corner_TopLeft, x, y, w, h, TRUE, TRUE); + client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE); } void client_shade(Client *self, gboolean shade)

@@ -2457,7 +2458,7 @@ return &self->icons[li];

} /* this be mostly ripped from fvwm */ -Client *client_find_directional(Client *c, Direction dir) +Client *client_find_directional(Client *c, ObDirection dir) { int my_cx, my_cy, his_cx, his_cy; int offset = 0;

@@ -2512,21 +2513,23 @@ his_cx = tx;

} switch(dir) { - case Direction_North : - case Direction_South : - case Direction_NorthEast : - case Direction_SouthWest : + case OB_DIRECTION_NORTH: + case OB_DIRECTION_SOUTH: + case OB_DIRECTION_NORTHEAST: + case OB_DIRECTION_SOUTHWEST: offset = (his_cx < 0) ? -his_cx : his_cx; - distance = (dir == Direction_North || dir == Direction_NorthEast) ? - -his_cy : his_cy; + distance = ((dir == OB_DIRECTION_NORTH || + dir == OB_DIRECTION_NORTHEAST) ? + -his_cy : his_cy); break; - case Direction_East : - case Direction_West : - case Direction_SouthEast : - case Direction_NorthWest : + case OB_DIRECTION_EAST: + case OB_DIRECTION_WEST: + case OB_DIRECTION_SOUTHEAST: + case OB_DIRECTION_NORTHWEST: offset = (his_cy < 0) ? -his_cy : his_cy; - distance = (dir == Direction_West || dir == Direction_NorthWest) ? - -his_cx : his_cx; + distance = ((dir == OB_DIRECTION_WEST || + dir == OB_DIRECTION_NORTHWEST) ? + -his_cx : his_cx); break; }
M openbox/client.hopenbox/client.h

@@ -1,6 +1,7 @@

#ifndef __client_h #define __client_h +#include "misc.h" #include "geom.h" #include "stacking.h" #include "render/color.h"

@@ -64,14 +65,6 @@ MwmDecor_Iconify = 1 << 5, /*!< Show an iconify button */

MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */ } MemDecorations; -/*! Corners of the client window, used for anchor positions */ -typedef enum { - Corner_TopLeft, - Corner_TopRight, - Corner_BottomLeft, - Corner_BottomRight -} Corner; - /*! Possible window types */ typedef enum { Type_Desktop, /*!< A desktop (bottom-most window) */

@@ -110,18 +103,6 @@ Decor_Shade = 1 << 7, /*!< Displays a shade button */

Decor_Close = 1 << 8 /*!< Display a close button */ } Decoration; -/*! The directions used by client_find_directional */ -typedef enum { - Direction_North, - Direction_East, - Direction_South, - Direction_West, - Direction_NorthEast, - Direction_SouthEast, - Direction_SouthWest, - Direction_NorthWest -} Direction; - typedef struct Client { ObWindow obwin;

@@ -346,7 +327,8 @@ configuration. e.g. Final should be FALSE if doing an

interactive move/resize, and then be TRUE for the last call only. */ -void client_configure(Client *self, Corner anchor, int x, int y, int w, int h, +void client_configure(Client *self, ObCorner anchor, + int x, int y, int w, int h, gboolean user, gboolean final); void client_reconfigure(Client *self);

@@ -499,7 +481,7 @@

Client *client_search_top_transient(Client *self); /*! Return the "closest" client in the given direction */ -Client *client_find_directional(Client *c, Direction dir); +Client *client_find_directional(Client *c, ObDirection dir); /*! Set a client window to be above/below other clients. @layer < 0 indicates the client should be placed below other clients.<br>
M openbox/dispatch.copenbox/dispatch.c

@@ -238,7 +238,7 @@ *x = obe.data.c.num[0];

*y = obe.data.c.num[1]; } -void dispatch_resize(Client *c, int *w, int *h, Corner corner) +void dispatch_resize(Client *c, int *w, int *h, ObCorner corner) { guint i; GSList *it;
M openbox/dispatch.hopenbox/dispatch.h

@@ -98,6 +98,6 @@ changed by the event handlers */

void dispatch_move(Client *c, int *x, int *y); /* *w and *h should be set with the destination of the window, they may be changed by the event handlers */ -void dispatch_resize(Client *c, int *w, int *h, Corner corner); +void dispatch_resize(Client *c, int *w, int *h, ObCorner corner); #endif
M openbox/dock.copenbox/dock.c

@@ -91,7 +91,7 @@ it. There are 2 unmap events generated that we see, one with the 'event'

member set the root window, and one set to the client, but both get handled and need to be ignored. */ - if (ob_state == State_Starting) + if (ob_state == OB_STATE_STARTING) app->ignore_unmaps += 2; if (app->win != app->icon_win) {

@@ -109,7 +109,7 @@ XSelectInput(ob_display, app->icon_win, DOCKAPP_EVENT_MASK);

grab_button_full(2, 0, app->icon_win, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, - GrabModeAsync, ob_cursors.move); + GrabModeAsync, OB_CURSOR_MOVE); g_hash_table_insert(window_map, &app->icon_win, app);
M openbox/event.copenbox/event.c

@@ -671,7 +671,7 @@ frame_adjust_focus(client->frame, FALSE);

break; case EnterNotify: if (client_normal(client)) { - if (ob_state == State_Starting) { + if (ob_state == OB_STATE_STARTING) { /* move it to the top of the focus order */ guint desktop = client->desktop; if (desktop == DESKTOP_ALL) desktop = screen_desktop;

@@ -722,7 +722,7 @@ /* 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; + ObCorner corner; x = (e->xconfigurerequest.value_mask & CWX) ? e->xconfigurerequest.x : client->area.x;

@@ -736,17 +736,17 @@

switch (client->gravity) { case NorthEastGravity: case EastGravity: - corner = Corner_TopRight; + corner = OB_CORNER_TOPRIGHT; break; case SouthWestGravity: case SouthGravity: - corner = Corner_BottomLeft; + corner = OB_CORNER_BOTTOMLEFT; break; case SouthEastGravity: - corner = Corner_BottomRight; + corner = OB_CORNER_BOTTOMRIGHT; break; default: /* NorthWest, Static, etc */ - corner = Corner_TopLeft; + corner = OB_CORNER_TOPLEFT; } client_configure(client, corner, x, y, w, h, FALSE, TRUE);

@@ -920,7 +920,8 @@ h = e->xclient.data.l[4];

else h = client->area.y; client->gravity = tmpg; - client_configure(client, Corner_TopLeft, x, y, w, h, FALSE, TRUE); + client_configure(client, OB_CORNER_TOPLEFT, + x, y, w, h, FALSE, TRUE); client->gravity = oldg; } break;
M openbox/focus.copenbox/focus.c

@@ -111,7 +111,7 @@ if (client != NULL)

push_to_top(client); /* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */ - if (ob_state != State_Exiting) { + if (ob_state != OB_STATE_EXITING) { active = client ? client->window : None; PROP_SET32(ob_root, net_active_window, window, active); }
M openbox/frame.copenbox/frame.c

@@ -61,9 +61,9 @@ self->icon = createWindow(self->title, mask, &attrib);

self->iconify = createWindow(self->title, mask, &attrib); self->handle = createWindow(self->window, mask, &attrib); mask |= CWCursor; - attrib.cursor = ob_cursors.bl; + attrib.cursor = ob_cursor(OB_CURSOR_SOUTHWEST); self->lgrip = createWindow(self->handle, mask, &attrib); - attrib.cursor = ob_cursors.br; + attrib.cursor = ob_cursor(OB_CURSOR_SOUTHEAST); self->rgrip = createWindow(self->handle, mask, &attrib); self->focused = FALSE;

@@ -344,7 +344,7 @@ it. There are 2 unmap events generated that we see, one with the 'event'

member set the root window, and one set to the client, but both get handled and need to be ignored. */ - if (ob_state == State_Starting) + if (ob_state == OB_STATE_STARTING) client->ignore_unmaps += 2; /* select the event mask on the client's parent (to receive config/map
M openbox/grab.copenbox/grab.c

@@ -32,7 +32,7 @@ }

return ret; } -gboolean grab_pointer(gboolean grab, Cursor cur) +gboolean grab_pointer(gboolean grab, ObCursor cur) { static guint pgrabs = 0; gboolean ret = FALSE;

@@ -40,7 +40,8 @@

if (grab) { if (pgrabs++ == 0) ret = XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK, - GrabModeAsync, GrabModeAsync, FALSE, cur, + GrabModeAsync, GrabModeAsync, FALSE, + ob_cursor(cur), event_lasttime) == Success; else ret = TRUE;

@@ -52,7 +53,7 @@ }

return ret; } -gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win) +gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win) { static guint pgrabs = 0; gboolean ret = FALSE;

@@ -60,7 +61,8 @@

if (grab) { if (pgrabs++ == 0) ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, - GrabModeAsync, GrabModeAsync, TRUE, cur, + GrabModeAsync, GrabModeAsync, TRUE, + ob_cursor(cur), event_lasttime) == Success; else ret = TRUE;

@@ -113,13 +115,13 @@ while (grab_server(FALSE));

} void grab_button_full(guint button, guint state, Window win, guint mask, - int pointer_mode, Cursor cursor) + int pointer_mode, ObCursor cur) { guint i; for (i = 0; i < MASK_LIST_SIZE; ++i) XGrabButton(ob_display, button, state | mask_list[i], win, FALSE, mask, - pointer_mode, GrabModeSync, None, cursor); + pointer_mode, GrabModeSync, None, ob_cursor(cur)); } void grab_button(guint button, guint state, Window win, guint mask)
M openbox/grab.hopenbox/grab.h

@@ -1,6 +1,8 @@

#ifndef __grab_h #define __grab_h +#include "misc.h" + #include <glib.h> #include <X11/Xlib.h>

@@ -8,13 +10,13 @@ void grab_startup();

void grab_shutdown(); gboolean grab_keyboard(gboolean grab); -gboolean grab_pointer(gboolean grab, Cursor cur); -gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win); +gboolean grab_pointer(gboolean grab, ObCursor cur); +gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win); void grab_server(gboolean grab); void grab_button(guint button, guint state, Window win, guint mask); void grab_button_full(guint button, guint state, Window win, guint mask, - int pointer_mode, Cursor cursor); + int pointer_mode, ObCursor cursor); void ungrab_button(guint button, guint state, Window win); void grab_key(guint keycode, guint state, Window win, int keyboard_mode);
A openbox/misc.h

@@ -0,0 +1,64 @@

+#ifndef __ob__misc_h +#define __ob__misc_h + +typedef enum +{ + OB_CURSOR_POINTER, + OB_CURSOR_BUSY, + OB_CURSOR_MOVE, + OB_CURSOR_NORTH, + OB_CURSOR_NORTHEAST, + OB_CURSOR_EAST, + OB_CURSOR_SOUTHEAST, + OB_CURSOR_SOUTH, + OB_CURSOR_SOUTHWEST, + OB_CURSOR_WEST, + OB_CURSOR_NORTHWEST, + OB_NUM_CURSORS +} ObCursor; + +typedef enum +{ + OB_KEY_RETURN, + OB_KEY_ESCAPE, + OB_KEY_LEFT, + OB_KEY_RIGHT, + OB_KEY_UP, + OB_KEY_DOWN, + OB_NUM_KEYS +} ObKey; + +typedef enum +{ + OB_STATE_STARTING, + OB_STATE_RUNNING, + OB_STATE_EXITING +} ObState; + +typedef enum +{ + OB_DIRECTION_NORTH, + OB_DIRECTION_NORTHEAST, + OB_DIRECTION_EAST, + OB_DIRECTION_SOUTHEAST, + OB_DIRECTION_SOUTH, + OB_DIRECTION_SOUTHWEST, + OB_DIRECTION_WEST, + OB_DIRECTION_NORTHWEST +} ObDirection; + +typedef enum +{ + OB_ORIENTATION_HORZ, + OB_ORIENTATION_VERT +} ObOrientation; + +typedef enum +{ + OB_CORNER_TOPLEFT, + OB_CORNER_TOPRIGHT, + OB_CORNER_BOTTOMLEFT, + OB_CORNER_BOTTOMRIGHT +} ObCorner; + +#endif
M openbox/moveresize.copenbox/moveresize.c

@@ -22,10 +22,7 @@ static int start_x, start_y, start_cx, start_cy, start_cw, start_ch;

static int cur_x, cur_y; static guint button; static guint32 corner; -static Corner lockcorner; - -static guint button_return, button_escape, button_left, button_right, - button_up, button_down; +static ObCorner lockcorner; static Popup *popup = NULL; static InternalWindow opaque_window = { { Window_Internal }, None };

@@ -40,13 +37,6 @@ {

XSetWindowAttributes attrib; XGCValues gcv; - button_return = XKeysymToKeycode(ob_display, XStringToKeysym("Return")); - button_escape = XKeysymToKeycode(ob_display, XStringToKeysym("Escape")); - button_left = XKeysymToKeycode(ob_display, XStringToKeysym("Left")); - button_right = XKeysymToKeycode(ob_display, XStringToKeysym("Right")); - button_up = XKeysymToKeycode(ob_display, XStringToKeysym("Up")); - button_down = XKeysymToKeycode(ob_display, XStringToKeysym("Down")); - popup = popup_new(FALSE); popup_size_to_string(popup, "W: 0000 W: 0000");

@@ -91,7 +81,7 @@ }

void moveresize_start(Client *c, int x, int y, guint b, guint32 cnr) { - Cursor cur; + ObCursor cur; Rect *a; g_assert(!moveresize_in_progress);

@@ -124,27 +114,27 @@

moveresize_in_progress = TRUE; if (corner == prop_atoms.net_wm_moveresize_size_topleft) - cur = ob_cursors.tl; + cur = OB_CURSOR_NORTHWEST; else if (corner == prop_atoms.net_wm_moveresize_size_top) - cur = ob_cursors.t; + cur = OB_CURSOR_NORTH; else if (corner == prop_atoms.net_wm_moveresize_size_topright) - cur = ob_cursors.tr; + cur = OB_CURSOR_NORTHEAST; else if (corner == prop_atoms.net_wm_moveresize_size_right) - cur = ob_cursors.r; + cur = OB_CURSOR_EAST; else if (corner == prop_atoms.net_wm_moveresize_size_bottomright) - cur = ob_cursors.br; + cur = OB_CURSOR_SOUTHEAST; else if (corner == prop_atoms.net_wm_moveresize_size_bottom) - cur = ob_cursors.b; + cur = OB_CURSOR_SOUTH; else if (corner == prop_atoms.net_wm_moveresize_size_bottomleft) - cur = ob_cursors.bl; + cur = OB_CURSOR_SOUTHWEST; else if (corner == prop_atoms.net_wm_moveresize_size_left) - cur = ob_cursors.l; + cur = OB_CURSOR_WEST; else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) - cur = ob_cursors.br; + cur = OB_CURSOR_SOUTHEAST; else if (corner == prop_atoms.net_wm_moveresize_move) - cur = ob_cursors.move; + cur = OB_CURSOR_MOVE; else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) - cur = ob_cursors.move; + cur = OB_CURSOR_MOVE; else g_assert_not_reached();

@@ -177,7 +167,7 @@

popup_hide(popup); if (moving) { - client_configure(moveresize_client, Corner_TopLeft, + client_configure(moveresize_client, OB_CORNER_TOPLEFT, (cancel ? start_cx : cur_x), (cancel ? start_cy : cur_y), start_cw, start_ch, TRUE, TRUE);

@@ -205,7 +195,7 @@ oldw = moveresize_client->frame->area.width;

oldh = moveresize_client->frame->area.height; /* get where the client should be */ frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y); - client_configure(moveresize_client, Corner_TopLeft, cur_x, cur_y, + client_configure(moveresize_client, OB_CORNER_TOPLEFT, cur_x, cur_y, start_cw, start_ch, TRUE, FALSE); /* draw the new one */ if (moveresize_client->frame->area.x != oldx ||

@@ -297,72 +287,72 @@ } else {

if (corner == prop_atoms.net_wm_moveresize_size_topleft) { cur_x = start_cw - (e->xmotion.x_root - start_x); cur_y = start_ch - (e->xmotion.y_root - start_y); - lockcorner = Corner_BottomRight; + lockcorner = OB_CORNER_BOTTOMRIGHT; } else if (corner == prop_atoms.net_wm_moveresize_size_top) { cur_x = start_cw; cur_y = start_ch - (e->xmotion.y_root - start_y); - lockcorner = Corner_BottomRight; + lockcorner = OB_CORNER_BOTTOMRIGHT; } else if (corner == prop_atoms.net_wm_moveresize_size_topright) { cur_x = start_cw + (e->xmotion.x_root - start_x); cur_y = start_ch - (e->xmotion.y_root - start_y); - lockcorner = Corner_BottomLeft; + lockcorner = OB_CORNER_BOTTOMLEFT; } else if (corner == prop_atoms.net_wm_moveresize_size_right) { cur_x = start_cw + (e->xmotion.x_root - start_x); cur_y = start_ch; - lockcorner = Corner_BottomLeft; + lockcorner = OB_CORNER_BOTTOMLEFT; } else if (corner == prop_atoms.net_wm_moveresize_size_bottomright) { cur_x = start_cw + (e->xmotion.x_root - start_x); cur_y = start_ch + (e->xmotion.y_root - start_y); - lockcorner = Corner_TopLeft; + lockcorner = OB_CORNER_TOPLEFT; } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) { cur_x = start_cw; cur_y = start_ch + (e->xmotion.y_root - start_y); - lockcorner = Corner_TopLeft; + lockcorner = OB_CORNER_TOPLEFT; } else if (corner == prop_atoms.net_wm_moveresize_size_bottomleft) { cur_x = start_cw - (e->xmotion.x_root - start_x); cur_y = start_ch + (e->xmotion.y_root - start_y); - lockcorner = Corner_TopRight; + lockcorner = OB_CORNER_TOPRIGHT; } else if (corner == prop_atoms.net_wm_moveresize_size_left) { cur_x = start_cw - (e->xmotion.x_root - start_x); cur_y = start_ch; - lockcorner = Corner_TopRight; + lockcorner = OB_CORNER_TOPRIGHT; } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { cur_x = start_cw + (e->xmotion.x_root - start_x); cur_y = start_ch + (e->xmotion.y_root - start_y); - lockcorner = Corner_TopLeft; + lockcorner = OB_CORNER_TOPLEFT; } else g_assert_not_reached(); do_resize(); } } else if (e->type == KeyPress) { - if (e->xkey.keycode == button_escape) + if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) moveresize_end(TRUE); - else if (e->xkey.keycode == button_return) + else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) moveresize_end(FALSE); else { if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { - if (e->xkey.keycode == button_right) + if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT)) cur_x += MAX(4, moveresize_client->size_inc.width); - else if (e->xkey.keycode == button_left) + else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT)) cur_x -= MAX(4, moveresize_client->size_inc.width); - else if (e->xkey.keycode == button_down) + else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN)) cur_y += MAX(4, moveresize_client->size_inc.height); - else if (e->xkey.keycode == button_up) + else if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) cur_y -= MAX(4, moveresize_client->size_inc.height); else return; do_resize(); } else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) { - if (e->xkey.keycode == button_right) + if (e->xkey.keycode == ob_keycode(OB_KEY_RIGHT)) cur_x += 4; - else if (e->xkey.keycode == button_left) + else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT)) cur_x -= 4; - else if (e->xkey.keycode == button_down) + else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN)) cur_y += 4; - else if (e->xkey.keycode == button_up) + else if (e->xkey.keycode == ob_keycode(OB_KEY_UP)) cur_y -= 4; else return;
M openbox/openbox.copenbox/openbox.c

@@ -60,13 +60,14 @@ RrTheme *ob_rr_theme = NULL;

Display *ob_display = NULL; int ob_screen; Window ob_root; -State ob_state; +ObState ob_state; gboolean ob_shutdown = FALSE; gboolean ob_restart = FALSE; char *ob_restart_path = NULL; gboolean ob_remote = TRUE; gboolean ob_sync = FALSE; -Cursors ob_cursors; +Cursor ob_cursors[OB_NUM_CURSORS]; +KeyCode ob_keys[OB_NUM_KEYS]; char *ob_rc_path = NULL; static void signal_handler(const ObEvent *e, void *data);

@@ -92,7 +93,7 @@ char *path;

xmlDocPtr doc; xmlNodePtr node; - ob_state = State_Starting; + ob_state = OB_STATE_STARTING; /* initialize the locale */ if (!setlocale(LC_ALL, ""))

@@ -170,17 +171,43 @@ /* set the DISPLAY environment variable for any lauched children, to the

display we're using, so they open in the right place. */ putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display))); - ob_cursors.ptr = XCreateFontCursor(ob_display, XC_left_ptr); - ob_cursors.busy = XCreateFontCursor(ob_display, XC_watch); - ob_cursors.move = XCreateFontCursor(ob_display, XC_fleur); - ob_cursors.tl = XCreateFontCursor(ob_display, XC_top_left_corner); - ob_cursors.tr = XCreateFontCursor(ob_display, XC_top_right_corner); - ob_cursors.bl = XCreateFontCursor(ob_display, XC_bottom_left_corner); - ob_cursors.br = XCreateFontCursor(ob_display, XC_bottom_right_corner); - ob_cursors.t = XCreateFontCursor(ob_display, XC_top_side); - ob_cursors.r = XCreateFontCursor(ob_display, XC_right_side); - ob_cursors.b = XCreateFontCursor(ob_display, XC_bottom_side); - ob_cursors.l = XCreateFontCursor(ob_display, XC_left_side); + /* create available cursors */ + ob_cursors[OB_CURSOR_POINTER] = + XCreateFontCursor(ob_display, XC_left_ptr); + ob_cursors[OB_CURSOR_BUSY] = + XCreateFontCursor(ob_display, XC_watch); + ob_cursors[OB_CURSOR_MOVE] = + XCreateFontCursor(ob_display, XC_fleur); + ob_cursors[OB_CURSOR_NORTH] = + XCreateFontCursor(ob_display, XC_top_side); + ob_cursors[OB_CURSOR_NORTHEAST] = + XCreateFontCursor(ob_display, XC_top_right_corner); + ob_cursors[OB_CURSOR_EAST] = + XCreateFontCursor(ob_display, XC_right_side); + ob_cursors[OB_CURSOR_SOUTHEAST] = + XCreateFontCursor(ob_display, XC_bottom_right_corner); + ob_cursors[OB_CURSOR_SOUTH] = + XCreateFontCursor(ob_display, XC_bottom_side); + ob_cursors[OB_CURSOR_SOUTHWEST] = + XCreateFontCursor(ob_display, XC_bottom_left_corner); + ob_cursors[OB_CURSOR_WEST] = + XCreateFontCursor(ob_display, XC_left_side); + ob_cursors[OB_CURSOR_NORTHWEST] = + XCreateFontCursor(ob_display, XC_top_left_corner); + + /* create available keycodes */ + ob_keys[OB_KEY_RETURN] = + XKeysymToKeycode(ob_display, XStringToKeysym("Return")); + ob_keys[OB_KEY_ESCAPE] = + XKeysymToKeycode(ob_display, XStringToKeysym("Escape")); + ob_keys[OB_KEY_LEFT] = + XKeysymToKeycode(ob_display, XStringToKeysym("Left")); + ob_keys[OB_KEY_RIGHT] = + XKeysymToKeycode(ob_display, XStringToKeysym("Right")); + ob_keys[OB_KEY_UP] = + XKeysymToKeycode(ob_display, XStringToKeysym("Up")); + ob_keys[OB_KEY_DOWN] = + XKeysymToKeycode(ob_display, XStringToKeysym("Down")); prop_startup(); /* get atoms values for the display */ extensions_query_all(); /* find which extensions are present */

@@ -232,10 +259,10 @@

/* get all the existing windows */ client_manage_all(); - ob_state = State_Running; + ob_state = OB_STATE_RUNNING; while (!ob_shutdown) event_loop(); - ob_state = State_Exiting; + ob_state = OB_STATE_EXITING; dock_remove_all(); client_unmanage_all();

@@ -564,3 +591,15 @@ g_critical(msg);

sm_shutdown(); exit(EXIT_FAILURE); } + +Cursor ob_cursor(ObCursor cursor) +{ + g_assert(cursor < OB_NUM_CURSORS); + return ob_cursors[cursor]; +} + +KeyCode ob_keycode(ObKey key) +{ + g_assert(key < OB_NUM_KEYS); + return ob_keys[key]; +}
M openbox/openbox.hopenbox/openbox.h

@@ -1,6 +1,8 @@

#ifndef __openbox_h #define __openbox_h +#include "misc.h" + #include "render/render.h" #include "render/theme.h"

@@ -27,15 +29,8 @@ extern int ob_screen;

/*! The root window */ extern Window ob_root; -/*! States of execution for Openbox */ -typedef enum { - State_Starting, - State_Exiting, - State_Running -} State; - /* The state of execution of the window manager */ -extern State ob_state; +extern ObState ob_state; /*! When set to true, Openbox will exit */ extern gboolean ob_shutdown;

@@ -50,23 +45,12 @@ extern gboolean ob_remote;

/*! Runtime option to run in synchronous mode */ extern gboolean ob_sync; -typedef struct Cursors { - Cursor ptr; - Cursor busy; - Cursor move; - Cursor bl; - Cursor br; - Cursor tl; - Cursor tr; - Cursor t; - Cursor r; - Cursor b; - Cursor l; -} Cursors; -extern Cursors ob_cursors; - /*! The path of the rc file. If NULL the default paths are searched for one. */ extern char *ob_rc_path; + +Cursor ob_cursor(ObCursor cursor); + +KeyCode ob_keycode(ObKey key); /* cuz i have nowhere better to put it right now... */ gboolean ob_pointer_pos(int *x, int *y);
M openbox/screen.copenbox/screen.c

@@ -247,7 +247,7 @@ screen_physical_size.width = geometry[0] = w;

screen_physical_size.height = geometry[1] = h; PROP_SETA32(ob_root, net_desktop_geometry, cardinal, geometry, 2); - if (ob_state == State_Starting) + if (ob_state == OB_STATE_STARTING) return; dock_configure();

@@ -355,33 +355,42 @@ }

void screen_update_layout() { - guint32 *data = NULL; + ObOrientation orient; + ObCorner corner; + guint rows; + guint cols; + guint32 *data; guint num; - - /* defaults */ - screen_desktop_layout.orientation = prop_atoms.net_wm_orientation_horz; - screen_desktop_layout.start_corner = prop_atoms.net_wm_topleft; - screen_desktop_layout.rows = 1; - screen_desktop_layout.columns = screen_num_desktops; + gboolean valid = FALSE; if (PROP_GETA32(ob_root, net_desktop_layout, cardinal, &data, &num)) { if (num == 3 || num == 4) { + if (data[0] == prop_atoms.net_wm_orientation_vert) - screen_desktop_layout.orientation = data[0]; - if (num == 3) - screen_desktop_layout.start_corner = - prop_atoms.net_wm_topright; + orient = OB_ORIENTATION_VERT; + else if (data[0] == prop_atoms.net_wm_orientation_horz) + orient = OB_ORIENTATION_HORZ; + else + goto screen_update_layout_bail; + + if (num < 4) + corner = OB_CORNER_TOPLEFT; else { if (data[3] == prop_atoms.net_wm_topright) - screen_desktop_layout.start_corner = data[3]; + corner = OB_CORNER_TOPRIGHT; else if (data[3] == prop_atoms.net_wm_bottomright) - screen_desktop_layout.start_corner = data[3]; + corner = OB_CORNER_BOTTOMRIGHT; else if (data[3] == prop_atoms.net_wm_bottomleft) - screen_desktop_layout.start_corner = data[3]; + corner = OB_CORNER_BOTTOMLEFT; + else + goto screen_update_layout_bail; } /* fill in a zero rows/columns */ - if (!(data[1] == 0 && data[2] == 0)) { /* both 0's is bad data.. */ + if ((data[1] == 0 && data[2] == 0) || /* both 0's is bad data.. */ + (data[1] != 0 && data[2] != 0)) { /* no 0's is bad data.. */ + goto screen_update_layout_bail; + } else { if (data[1] == 0) { data[1] = (screen_num_desktops + screen_num_desktops % data[2]) / data[2];

@@ -389,38 +398,39 @@ } else if (data[2] == 0) {

data[2] = (screen_num_desktops + screen_num_desktops % data[1]) / data[1]; } - screen_desktop_layout.columns = data[1]; - screen_desktop_layout.rows = data[2]; + cols = data[1]; + rows = data[2]; } /* bounds checking */ - if (screen_desktop_layout.orientation == - prop_atoms.net_wm_orientation_horz) { - if (screen_desktop_layout.rows > screen_num_desktops) - screen_desktop_layout.rows = screen_num_desktops; - if (screen_desktop_layout.columns > - ((screen_num_desktops + screen_num_desktops % - screen_desktop_layout.rows) / - screen_desktop_layout.rows)) - screen_desktop_layout.columns = - (screen_num_desktops + screen_num_desktops % - screen_desktop_layout.rows) / - screen_desktop_layout.rows; + if (orient == OB_ORIENTATION_HORZ) { + rows = MIN(rows, screen_num_desktops); + cols = MIN(cols, ((screen_num_desktops + + (screen_num_desktops % rows)) / rows)); } else { - if (screen_desktop_layout.columns > screen_num_desktops) - screen_desktop_layout.columns = screen_num_desktops; - if (screen_desktop_layout.rows > - ((screen_num_desktops + screen_num_desktops % - screen_desktop_layout.columns) / - screen_desktop_layout.columns)) - screen_desktop_layout.rows = - (screen_num_desktops + screen_num_desktops % - screen_desktop_layout.columns) / - screen_desktop_layout.columns; + cols = MIN(cols, screen_num_desktops); + rows = MIN(rows, ((screen_num_desktops + + (screen_num_desktops % cols)) / cols)); } + + valid = TRUE; } - g_free(data); + screen_update_layout_bail: + g_free(data); } + + if (!valid) { + /* defaults */ + orient = OB_ORIENTATION_HORZ; + corner = OB_CORNER_TOPLEFT; + rows = 1; + cols = screen_num_desktops; + } + + screen_desktop_layout.orientation = orient; + screen_desktop_layout.start_corner = corner; + screen_desktop_layout.rows = rows; + screen_desktop_layout.columns = cols; } void screen_update_desktop_names()

@@ -715,10 +725,10 @@ static void set_root_cursor()

{ #ifdef USE_LIBSN if (sn_busy_cnt) - XDefineCursor(ob_display, ob_root, ob_cursors.busy); + XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_BUSY)); else #endif - XDefineCursor(ob_display, ob_root, ob_cursors.ptr); + XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_POINTER)); } #ifdef USE_LIBSN
M openbox/screen.hopenbox/screen.h

@@ -1,6 +1,7 @@

#ifndef __screen_h #define __screen_h +#include "misc.h" #include "geom.h" #include "client.h"

@@ -17,15 +18,9 @@ extern guint screen_desktop;

/*! Are we in showing-desktop mode? */ extern gboolean screen_showing_desktop; -/*! Orientation of the desktops */ -typedef enum { - Orientation_Horz = 0, - Orientation_Vert = 1 -} Orientation; - typedef struct DesktopLayout { - Orientation orientation; - Corner start_corner; + ObOrientation orientation; + ObCorner start_corner; guint rows; guint columns; } DesktopLayout;
M openbox/stacking.copenbox/stacking.c

@@ -18,7 +18,7 @@

/* on shutdown, don't update the properties, so that we can read it back in on startup and re-stack the windows as they were before we shut down */ - if (ob_state == State_Exiting) return; + if (ob_state == OB_STATE_EXITING) return; /* create an array of the window ids (from bottom to top, reverse order!) */
M plugins/keyboard/keyboard.cplugins/keyboard/keyboard.c

@@ -78,7 +78,7 @@

KeyBindingTree *firstnode = NULL; static KeyBindingTree *curpos; -static guint reset_key, reset_state, button_return, button_escape; +static guint reset_key, reset_state; static Timer *chain_timer; static void grab_for_window(Window win, gboolean grab)

@@ -177,9 +177,9 @@ if ((e->type == Event_X_KeyRelease &&

!(grabbed_key->state & e->data.x.e->xkey.state))) done = TRUE; else if (e->type == Event_X_KeyPress) { - if (e->data.x.e->xkey.keycode == button_return) + if (e->data.x.e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) done = TRUE; - else if (e->data.x.e->xkey.keycode == button_escape) { + else if (e->data.x.e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) { GSList *it; for (it = grabbed_key->actions; it; it = it->next) { Action *act = it->data;

@@ -258,8 +258,6 @@ }

void plugin_startup() { - guint i; - curpos = NULL; chain_timer = NULL;

@@ -268,8 +266,6 @@ Event_X_KeyPress | Event_X_KeyRelease,

(EventHandler)event, NULL); translate_key("C-g", &reset_state, &reset_key); - translate_key("Escape", &i, &button_escape); - translate_key("Return", &i, &button_return); grab_keys(TRUE); }
M plugins/placement/history.cplugins/placement/history.c

@@ -58,7 +58,7 @@ hi = history_find(c->name, c->class, c->role);

if (hi && !(hi->flags & PLACED)) { hi->flags |= PLACED; - if (ob_state != State_Starting) { + if (ob_state != OB_STATE_STARTING) { if (hi->flags & HAVE_POSITION || hi->flags & HAVE_SIZE) { if (hi->flags & HAVE_POSITION) {

@@ -77,7 +77,7 @@ } else {

w = c->area.width; h = c->area.height; } - client_configure(c, Corner_TopLeft, x, y, w, h, + client_configure(c, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE); } if (hi->flags & HAVE_DESKTOP) {
M plugins/placement/placement.cplugins/placement/placement.c

@@ -30,7 +30,7 @@ int l, r, t, b;

int x, y; Rect *area; - if (ob_state == State_Starting) return; + if (ob_state == OB_STATE_STARTING) return; area = screen_area_monitor(c->desktop, g_random_int_range(0, screen_num_monitors));

@@ -46,7 +46,7 @@ if (b > t) y = g_random_int_range(t, b + 1);

else y = 0; frame_frame_gravity(c->frame, &x, &y); /* get where the client should be */ - client_configure(c, Corner_TopLeft, x, y, c->area.width, c->area.height, + client_configure(c, OB_CORNER_TOPLEFT, x, y, c->area.width, c->area.height, TRUE, TRUE); }
M plugins/resistance/resistance.cplugins/resistance/resistance.c

@@ -131,7 +131,7 @@ *y = ab - h + 1;

} } -static void resist_size(Client *c, int *w, int *h, Corner corn) +static void resist_size(Client *c, int *w, int *h, ObCorner corn) { GList *it; Client *target; /* target */

@@ -177,15 +177,15 @@ if (snapx == NULL) {

/* horizontal snapping */ if (t < tb && b > tt) { switch (corn) { - case Corner_TopLeft: - case Corner_BottomLeft: + case OB_CORNER_TOPLEFT: + case OB_CORNER_BOTTOMLEFT: dlt = l; drb = r + *w - c->frame->area.width; if (r < tl && drb >= tl && drb < tl + resistance) *w = tl - l, snapx = target; break; - case Corner_TopRight: - case Corner_BottomRight: + case OB_CORNER_TOPRIGHT: + case OB_CORNER_BOTTOMRIGHT: dlt = l - *w + c->frame->area.width; drb = r; if (l > tr && dlt <= tr && dlt > tr - resistance)

@@ -199,15 +199,15 @@ if (snapy == NULL) {

/* vertical snapping */ if (l < tr && r > tl) { switch (corn) { - case Corner_TopLeft: - case Corner_TopRight: + case OB_CORNER_TOPLEFT: + case OB_CORNER_TOPRIGHT: dlt = t; drb = b + *h - c->frame->area.height; if (b < tt && drb >= tt && drb < tt + resistance) *h = tt - t, snapy = target; break; - case Corner_BottomLeft: - case Corner_BottomRight: + case OB_CORNER_BOTTOMLEFT: + case OB_CORNER_BOTTOMRIGHT: dlt = t - *h + c->frame->area.height; drb = b; if (t > tb && dlt <= tb && dlt > tb - resistance)

@@ -226,15 +226,15 @@ /* snap to screen edges */

/* horizontal snapping */ switch (corn) { - case Corner_TopLeft: - case Corner_BottomLeft: + case OB_CORNER_TOPLEFT: + case OB_CORNER_BOTTOMLEFT: dlt = l; drb = r + *w - c->frame->area.width; if (r <= ar && drb > ar && drb <= ar + resistance) *w = ar - l + 1; break; - case Corner_TopRight: - case Corner_BottomRight: + case OB_CORNER_TOPRIGHT: + case OB_CORNER_BOTTOMRIGHT: dlt = l - *w + c->frame->area.width; drb = r; if (l >= al && dlt < al && dlt >= al - resistance)

@@ -244,15 +244,15 @@ }

/* vertical snapping */ switch (corn) { - case Corner_TopLeft: - case Corner_TopRight: + case OB_CORNER_TOPLEFT: + case OB_CORNER_TOPRIGHT: dlt = t; drb = b + *h - c->frame->area.height; if (b <= ab && drb > ab && drb <= ab + resistance) *h = ab - t + 1; break; - case Corner_BottomLeft: - case Corner_BottomRight: + case OB_CORNER_BOTTOMLEFT: + case OB_CORNER_BOTTOMRIGHT: dlt = t - *h + c->frame->area.height; drb = b; if (t >= at && dlt < at && dlt >= at - resistance)