From 276b2be581c6cb138b439537761ff2ca42201805 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 10 Jul 2003 06:18:47 +0000 Subject: [PATCH] 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. --- openbox/action.c | 84 +++++++++++++++-------------- openbox/action.h | 2 +- openbox/client.c | 53 +++++++++--------- openbox/client.h | 26 ++------- openbox/dispatch.c | 2 +- openbox/dispatch.h | 2 +- openbox/dock.c | 4 +- openbox/event.c | 15 +++--- openbox/focus.c | 2 +- openbox/frame.c | 6 +-- openbox/grab.c | 14 ++--- openbox/grab.h | 8 +-- openbox/misc.h | 64 ++++++++++++++++++++++ openbox/moveresize.c | 78 ++++++++++++--------------- openbox/openbox.c | 71 ++++++++++++++++++------ openbox/openbox.h | 30 +++-------- openbox/screen.c | 96 ++++++++++++++++++--------------- openbox/screen.h | 11 ++-- openbox/stacking.c | 2 +- plugins/keyboard/keyboard.c | 10 ++-- plugins/placement/history.c | 4 +- plugins/placement/placement.c | 4 +- plugins/resistance/resistance.c | 34 ++++++------ 23 files changed, 346 insertions(+), 276 deletions(-) create mode 100644 openbox/misc.h diff --git a/openbox/action.c b/openbox/action.c index e166dd8b..85261a5f 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -41,42 +41,42 @@ void action_free(Action *a) 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_cycle_windows_previous(Action *a) 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 @@ void action_desktop(union ActionData *data) 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 @@ static void cur_row_col(guint *r, guint *c) 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 void cur_row_col(guint *r, guint *c) 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 @@ void action_movetoedge(union ActionData *data) 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); } diff --git a/openbox/action.h b/openbox/action.h index f79bd56b..9dfbc716 100644 --- a/openbox/action.h +++ b/openbox/action.h @@ -15,7 +15,7 @@ struct AnyAction { struct DirectionalAction{ Client *c; - int direction; + ObDirection direction; }; struct Execute { diff --git a/openbox/client.c b/openbox/client.c index bdf9ed0d..3249fd57 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -254,7 +254,7 @@ void client_manage(Window window) 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 @@ void client_unmanage(Client *self) 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 @@ void client_move_onscreen(Client *self) 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 @@ void client_reconfigure(Client *self) /* 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 @@ void client_update_wmhints(Client *self) /* 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 @@ static void client_apply_startup_state(Client *self) */ } -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 @@ void client_configure(Client *self, Corner anchor, int x, int y, int w, int h, } 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 @@ void client_fullscreen(Client *self, gboolean fs, gboolean savearea) 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 @@ void client_maximize(Client *self, gboolean max, int dir, gboolean savearea) /* 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 @@ Icon *client_icon(Client *self, int w, int h) } /* 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 @@ Client *client_find_directional(Client *c, Direction dir) } 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; } diff --git a/openbox/client.h b/openbox/client.h index ede9df66..1e8adf6e 100644 --- a/openbox/client.h +++ b/openbox/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 @@ typedef enum { 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 @@ typedef enum { 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 @@ gboolean client_focused(Client *self); 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_modal_child(Client *self); 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.
diff --git a/openbox/dispatch.c b/openbox/dispatch.c index 6f2b3d4e..87f41dcc 100644 --- a/openbox/dispatch.c +++ b/openbox/dispatch.c @@ -238,7 +238,7 @@ void dispatch_move(Client *c, int *x, int *y) *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; diff --git a/openbox/dispatch.h b/openbox/dispatch.h index d3ac0d4e..852d0bfc 100644 --- a/openbox/dispatch.h +++ b/openbox/dispatch.h @@ -98,6 +98,6 @@ void dispatch_signal(int signal); 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 diff --git a/openbox/dock.c b/openbox/dock.c index 12985fb7..08f65139 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -91,7 +91,7 @@ void dock_add(Window win, XWMHints *wmhints) 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 @@ void dock_add(Window win, XWMHints *wmhints) 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); diff --git a/openbox/event.c b/openbox/event.c index 6260e912..11eacbd8 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -671,7 +671,7 @@ static void event_handle_client(Client *client, XEvent *e) 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 @@ static void event_handle_client(Client *client, XEvent *e) 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 @@ static void event_handle_client(Client *client, XEvent *e) 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 @@ static void event_handle_client(Client *client, XEvent *e) 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; diff --git a/openbox/focus.c b/openbox/focus.c index 12d30d27..8d5e6c54 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -111,7 +111,7 @@ void focus_set_client(Client *client) 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); } diff --git a/openbox/frame.c b/openbox/frame.c index 5409fc76..a9e287dc 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -61,9 +61,9 @@ Frame *frame_new() 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 @@ void frame_grab_client(Frame *self, Client *client) 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 diff --git a/openbox/grab.c b/openbox/grab.c index 7cb553a2..3f87f3b0 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -32,7 +32,7 @@ gboolean grab_keyboard(gboolean grab) 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 @@ gboolean grab_pointer(gboolean grab, Cursor cur) 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 @@ gboolean grab_pointer(gboolean grab, Cursor cur) 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 @@ gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win) 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 @@ void grab_shutdown() } 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) diff --git a/openbox/grab.h b/openbox/grab.h index 78d7d264..39489ed2 100644 --- a/openbox/grab.h +++ b/openbox/grab.h @@ -1,6 +1,8 @@ #ifndef __grab_h #define __grab_h +#include "misc.h" + #include #include @@ -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); diff --git a/openbox/misc.h b/openbox/misc.h new file mode 100644 index 00000000..5f84a98a --- /dev/null +++ b/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 diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 63de5c5b..93564683 100644 --- a/openbox/moveresize.c +++ b/openbox/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 @@ void moveresize_startup() 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 @@ static void popup_coords(char *format, int a, int b) 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 @@ void moveresize_start(Client *c, int x, int y, guint b, guint32 cnr) 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 @@ void moveresize_end(gboolean cancel) 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 @@ static void do_move() 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 @@ void moveresize_event(XEvent *e) 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; diff --git a/openbox/openbox.c b/openbox/openbox.c index 1298540b..8f19b31a 100644 --- a/openbox/openbox.c +++ b/openbox/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 @@ int main(int argc, char **argv) xmlDocPtr doc; xmlNodePtr node; - ob_state = State_Starting; + ob_state = OB_STATE_STARTING; /* initialize the locale */ if (!setlocale(LC_ALL, "")) @@ -170,17 +171,43 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) /* 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 @@ static void exit_with_error(gchar *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]; +} diff --git a/openbox/openbox.h b/openbox/openbox.h index 7723035e..69004990 100644 --- a/openbox/openbox.h +++ b/openbox/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,24 +45,13 @@ 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); diff --git a/openbox/screen.c b/openbox/screen.c index 75cc3c4c..4998d97c 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -247,7 +247,7 @@ void screen_resize() 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_set_desktop(guint num) 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 @@ void screen_update_layout() 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 diff --git a/openbox/screen.h b/openbox/screen.h index 42e3dc17..b68f6ea5 100644 --- a/openbox/screen.h +++ b/openbox/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; diff --git a/openbox/stacking.c b/openbox/stacking.c index 6316049a..c3d485f5 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -18,7 +18,7 @@ void stacking_set_list() /* 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!) */ diff --git a/plugins/keyboard/keyboard.c b/plugins/keyboard/keyboard.c index 3fe74aea..45b93ac4 100644 --- a/plugins/keyboard/keyboard.c +++ b/plugins/keyboard/keyboard.c @@ -78,7 +78,7 @@ void plugin_setup_config() 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 @@ static void event(ObEvent *e, void *foo) !(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 @@ static void event(ObEvent *e, void *foo) void plugin_startup() { - guint i; - curpos = NULL; chain_timer = NULL; @@ -268,8 +266,6 @@ void plugin_startup() (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); } diff --git a/plugins/placement/history.c b/plugins/placement/history.c index 797aef3b..f2b4ea63 100644 --- a/plugins/placement/history.c +++ b/plugins/placement/history.c @@ -58,7 +58,7 @@ gboolean place_history(Client *c) 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 @@ gboolean place_history(Client *c) 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) { diff --git a/plugins/placement/placement.c b/plugins/placement/placement.c index 589e0a30..b567e229 100644 --- a/plugins/placement/placement.c +++ b/plugins/placement/placement.c @@ -30,7 +30,7 @@ static void place_random(Client *c) 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 @@ static void place_random(Client *c) 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); } diff --git a/plugins/resistance/resistance.c b/plugins/resistance/resistance.c index 31844752..b9539e40 100644 --- a/plugins/resistance/resistance.c +++ b/plugins/resistance/resistance.c @@ -131,7 +131,7 @@ static void resist_move(Client *c, int *x, int *y) } } -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 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* 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 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* 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 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* 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 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* 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) -- 2.45.2