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.
This commit is contained in:
Dana Jansens 2003-07-10 06:18:47 +00:00
parent 6357583c39
commit 276b2be581
23 changed files with 346 additions and 276 deletions

View file

@ -41,42 +41,42 @@ void action_free(Action *a)
void setup_action_directional_focus_north(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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) void setup_action_top_layer(Action *a)
@ -702,7 +702,7 @@ void action_move_relative_horz(union ActionData *data)
{ {
Client *c = data->relative.c; Client *c = data->relative.c;
if (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.x + data->relative.delta, c->area.y,
c->area.width, c->area.height, TRUE, TRUE); 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; Client *c = data->relative.c;
if (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.x, c->area.y + data->relative.delta,
c->area.width, c->area.height, TRUE, TRUE); 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; Client *c = data->relative.c;
if (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 + c->area.width +
data->relative.delta * c->size_inc.width, data->relative.delta * c->size_inc.width,
c->area.height, TRUE, TRUE); c->area.height, TRUE, TRUE);
@ -730,7 +730,7 @@ void action_resize_relative_vert(union ActionData *data)
{ {
Client *c = data->relative.c; Client *c = data->relative.c;
if (c && !c->shaded) 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 + c->area.width, c->area.height +
data->relative.delta * c->size_inc.height, data->relative.delta * c->size_inc.height,
TRUE, TRUE); TRUE, TRUE);
@ -815,23 +815,23 @@ void action_desktop(union ActionData *data)
static void cur_row_col(guint *r, guint *c) static void cur_row_col(guint *r, guint *c)
{ {
switch (screen_desktop_layout.orientation) { switch (screen_desktop_layout.orientation) {
case Orientation_Horz: case OB_ORIENTATION_HORZ:
switch (screen_desktop_layout.start_corner) { switch (screen_desktop_layout.start_corner) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
*r = screen_desktop / screen_desktop_layout.columns; *r = screen_desktop / screen_desktop_layout.columns;
*c = screen_desktop % screen_desktop_layout.columns; *c = screen_desktop % screen_desktop_layout.columns;
break; break;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
*r = screen_desktop_layout.rows - 1 - *r = screen_desktop_layout.rows - 1 -
screen_desktop / screen_desktop_layout.columns; screen_desktop / screen_desktop_layout.columns;
*c = screen_desktop % screen_desktop_layout.columns; *c = screen_desktop % screen_desktop_layout.columns;
break; break;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
*r = screen_desktop / screen_desktop_layout.columns; *r = screen_desktop / screen_desktop_layout.columns;
*c = screen_desktop_layout.columns - 1 - *c = screen_desktop_layout.columns - 1 -
screen_desktop % screen_desktop_layout.columns; screen_desktop % screen_desktop_layout.columns;
break; break;
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
*r = screen_desktop_layout.rows - 1 - *r = screen_desktop_layout.rows - 1 -
screen_desktop / screen_desktop_layout.columns; screen_desktop / screen_desktop_layout.columns;
*c = screen_desktop_layout.columns - 1 - *c = screen_desktop_layout.columns - 1 -
@ -839,23 +839,23 @@ static void cur_row_col(guint *r, guint *c)
break; break;
} }
break; break;
case Orientation_Vert: case OB_ORIENTATION_VERT:
switch (screen_desktop_layout.start_corner) { switch (screen_desktop_layout.start_corner) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
*r = screen_desktop % screen_desktop_layout.rows; *r = screen_desktop % screen_desktop_layout.rows;
*c = screen_desktop / screen_desktop_layout.rows; *c = screen_desktop / screen_desktop_layout.rows;
break; break;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
*r = screen_desktop_layout.rows - 1 - *r = screen_desktop_layout.rows - 1 -
screen_desktop % screen_desktop_layout.rows; screen_desktop % screen_desktop_layout.rows;
*c = screen_desktop / screen_desktop_layout.rows; *c = screen_desktop / screen_desktop_layout.rows;
break; break;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
*r = screen_desktop % screen_desktop_layout.rows; *r = screen_desktop % screen_desktop_layout.rows;
*c = screen_desktop_layout.columns - 1 - *c = screen_desktop_layout.columns - 1 -
screen_desktop / screen_desktop_layout.rows; screen_desktop / screen_desktop_layout.rows;
break; break;
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
*r = screen_desktop_layout.rows - 1 - *r = screen_desktop_layout.rows - 1 -
screen_desktop % screen_desktop_layout.rows; screen_desktop % screen_desktop_layout.rows;
*c = screen_desktop_layout.columns - 1 - *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) static guint translate_row_col(guint r, guint c)
{ {
switch (screen_desktop_layout.orientation) { switch (screen_desktop_layout.orientation) {
case Orientation_Horz: case OB_ORIENTATION_HORZ:
switch (screen_desktop_layout.start_corner) { switch (screen_desktop_layout.start_corner) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
return r % screen_desktop_layout.rows * return r % screen_desktop_layout.rows *
screen_desktop_layout.columns + screen_desktop_layout.columns +
c % screen_desktop_layout.columns; c % screen_desktop_layout.columns;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
return (screen_desktop_layout.rows - 1 - return (screen_desktop_layout.rows - 1 -
r % screen_desktop_layout.rows) * r % screen_desktop_layout.rows) *
screen_desktop_layout.columns + screen_desktop_layout.columns +
c % screen_desktop_layout.columns; c % screen_desktop_layout.columns;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
return r % screen_desktop_layout.rows * return r % screen_desktop_layout.rows *
screen_desktop_layout.columns + screen_desktop_layout.columns +
(screen_desktop_layout.columns - 1 - (screen_desktop_layout.columns - 1 -
c % screen_desktop_layout.columns); c % screen_desktop_layout.columns);
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
return (screen_desktop_layout.rows - 1 - return (screen_desktop_layout.rows - 1 -
r % screen_desktop_layout.rows) * r % screen_desktop_layout.rows) *
screen_desktop_layout.columns + screen_desktop_layout.columns +
(screen_desktop_layout.columns - 1 - (screen_desktop_layout.columns - 1 -
c % screen_desktop_layout.columns); c % screen_desktop_layout.columns);
} }
case Orientation_Vert: case OB_ORIENTATION_VERT:
switch (screen_desktop_layout.start_corner) { switch (screen_desktop_layout.start_corner) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
return c % screen_desktop_layout.columns * return c % screen_desktop_layout.columns *
screen_desktop_layout.rows + screen_desktop_layout.rows +
r % screen_desktop_layout.rows; r % screen_desktop_layout.rows;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
return c % screen_desktop_layout.columns * return c % screen_desktop_layout.columns *
screen_desktop_layout.rows + screen_desktop_layout.rows +
(screen_desktop_layout.rows - 1 - (screen_desktop_layout.rows - 1 -
r % screen_desktop_layout.rows); r % screen_desktop_layout.rows);
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
return (screen_desktop_layout.columns - 1 - return (screen_desktop_layout.columns - 1 -
c % screen_desktop_layout.columns) * c % screen_desktop_layout.columns) *
screen_desktop_layout.rows + screen_desktop_layout.rows +
r % screen_desktop_layout.rows; r % screen_desktop_layout.rows;
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
return (screen_desktop_layout.columns - 1 - return (screen_desktop_layout.columns - 1 -
c % screen_desktop_layout.columns) * c % screen_desktop_layout.columns) *
screen_desktop_layout.rows + screen_desktop_layout.rows +
@ -1167,21 +1167,23 @@ void action_movetoedge(union ActionData *data)
h = screen_area(c->desktop)->height; h = screen_area(c->desktop)->height;
w = screen_area(c->desktop)->width; w = screen_area(c->desktop)->width;
switch(data->diraction.direction) { switch(data->diraction.direction) {
case Direction_North: case OB_DIRECTION_NORTH:
y = 0; y = 0;
break; break;
case Direction_West: case OB_DIRECTION_WEST:
x = 0; x = 0;
break; break;
case Direction_South: case OB_DIRECTION_SOUTH:
y = h - c->frame->area.height; y = h - c->frame->area.height;
break; break;
case Direction_East: case OB_DIRECTION_EAST:
x = w - c->frame->area.width; x = w - c->frame->area.width;
break; break;
default:
g_assert_not_reached();
} }
frame_frame_gravity(c->frame, &x, &y); 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); x, y, c->area.width, c->area.height, TRUE, TRUE);
} }

View file

@ -15,7 +15,7 @@ struct AnyAction {
struct DirectionalAction{ struct DirectionalAction{
Client *c; Client *c;
int direction; ObDirection direction;
}; };
struct Execute { struct Execute {

View file

@ -254,7 +254,7 @@ void client_manage(Window window)
focus_order_add_new(self); focus_order_add_new(self);
/* focus the new window? */ /* 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)) { (self->type == Type_Normal || self->type == Type_Dialog)) {
gboolean group_foc = FALSE; gboolean group_foc = FALSE;
@ -403,7 +403,7 @@ void client_unmanage(Client *self)
frame_release_client(self->frame, self); frame_release_client(self->frame, self);
self->frame = NULL; self->frame = NULL;
if (ob_state != State_Exiting) { if (ob_state != OB_STATE_EXITING) {
/* these values should not be persisted across a window /* these values should not be persisted across a window
unmapping/mapping */ unmapping/mapping */
prop_erase(self->window, prop_atoms.net_wm_desktop); 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 frame_frame_gravity(self->frame, &x, &y); /* get where the client
should be */ should be */
client_configure(self , Corner_TopLeft, x, y, client_configure(self, OB_CORNER_TOPLEFT, x, y,
self->area.width, self->area.height, self->area.width, self->area.height,
TRUE, TRUE); 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 /* 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 every configurenotify causes an update in its normal hints, i think this
is generally what we want anyways... */ 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); 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 /* only do this when first managing the window *AND* when we aren't
starting up! */ starting up! */
if (ob_state != State_Starting && self->frame == NULL) if (ob_state != OB_STATE_STARTING && self->frame == NULL)
if (hints->flags & StateHint) if (hints->flags & StateHint)
self->iconic = hints->initial_state == IconicState; 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 user, gboolean final)
{ {
gboolean moved = FALSE, resized = FALSE; 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) { switch (anchor) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
break; break;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
x -= w - self->area.width; x -= w - self->area.width;
break; break;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
y -= h - self->area.height; y -= h - self->area.height;
break; break;
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
x -= w - self->area.width; x -= w - self->area.width;
y -= h - self->area.height; y -= h - self->area.height;
break; break;
@ -1865,7 +1866,7 @@ void client_fullscreen(Client *self, gboolean fs, gboolean savearea)
client_setup_decor_and_functions(self); 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 */ /* try focus us when we go into fullscreen mode */
client_focus(self); 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 */ /* figure out where the client should be going */
frame_frame_gravity(self->frame, &x, &y); 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) 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 */ /* 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 my_cx, my_cy, his_cx, his_cy;
int offset = 0; int offset = 0;
@ -2512,21 +2513,23 @@ Client *client_find_directional(Client *c, Direction dir)
} }
switch(dir) { switch(dir) {
case Direction_North : case OB_DIRECTION_NORTH:
case Direction_South : case OB_DIRECTION_SOUTH:
case Direction_NorthEast : case OB_DIRECTION_NORTHEAST:
case Direction_SouthWest : case OB_DIRECTION_SOUTHWEST:
offset = (his_cx < 0) ? -his_cx : his_cx; offset = (his_cx < 0) ? -his_cx : his_cx;
distance = (dir == Direction_North || dir == Direction_NorthEast) ? distance = ((dir == OB_DIRECTION_NORTH ||
-his_cy : his_cy; dir == OB_DIRECTION_NORTHEAST) ?
-his_cy : his_cy);
break; break;
case Direction_East : case OB_DIRECTION_EAST:
case Direction_West : case OB_DIRECTION_WEST:
case Direction_SouthEast : case OB_DIRECTION_SOUTHEAST:
case Direction_NorthWest : case OB_DIRECTION_NORTHWEST:
offset = (his_cy < 0) ? -his_cy : his_cy; offset = (his_cy < 0) ? -his_cy : his_cy;
distance = (dir == Direction_West || dir == Direction_NorthWest) ? distance = ((dir == OB_DIRECTION_WEST ||
-his_cx : his_cx; dir == OB_DIRECTION_NORTHWEST) ?
-his_cx : his_cx);
break; break;
} }

View file

@ -1,6 +1,7 @@
#ifndef __client_h #ifndef __client_h
#define __client_h #define __client_h
#include "misc.h"
#include "geom.h" #include "geom.h"
#include "stacking.h" #include "stacking.h"
#include "render/color.h" #include "render/color.h"
@ -64,14 +65,6 @@ typedef enum {
MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */ MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */
} MemDecorations; } MemDecorations;
/*! Corners of the client window, used for anchor positions */
typedef enum {
Corner_TopLeft,
Corner_TopRight,
Corner_BottomLeft,
Corner_BottomRight
} Corner;
/*! Possible window types */ /*! Possible window types */
typedef enum { typedef enum {
Type_Desktop, /*!< A desktop (bottom-most window) */ Type_Desktop, /*!< A desktop (bottom-most window) */
@ -110,18 +103,6 @@ typedef enum {
Decor_Close = 1 << 8 /*!< Display a close button */ Decor_Close = 1 << 8 /*!< Display a close button */
} Decoration; } 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 { typedef struct Client {
ObWindow obwin; ObWindow obwin;
@ -346,7 +327,8 @@ gboolean client_focused(Client *self);
interactive move/resize, and then be TRUE for the last call interactive move/resize, and then be TRUE for the last call
only. 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); gboolean user, gboolean final);
void client_reconfigure(Client *self); void client_reconfigure(Client *self);
@ -499,7 +481,7 @@ Client *client_search_modal_child(Client *self);
Client *client_search_top_transient(Client *self); Client *client_search_top_transient(Client *self);
/*! Return the "closest" client in the given direction */ /*! 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. /*! Set a client window to be above/below other clients.
@layer < 0 indicates the client should be placed below other clients.<br> @layer < 0 indicates the client should be placed below other clients.<br>

View file

@ -238,7 +238,7 @@ void dispatch_move(Client *c, int *x, int *y)
*y = obe.data.c.num[1]; *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; guint i;
GSList *it; GSList *it;

View file

@ -98,6 +98,6 @@ void dispatch_signal(int signal);
void dispatch_move(Client *c, int *x, int *y); void dispatch_move(Client *c, int *x, int *y);
/* *w and *h should be set with the destination of the window, they may be /* *w and *h should be set with the destination of the window, they may be
changed by the event handlers */ 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 #endif

View file

@ -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 member set the root window, and one set to the client, but both get
handled and need to be ignored. handled and need to be ignored.
*/ */
if (ob_state == State_Starting) if (ob_state == OB_STATE_STARTING)
app->ignore_unmaps += 2; app->ignore_unmaps += 2;
if (app->win != app->icon_win) { 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, grab_button_full(2, 0, app->icon_win,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
GrabModeAsync, ob_cursors.move); GrabModeAsync, OB_CURSOR_MOVE);
g_hash_table_insert(window_map, &app->icon_win, app); g_hash_table_insert(window_map, &app->icon_win, app);

View file

@ -671,7 +671,7 @@ static void event_handle_client(Client *client, XEvent *e)
break; break;
case EnterNotify: case EnterNotify:
if (client_normal(client)) { if (client_normal(client)) {
if (ob_state == State_Starting) { if (ob_state == OB_STATE_STARTING) {
/* move it to the top of the focus order */ /* move it to the top of the focus order */
guint desktop = client->desktop; guint desktop = client->desktop;
if (desktop == DESKTOP_ALL) desktop = screen_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 | if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
CWX | CWY)) { CWX | CWY)) {
int x, y, w, h; int x, y, w, h;
Corner corner; ObCorner corner;
x = (e->xconfigurerequest.value_mask & CWX) ? x = (e->xconfigurerequest.value_mask & CWX) ?
e->xconfigurerequest.x : client->area.x; e->xconfigurerequest.x : client->area.x;
@ -736,17 +736,17 @@ static void event_handle_client(Client *client, XEvent *e)
switch (client->gravity) { switch (client->gravity) {
case NorthEastGravity: case NorthEastGravity:
case EastGravity: case EastGravity:
corner = Corner_TopRight; corner = OB_CORNER_TOPRIGHT;
break; break;
case SouthWestGravity: case SouthWestGravity:
case SouthGravity: case SouthGravity:
corner = Corner_BottomLeft; corner = OB_CORNER_BOTTOMLEFT;
break; break;
case SouthEastGravity: case SouthEastGravity:
corner = Corner_BottomRight; corner = OB_CORNER_BOTTOMRIGHT;
break; break;
default: /* NorthWest, Static, etc */ default: /* NorthWest, Static, etc */
corner = Corner_TopLeft; corner = OB_CORNER_TOPLEFT;
} }
client_configure(client, corner, x, y, w, h, FALSE, TRUE); client_configure(client, corner, x, y, w, h, FALSE, TRUE);
@ -920,7 +920,8 @@ static void event_handle_client(Client *client, XEvent *e)
else else
h = client->area.y; h = client->area.y;
client->gravity = tmpg; 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; client->gravity = oldg;
} }
break; break;

View file

@ -111,7 +111,7 @@ void focus_set_client(Client *client)
push_to_top(client); push_to_top(client);
/* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */ /* 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; active = client ? client->window : None;
PROP_SET32(ob_root, net_active_window, window, active); PROP_SET32(ob_root, net_active_window, window, active);
} }

View file

@ -61,9 +61,9 @@ Frame *frame_new()
self->iconify = createWindow(self->title, mask, &attrib); self->iconify = createWindow(self->title, mask, &attrib);
self->handle = createWindow(self->window, mask, &attrib); self->handle = createWindow(self->window, mask, &attrib);
mask |= CWCursor; mask |= CWCursor;
attrib.cursor = ob_cursors.bl; attrib.cursor = ob_cursor(OB_CURSOR_SOUTHWEST);
self->lgrip = createWindow(self->handle, mask, &attrib); 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->rgrip = createWindow(self->handle, mask, &attrib);
self->focused = FALSE; 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 member set the root window, and one set to the client, but both get
handled and need to be ignored. handled and need to be ignored.
*/ */
if (ob_state == State_Starting) if (ob_state == OB_STATE_STARTING)
client->ignore_unmaps += 2; client->ignore_unmaps += 2;
/* select the event mask on the client's parent (to receive config/map /* select the event mask on the client's parent (to receive config/map

View file

@ -32,7 +32,7 @@ gboolean grab_keyboard(gboolean grab)
return ret; return ret;
} }
gboolean grab_pointer(gboolean grab, Cursor cur) gboolean grab_pointer(gboolean grab, ObCursor cur)
{ {
static guint pgrabs = 0; static guint pgrabs = 0;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -40,7 +40,8 @@ gboolean grab_pointer(gboolean grab, Cursor cur)
if (grab) { if (grab) {
if (pgrabs++ == 0) if (pgrabs++ == 0)
ret = XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK, ret = XGrabPointer(ob_display, ob_root, False, GRAB_PTR_MASK,
GrabModeAsync, GrabModeAsync, FALSE, cur, GrabModeAsync, GrabModeAsync, FALSE,
ob_cursor(cur),
event_lasttime) == Success; event_lasttime) == Success;
else else
ret = TRUE; ret = TRUE;
@ -52,7 +53,7 @@ gboolean grab_pointer(gboolean grab, Cursor cur)
return ret; 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; static guint pgrabs = 0;
gboolean ret = FALSE; gboolean ret = FALSE;
@ -60,7 +61,8 @@ gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win)
if (grab) { if (grab) {
if (pgrabs++ == 0) if (pgrabs++ == 0)
ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK, ret = XGrabPointer(ob_display, win, False, GRAB_PTR_MASK,
GrabModeAsync, GrabModeAsync, TRUE, cur, GrabModeAsync, GrabModeAsync, TRUE,
ob_cursor(cur),
event_lasttime) == Success; event_lasttime) == Success;
else else
ret = TRUE; ret = TRUE;
@ -113,13 +115,13 @@ void grab_shutdown()
} }
void grab_button_full(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 cur)
{ {
guint i; guint i;
for (i = 0; i < MASK_LIST_SIZE; ++i) for (i = 0; i < MASK_LIST_SIZE; ++i)
XGrabButton(ob_display, button, state | mask_list[i], win, FALSE, mask, 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) void grab_button(guint button, guint state, Window win, guint mask)

View file

@ -1,6 +1,8 @@
#ifndef __grab_h #ifndef __grab_h
#define __grab_h #define __grab_h
#include "misc.h"
#include <glib.h> #include <glib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -8,13 +10,13 @@ void grab_startup();
void grab_shutdown(); void grab_shutdown();
gboolean grab_keyboard(gboolean grab); gboolean grab_keyboard(gboolean grab);
gboolean grab_pointer(gboolean grab, Cursor cur); gboolean grab_pointer(gboolean grab, ObCursor cur);
gboolean grab_pointer_window(gboolean grab, Cursor cur, Window win); gboolean grab_pointer_window(gboolean grab, ObCursor cur, Window win);
void grab_server(gboolean grab); void grab_server(gboolean grab);
void grab_button(guint button, guint state, Window win, guint mask); void grab_button(guint button, guint state, Window win, guint mask);
void grab_button_full(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 ungrab_button(guint button, guint state, Window win);
void grab_key(guint keycode, guint state, Window win, int keyboard_mode); void grab_key(guint keycode, guint state, Window win, int keyboard_mode);

64
openbox/misc.h Normal file
View file

@ -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

View file

@ -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 int cur_x, cur_y;
static guint button; static guint button;
static guint32 corner; static guint32 corner;
static Corner lockcorner; static ObCorner lockcorner;
static guint button_return, button_escape, button_left, button_right,
button_up, button_down;
static Popup *popup = NULL; static Popup *popup = NULL;
static InternalWindow opaque_window = { { Window_Internal }, None }; static InternalWindow opaque_window = { { Window_Internal }, None };
@ -40,13 +37,6 @@ void moveresize_startup()
XSetWindowAttributes attrib; XSetWindowAttributes attrib;
XGCValues gcv; 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 = popup_new(FALSE);
popup_size_to_string(popup, "W: 0000 W: 0000"); 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) void moveresize_start(Client *c, int x, int y, guint b, guint32 cnr)
{ {
Cursor cur; ObCursor cur;
Rect *a; Rect *a;
g_assert(!moveresize_in_progress); 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; moveresize_in_progress = TRUE;
if (corner == prop_atoms.net_wm_moveresize_size_topleft) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) else if (corner == prop_atoms.net_wm_moveresize_move_keyboard)
cur = ob_cursors.move; cur = OB_CURSOR_MOVE;
else else
g_assert_not_reached(); g_assert_not_reached();
@ -177,7 +167,7 @@ void moveresize_end(gboolean cancel)
popup_hide(popup); popup_hide(popup);
if (moving) { if (moving) {
client_configure(moveresize_client, Corner_TopLeft, client_configure(moveresize_client, OB_CORNER_TOPLEFT,
(cancel ? start_cx : cur_x), (cancel ? start_cx : cur_x),
(cancel ? start_cy : cur_y), (cancel ? start_cy : cur_y),
start_cw, start_ch, TRUE, TRUE); start_cw, start_ch, TRUE, TRUE);
@ -205,7 +195,7 @@ static void do_move()
oldh = moveresize_client->frame->area.height; oldh = moveresize_client->frame->area.height;
/* get where the client should be */ /* get where the client should be */
frame_frame_gravity(moveresize_client->frame, &cur_x, &cur_y); 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); start_cw, start_ch, TRUE, FALSE);
/* draw the new one */ /* draw the new one */
if (moveresize_client->frame->area.x != oldx || 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) { if (corner == prop_atoms.net_wm_moveresize_size_topleft) {
cur_x = start_cw - (e->xmotion.x_root - start_x); cur_x = start_cw - (e->xmotion.x_root - start_x);
cur_y = start_ch - (e->xmotion.y_root - start_y); 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) { } else if (corner == prop_atoms.net_wm_moveresize_size_top) {
cur_x = start_cw; cur_x = start_cw;
cur_y = start_ch - (e->xmotion.y_root - start_y); 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) { } else if (corner == prop_atoms.net_wm_moveresize_size_topright) {
cur_x = start_cw + (e->xmotion.x_root - start_x); cur_x = start_cw + (e->xmotion.x_root - start_x);
cur_y = start_ch - (e->xmotion.y_root - start_y); 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) { } else if (corner == prop_atoms.net_wm_moveresize_size_right) {
cur_x = start_cw + (e->xmotion.x_root - start_x); cur_x = start_cw + (e->xmotion.x_root - start_x);
cur_y = start_ch; cur_y = start_ch;
lockcorner = Corner_BottomLeft; lockcorner = OB_CORNER_BOTTOMLEFT;
} else if (corner == } else if (corner ==
prop_atoms.net_wm_moveresize_size_bottomright) { prop_atoms.net_wm_moveresize_size_bottomright) {
cur_x = start_cw + (e->xmotion.x_root - start_x); cur_x = start_cw + (e->xmotion.x_root - start_x);
cur_y = start_ch + (e->xmotion.y_root - start_y); 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) { } else if (corner == prop_atoms.net_wm_moveresize_size_bottom) {
cur_x = start_cw; cur_x = start_cw;
cur_y = start_ch + (e->xmotion.y_root - start_y); cur_y = start_ch + (e->xmotion.y_root - start_y);
lockcorner = Corner_TopLeft; lockcorner = OB_CORNER_TOPLEFT;
} else if (corner == } else if (corner ==
prop_atoms.net_wm_moveresize_size_bottomleft) { prop_atoms.net_wm_moveresize_size_bottomleft) {
cur_x = start_cw - (e->xmotion.x_root - start_x); cur_x = start_cw - (e->xmotion.x_root - start_x);
cur_y = start_ch + (e->xmotion.y_root - start_y); 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) { } else if (corner == prop_atoms.net_wm_moveresize_size_left) {
cur_x = start_cw - (e->xmotion.x_root - start_x); cur_x = start_cw - (e->xmotion.x_root - start_x);
cur_y = start_ch; cur_y = start_ch;
lockcorner = Corner_TopRight; lockcorner = OB_CORNER_TOPRIGHT;
} else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { } else if (corner == prop_atoms.net_wm_moveresize_size_keyboard) {
cur_x = start_cw + (e->xmotion.x_root - start_x); cur_x = start_cw + (e->xmotion.x_root - start_x);
cur_y = start_ch + (e->xmotion.y_root - start_y); cur_y = start_ch + (e->xmotion.y_root - start_y);
lockcorner = Corner_TopLeft; lockcorner = OB_CORNER_TOPLEFT;
} else } else
g_assert_not_reached(); g_assert_not_reached();
do_resize(); do_resize();
} }
} else if (e->type == KeyPress) { } else if (e->type == KeyPress) {
if (e->xkey.keycode == button_escape) if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
moveresize_end(TRUE); moveresize_end(TRUE);
else if (e->xkey.keycode == button_return) else if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN))
moveresize_end(FALSE); moveresize_end(FALSE);
else { else {
if (corner == prop_atoms.net_wm_moveresize_size_keyboard) { 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); 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); 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); 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); cur_y -= MAX(4, moveresize_client->size_inc.height);
else else
return; return;
do_resize(); do_resize();
} else if (corner == prop_atoms.net_wm_moveresize_move_keyboard) { } 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; cur_x += 4;
else if (e->xkey.keycode == button_left) else if (e->xkey.keycode == ob_keycode(OB_KEY_LEFT))
cur_x -= 4; cur_x -= 4;
else if (e->xkey.keycode == button_down) else if (e->xkey.keycode == ob_keycode(OB_KEY_DOWN))
cur_y += 4; cur_y += 4;
else if (e->xkey.keycode == button_up) else if (e->xkey.keycode == ob_keycode(OB_KEY_UP))
cur_y -= 4; cur_y -= 4;
else else
return; return;

View file

@ -60,13 +60,14 @@ RrTheme *ob_rr_theme = NULL;
Display *ob_display = NULL; Display *ob_display = NULL;
int ob_screen; int ob_screen;
Window ob_root; Window ob_root;
State ob_state; ObState ob_state;
gboolean ob_shutdown = FALSE; gboolean ob_shutdown = FALSE;
gboolean ob_restart = FALSE; gboolean ob_restart = FALSE;
char *ob_restart_path = NULL; char *ob_restart_path = NULL;
gboolean ob_remote = TRUE; gboolean ob_remote = TRUE;
gboolean ob_sync = FALSE; gboolean ob_sync = FALSE;
Cursors ob_cursors; Cursor ob_cursors[OB_NUM_CURSORS];
KeyCode ob_keys[OB_NUM_KEYS];
char *ob_rc_path = NULL; char *ob_rc_path = NULL;
static void signal_handler(const ObEvent *e, void *data); static void signal_handler(const ObEvent *e, void *data);
@ -92,7 +93,7 @@ int main(int argc, char **argv)
xmlDocPtr doc; xmlDocPtr doc;
xmlNodePtr node; xmlNodePtr node;
ob_state = State_Starting; ob_state = OB_STATE_STARTING;
/* initialize the locale */ /* initialize the locale */
if (!setlocale(LC_ALL, "")) 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. */ display we're using, so they open in the right place. */
putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display))); putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display)));
ob_cursors.ptr = XCreateFontCursor(ob_display, XC_left_ptr); /* create available cursors */
ob_cursors.busy = XCreateFontCursor(ob_display, XC_watch); ob_cursors[OB_CURSOR_POINTER] =
ob_cursors.move = XCreateFontCursor(ob_display, XC_fleur); XCreateFontCursor(ob_display, XC_left_ptr);
ob_cursors.tl = XCreateFontCursor(ob_display, XC_top_left_corner); ob_cursors[OB_CURSOR_BUSY] =
ob_cursors.tr = XCreateFontCursor(ob_display, XC_top_right_corner); XCreateFontCursor(ob_display, XC_watch);
ob_cursors.bl = XCreateFontCursor(ob_display, XC_bottom_left_corner); ob_cursors[OB_CURSOR_MOVE] =
ob_cursors.br = XCreateFontCursor(ob_display, XC_bottom_right_corner); XCreateFontCursor(ob_display, XC_fleur);
ob_cursors.t = XCreateFontCursor(ob_display, XC_top_side); ob_cursors[OB_CURSOR_NORTH] =
ob_cursors.r = XCreateFontCursor(ob_display, XC_right_side); XCreateFontCursor(ob_display, XC_top_side);
ob_cursors.b = XCreateFontCursor(ob_display, XC_bottom_side); ob_cursors[OB_CURSOR_NORTHEAST] =
ob_cursors.l = XCreateFontCursor(ob_display, XC_left_side); 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 */ prop_startup(); /* get atoms values for the display */
extensions_query_all(); /* find which extensions are present */ extensions_query_all(); /* find which extensions are present */
@ -232,10 +259,10 @@ int main(int argc, char **argv)
/* get all the existing windows */ /* get all the existing windows */
client_manage_all(); client_manage_all();
ob_state = State_Running; ob_state = OB_STATE_RUNNING;
while (!ob_shutdown) while (!ob_shutdown)
event_loop(); event_loop();
ob_state = State_Exiting; ob_state = OB_STATE_EXITING;
dock_remove_all(); dock_remove_all();
client_unmanage_all(); client_unmanage_all();
@ -564,3 +591,15 @@ static void exit_with_error(gchar *msg)
sm_shutdown(); sm_shutdown();
exit(EXIT_FAILURE); 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];
}

View file

@ -1,6 +1,8 @@
#ifndef __openbox_h #ifndef __openbox_h
#define __openbox_h #define __openbox_h
#include "misc.h"
#include "render/render.h" #include "render/render.h"
#include "render/theme.h" #include "render/theme.h"
@ -27,15 +29,8 @@ extern int ob_screen;
/*! The root window */ /*! The root window */
extern Window ob_root; 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 */ /* The state of execution of the window manager */
extern State ob_state; extern ObState ob_state;
/*! When set to true, Openbox will exit */ /*! When set to true, Openbox will exit */
extern gboolean ob_shutdown; extern gboolean ob_shutdown;
@ -50,24 +45,13 @@ extern gboolean ob_remote;
/*! Runtime option to run in synchronous mode */ /*! Runtime option to run in synchronous mode */
extern gboolean ob_sync; 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. */ /*! The path of the rc file. If NULL the default paths are searched for one. */
extern char *ob_rc_path; 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... */ /* cuz i have nowhere better to put it right now... */
gboolean ob_pointer_pos(int *x, int *y); gboolean ob_pointer_pos(int *x, int *y);

View file

@ -247,7 +247,7 @@ void screen_resize()
screen_physical_size.height = geometry[1] = h; screen_physical_size.height = geometry[1] = h;
PROP_SETA32(ob_root, net_desktop_geometry, cardinal, geometry, 2); PROP_SETA32(ob_root, net_desktop_geometry, cardinal, geometry, 2);
if (ob_state == State_Starting) if (ob_state == OB_STATE_STARTING)
return; return;
dock_configure(); dock_configure();
@ -355,33 +355,42 @@ void screen_set_desktop(guint num)
void screen_update_layout() void screen_update_layout()
{ {
guint32 *data = NULL; ObOrientation orient;
ObCorner corner;
guint rows;
guint cols;
guint32 *data;
guint num; guint num;
gboolean valid = FALSE;
/* 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;
if (PROP_GETA32(ob_root, net_desktop_layout, cardinal, &data, &num)) { if (PROP_GETA32(ob_root, net_desktop_layout, cardinal, &data, &num)) {
if (num == 3 || num == 4) { if (num == 3 || num == 4) {
if (data[0] == prop_atoms.net_wm_orientation_vert) if (data[0] == prop_atoms.net_wm_orientation_vert)
screen_desktop_layout.orientation = data[0]; orient = OB_ORIENTATION_VERT;
if (num == 3) else if (data[0] == prop_atoms.net_wm_orientation_horz)
screen_desktop_layout.start_corner = orient = OB_ORIENTATION_HORZ;
prop_atoms.net_wm_topright; else
goto screen_update_layout_bail;
if (num < 4)
corner = OB_CORNER_TOPLEFT;
else { else {
if (data[3] == prop_atoms.net_wm_topright) 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) 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) 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 */ /* 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) { if (data[1] == 0) {
data[1] = (screen_num_desktops + data[1] = (screen_num_desktops +
screen_num_desktops % data[2]) / data[2]; screen_num_desktops % data[2]) / data[2];
@ -389,38 +398,39 @@ void screen_update_layout()
data[2] = (screen_num_desktops + data[2] = (screen_num_desktops +
screen_num_desktops % data[1]) / data[1]; screen_num_desktops % data[1]) / data[1];
} }
screen_desktop_layout.columns = data[1]; cols = data[1];
screen_desktop_layout.rows = data[2]; rows = data[2];
} }
/* bounds checking */ /* bounds checking */
if (screen_desktop_layout.orientation == if (orient == OB_ORIENTATION_HORZ) {
prop_atoms.net_wm_orientation_horz) { rows = MIN(rows, screen_num_desktops);
if (screen_desktop_layout.rows > screen_num_desktops) cols = MIN(cols, ((screen_num_desktops +
screen_desktop_layout.rows = screen_num_desktops; (screen_num_desktops % rows)) / rows));
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;
} else { } else {
if (screen_desktop_layout.columns > screen_num_desktops) cols = MIN(cols, screen_num_desktops);
screen_desktop_layout.columns = screen_num_desktops; rows = MIN(rows, ((screen_num_desktops +
if (screen_desktop_layout.rows > (screen_num_desktops % cols)) / cols));
((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;
} }
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() void screen_update_desktop_names()
@ -715,10 +725,10 @@ static void set_root_cursor()
{ {
#ifdef USE_LIBSN #ifdef USE_LIBSN
if (sn_busy_cnt) if (sn_busy_cnt)
XDefineCursor(ob_display, ob_root, ob_cursors.busy); XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_BUSY));
else else
#endif #endif
XDefineCursor(ob_display, ob_root, ob_cursors.ptr); XDefineCursor(ob_display, ob_root, ob_cursor(OB_CURSOR_POINTER));
} }
#ifdef USE_LIBSN #ifdef USE_LIBSN

View file

@ -1,6 +1,7 @@
#ifndef __screen_h #ifndef __screen_h
#define __screen_h #define __screen_h
#include "misc.h"
#include "geom.h" #include "geom.h"
#include "client.h" #include "client.h"
@ -17,15 +18,9 @@ extern guint screen_desktop;
/*! Are we in showing-desktop mode? */ /*! Are we in showing-desktop mode? */
extern gboolean screen_showing_desktop; extern gboolean screen_showing_desktop;
/*! Orientation of the desktops */
typedef enum {
Orientation_Horz = 0,
Orientation_Vert = 1
} Orientation;
typedef struct DesktopLayout { typedef struct DesktopLayout {
Orientation orientation; ObOrientation orientation;
Corner start_corner; ObCorner start_corner;
guint rows; guint rows;
guint columns; guint columns;
} DesktopLayout; } DesktopLayout;

View file

@ -18,7 +18,7 @@ void stacking_set_list()
/* on shutdown, don't update the properties, so that we can read it back /* 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 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, /* create an array of the window ids (from bottom to top,
reverse order!) */ reverse order!) */

View file

@ -78,7 +78,7 @@ void plugin_setup_config()
KeyBindingTree *firstnode = NULL; KeyBindingTree *firstnode = NULL;
static KeyBindingTree *curpos; static KeyBindingTree *curpos;
static guint reset_key, reset_state, button_return, button_escape; static guint reset_key, reset_state;
static Timer *chain_timer; static Timer *chain_timer;
static void grab_for_window(Window win, gboolean grab) 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))) !(grabbed_key->state & e->data.x.e->xkey.state)))
done = TRUE; done = TRUE;
else if (e->type == Event_X_KeyPress) { 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; 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; GSList *it;
for (it = grabbed_key->actions; it; it = it->next) { for (it = grabbed_key->actions; it; it = it->next) {
Action *act = it->data; Action *act = it->data;
@ -258,8 +258,6 @@ static void event(ObEvent *e, void *foo)
void plugin_startup() void plugin_startup()
{ {
guint i;
curpos = NULL; curpos = NULL;
chain_timer = NULL; chain_timer = NULL;
@ -268,8 +266,6 @@ void plugin_startup()
(EventHandler)event, NULL); (EventHandler)event, NULL);
translate_key("C-g", &reset_state, &reset_key); translate_key("C-g", &reset_state, &reset_key);
translate_key("Escape", &i, &button_escape);
translate_key("Return", &i, &button_return);
grab_keys(TRUE); grab_keys(TRUE);
} }

View file

@ -58,7 +58,7 @@ gboolean place_history(Client *c)
if (hi && !(hi->flags & PLACED)) { if (hi && !(hi->flags & PLACED)) {
hi->flags |= PLACED; hi->flags |= PLACED;
if (ob_state != State_Starting) { if (ob_state != OB_STATE_STARTING) {
if (hi->flags & HAVE_POSITION || if (hi->flags & HAVE_POSITION ||
hi->flags & HAVE_SIZE) { hi->flags & HAVE_SIZE) {
if (hi->flags & HAVE_POSITION) { if (hi->flags & HAVE_POSITION) {
@ -77,7 +77,7 @@ gboolean place_history(Client *c)
w = c->area.width; w = c->area.width;
h = c->area.height; 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); TRUE, TRUE);
} }
if (hi->flags & HAVE_DESKTOP) { if (hi->flags & HAVE_DESKTOP) {

View file

@ -30,7 +30,7 @@ static void place_random(Client *c)
int x, y; int x, y;
Rect *area; Rect *area;
if (ob_state == State_Starting) return; if (ob_state == OB_STATE_STARTING) return;
area = screen_area_monitor(c->desktop, area = screen_area_monitor(c->desktop,
g_random_int_range(0, screen_num_monitors)); g_random_int_range(0, screen_num_monitors));
@ -46,7 +46,7 @@ static void place_random(Client *c)
else y = 0; else y = 0;
frame_frame_gravity(c->frame, &x, &y); /* get where the client should be */ 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); TRUE, TRUE);
} }

View file

@ -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; GList *it;
Client *target; /* target */ Client *target; /* target */
@ -177,15 +177,15 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
/* horizontal snapping */ /* horizontal snapping */
if (t < tb && b > tt) { if (t < tb && b > tt) {
switch (corn) { switch (corn) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
dlt = l; dlt = l;
drb = r + *w - c->frame->area.width; drb = r + *w - c->frame->area.width;
if (r < tl && drb >= tl && drb < tl + resistance) if (r < tl && drb >= tl && drb < tl + resistance)
*w = tl - l, snapx = target; *w = tl - l, snapx = target;
break; break;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
dlt = l - *w + c->frame->area.width; dlt = l - *w + c->frame->area.width;
drb = r; drb = r;
if (l > tr && dlt <= tr && dlt > tr - resistance) 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 */ /* vertical snapping */
if (l < tr && r > tl) { if (l < tr && r > tl) {
switch (corn) { switch (corn) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
dlt = t; dlt = t;
drb = b + *h - c->frame->area.height; drb = b + *h - c->frame->area.height;
if (b < tt && drb >= tt && drb < tt + resistance) if (b < tt && drb >= tt && drb < tt + resistance)
*h = tt - t, snapy = target; *h = tt - t, snapy = target;
break; break;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
dlt = t - *h + c->frame->area.height; dlt = t - *h + c->frame->area.height;
drb = b; drb = b;
if (t > tb && dlt <= tb && dlt > tb - resistance) 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 */ /* horizontal snapping */
switch (corn) { switch (corn) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
dlt = l; dlt = l;
drb = r + *w - c->frame->area.width; drb = r + *w - c->frame->area.width;
if (r <= ar && drb > ar && drb <= ar + resistance) if (r <= ar && drb > ar && drb <= ar + resistance)
*w = ar - l + 1; *w = ar - l + 1;
break; break;
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
dlt = l - *w + c->frame->area.width; dlt = l - *w + c->frame->area.width;
drb = r; drb = r;
if (l >= al && dlt < al && dlt >= al - resistance) 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 */ /* vertical snapping */
switch (corn) { switch (corn) {
case Corner_TopLeft: case OB_CORNER_TOPLEFT:
case Corner_TopRight: case OB_CORNER_TOPRIGHT:
dlt = t; dlt = t;
drb = b + *h - c->frame->area.height; drb = b + *h - c->frame->area.height;
if (b <= ab && drb > ab && drb <= ab + resistance) if (b <= ab && drb > ab && drb <= ab + resistance)
*h = ab - t + 1; *h = ab - t + 1;
break; break;
case Corner_BottomLeft: case OB_CORNER_BOTTOMLEFT:
case Corner_BottomRight: case OB_CORNER_BOTTOMRIGHT:
dlt = t - *h + c->frame->area.height; dlt = t - *h + c->frame->area.height;
drb = b; drb = b;
if (t >= at && dlt < at && dlt >= at - resistance) if (t >= at && dlt < at && dlt >= at - resistance)