From d206303a9f0742ff330aebe8129d6044ade30a94 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 10 Jul 2003 16:29:40 +0000 Subject: [PATCH] prefixing for the dock. use ObDirection instead of dupliacting it in another enum for the dock's placement --- openbox/config.c | 34 +++--- openbox/config.h | 7 +- openbox/dock.c | 264 ++++++++++++++++++++++++----------------------- openbox/dock.h | 50 ++++----- openbox/event.c | 12 +-- openbox/window.c | 2 +- openbox/window.h | 8 +- 7 files changed, 193 insertions(+), 184 deletions(-) diff --git a/openbox/config.c b/openbox/config.c index 491097e4..b8ffa9a6 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -16,7 +16,8 @@ gboolean config_opaque_move; gboolean config_opaque_resize; StackLayer config_dock_layer; -DockPosition config_dock_pos; +gboolean config_dock_floating; +ObDirection config_dock_pos; int config_dock_x; int config_dock_y; gboolean config_dock_horz; @@ -89,25 +90,33 @@ static void parse_dock(xmlDocPtr doc, xmlNodePtr node, void *d) if ((n = parse_find_node("position", node))) { if (parse_contains("TopLeft", doc, n)) - config_dock_pos = DockPos_TopLeft; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_NORTHWEST; else if (parse_contains("Top", doc, n)) - config_dock_pos = DockPos_Top; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_NORTH; else if (parse_contains("TopRight", doc, n)) - config_dock_pos = DockPos_TopRight; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_NORTHEAST; else if (parse_contains("Right", doc, n)) - config_dock_pos = DockPos_Right; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_EAST; else if (parse_contains("BottomRight", doc, n)) - config_dock_pos = DockPos_BottomRight; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_SOUTHEAST; else if (parse_contains("Bottom", doc, n)) - config_dock_pos = DockPos_Bottom; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_SOUTH; else if (parse_contains("BottomLeft", doc, n)) - config_dock_pos = DockPos_BottomLeft; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_SOUTHWEST; else if (parse_contains("Left", doc, n)) - config_dock_pos = DockPos_Left; + config_dock_floating = FALSE, + config_dock_pos = OB_DIRECTION_WEST; else if (parse_contains("Floating", doc, n)) - config_dock_pos = DockPos_Floating; + config_dock_floating = TRUE; } - if (config_dock_pos == DockPos_Floating) { + if (config_dock_floating) { if ((n = parse_find_node("floatingX", node))) config_dock_x = parse_int(doc, n); if ((n = parse_find_node("floatingY", node))) @@ -158,7 +167,8 @@ void config_startup() parse_register("moveresize", parse_moveresize, NULL); config_dock_layer = Layer_Top; - config_dock_pos = DockPos_TopRight; + config_dock_pos = OB_DIRECTION_NORTHEAST; + config_dock_floating = FALSE; config_dock_x = 0; config_dock_y = 0; config_dock_horz = FALSE; diff --git a/openbox/config.h b/openbox/config.h index 71aa4e1d..6b0f3be5 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -1,6 +1,7 @@ #ifndef __config_h #define __config_h +#include "misc.h" #include "dock.h" #include "stacking.h" @@ -27,8 +28,10 @@ extern gboolean config_opaque_resize; /*! The stacking layer the dock will reside in */ extern StackLayer config_dock_layer; -/*! The position at which to place the dock */ -extern DockPosition config_dock_pos; +/*! Is the dock floating */ +extern gboolean config_dock_floating; +/*! Where to place the dock if not floating */ +extern ObDirection config_dock_pos; /*! If config_dock_pos is DockPos_Floating, this is the top-left corner's position */ extern int config_dock_x; diff --git a/openbox/dock.c b/openbox/dock.c index 08f65139..5a9e02ec 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -10,7 +10,7 @@ EnterWindowMask | LeaveWindowMask) #define DOCKAPP_EVENT_MASK (StructureNotifyMask) -static Dock *dock; +static ObDock *dock; Strut dock_strut; @@ -20,7 +20,7 @@ void dock_startup() STRUT_SET(dock_strut, 0, 0, 0, 0); - dock = g_new0(struct Dock, 1); + dock = g_new0(ObDock, 1); dock->obwin.type = Window_Dock; dock->hidden = TRUE; @@ -51,11 +51,11 @@ void dock_shutdown() void dock_add(Window win, XWMHints *wmhints) { - DockApp *app; + ObDockApp *app; XWindowAttributes attrib; - char **data; + gchar **data; - app = g_new0(DockApp, 1); + app = g_new0(ObDockApp, 1); app->obwin.type = Window_DockApp; app->win = win; app->icon_win = (wmhints->flags & IconWindowHint) ? @@ -122,7 +122,7 @@ void dock_remove_all() dock_remove(dock->dock_apps->data, TRUE); } -void dock_remove(DockApp *app, gboolean reparent) +void dock_remove(ObDockApp *app, gboolean reparent) { ungrab_button(2, 0, app->icon_win); XSelectInput(ob_display, app->icon_win, NoEventMask); @@ -148,10 +148,10 @@ void dock_remove(DockApp *app, gboolean reparent) void dock_configure() { GList *it; - int spot; - int gravity; - int minw, minh; - int strw, strh; + gint spot; + gint gravity; + gint minw, minh; + gint strw, strh; Rect *a; RrMinsize(dock->a_frame, &minw, &minh); @@ -160,7 +160,7 @@ void dock_configure() /* get the size */ for (it = dock->dock_apps; it; it = it->next) { - struct DockApp *app = it->data; + ObDockApp *app = it->data; if (config_dock_horz) { dock->w += app->w; dock->h = MAX(dock->h, app->h); @@ -174,7 +174,7 @@ void dock_configure() /* position the apps */ for (it = dock->dock_apps; it; it = it->next) { - struct DockApp *app = it->data; + ObDockApp *app = it->data; if (config_dock_horz) { app->x = spot; app->y = (dock->h - app->h) / 2; @@ -195,52 +195,53 @@ void dock_configure() a = screen_physical_area(); /* calculate position */ - switch (config_dock_pos) { - case DockPos_Floating: + if (config_dock_floating) { dock->x = config_dock_x; dock->y = config_dock_y; gravity = NorthWestGravity; - break; - case DockPos_TopLeft: - dock->x = 0; - dock->y = 0; - gravity = NorthWestGravity; - break; - case DockPos_Top: - dock->x = a->width / 2; - dock->y = 0; - gravity = NorthGravity; - break; - case DockPos_TopRight: - dock->x = a->width; - dock->y = 0; - gravity = NorthEastGravity; - break; - case DockPos_Left: - dock->x = 0; - dock->y = a->height / 2; - gravity = WestGravity; - break; - case DockPos_Right: - dock->x = a->width; - dock->y = a->height / 2; - gravity = EastGravity; - break; - case DockPos_BottomLeft: - dock->x = 0; - dock->y = a->height; - gravity = SouthWestGravity; - break; - case DockPos_Bottom: - dock->x = a->width / 2; - dock->y = a->height; - gravity = SouthGravity; - break; - case DockPos_BottomRight: - dock->x = a->width; - dock->y = a->height; - gravity = SouthEastGravity; - break; + } else { + switch (config_dock_pos) { + case OB_DIRECTION_NORTHWEST: + dock->x = 0; + dock->y = 0; + gravity = NorthWestGravity; + break; + case OB_DIRECTION_NORTH: + dock->x = a->width / 2; + dock->y = 0; + gravity = NorthGravity; + break; + case OB_DIRECTION_NORTHEAST: + dock->x = a->width; + dock->y = 0; + gravity = NorthEastGravity; + break; + case OB_DIRECTION_WEST: + dock->x = 0; + dock->y = a->height / 2; + gravity = WestGravity; + break; + case OB_DIRECTION_EAST: + dock->x = a->width; + dock->y = a->height / 2; + gravity = EastGravity; + break; + case OB_DIRECTION_SOUTHWEST: + dock->x = 0; + dock->y = a->height; + gravity = SouthWestGravity; + break; + case OB_DIRECTION_SOUTH: + dock->x = a->width / 2; + dock->y = a->height; + gravity = SouthGravity; + break; + case OB_DIRECTION_SOUTHEAST: + dock->x = a->width; + dock->y = a->height; + gravity = SouthEastGravity; + break; + } } switch(gravity) { @@ -269,49 +270,49 @@ void dock_configure() } if (config_dock_hide && dock->hidden) { - switch (config_dock_pos) { - case DockPos_Floating: - break; - case DockPos_TopLeft: - if (config_dock_horz) + if (!config_dock_floating) { + switch (config_dock_pos) { + case OB_DIRECTION_NORTHWEST: + if (config_dock_horz) + dock->y -= dock->h - ob_rr_theme->bwidth; + else + dock->x -= dock->w - ob_rr_theme->bwidth; + break; + case OB_DIRECTION_NORTH: dock->y -= dock->h - ob_rr_theme->bwidth; - else + break; + case OB_DIRECTION_NORTHEAST: + if (config_dock_horz) + dock->y -= dock->h - ob_rr_theme->bwidth; + else + dock->x += dock->w - ob_rr_theme->bwidth; + break; + case OB_DIRECTION_WEST: dock->x -= dock->w - ob_rr_theme->bwidth; - break; - case DockPos_Top: - dock->y -= dock->h - ob_rr_theme->bwidth; - break; - case DockPos_TopRight: - if (config_dock_horz) - dock->y -= dock->h - ob_rr_theme->bwidth; - else + break; + case OB_DIRECTION_EAST: dock->x += dock->w - ob_rr_theme->bwidth; - break; - case DockPos_Left: - dock->x -= dock->w - ob_rr_theme->bwidth; - break; - case DockPos_Right: - dock->x += dock->w - ob_rr_theme->bwidth; - break; - case DockPos_BottomLeft: - if (config_dock_horz) - dock->y += dock->h - ob_rr_theme->bwidth; - else - dock->x -= dock->w - ob_rr_theme->bwidth; - break; - case DockPos_Bottom: - dock->y += dock->h - ob_rr_theme->bwidth; - break; - case DockPos_BottomRight: - if (config_dock_horz) + break; + case OB_DIRECTION_SOUTHWEST: + if (config_dock_horz) + dock->y += dock->h - ob_rr_theme->bwidth; + else + dock->x -= dock->w - ob_rr_theme->bwidth; + break; + case OB_DIRECTION_SOUTH: dock->y += dock->h - ob_rr_theme->bwidth; - else - dock->x += dock->w - ob_rr_theme->bwidth; - break; - } + break; + case OB_DIRECTION_SOUTHEAST: + if (config_dock_horz) + dock->y += dock->h - ob_rr_theme->bwidth; + else + dock->x += dock->w - ob_rr_theme->bwidth; + break; + } + } } - if (config_dock_pos != DockPos_Floating && config_dock_hide) { + if (!config_dock_floating && config_dock_hide) { strw = strh = ob_rr_theme->bwidth; } else { strw = dock->w; @@ -319,46 +320,47 @@ void dock_configure() } /* set the strut */ - switch (config_dock_pos) { - case DockPos_Floating: + if (config_dock_floating) { STRUT_SET(dock_strut, 0, 0, 0, 0); - break; - case DockPos_TopLeft: - if (config_dock_horz) + } else { + switch (config_dock_pos) { + case OB_DIRECTION_NORTHWEST: + if (config_dock_horz) + STRUT_SET(dock_strut, 0, strh, 0, 0); + else + STRUT_SET(dock_strut, strw, 0, 0, 0); + break; + case OB_DIRECTION_NORTH: STRUT_SET(dock_strut, 0, strh, 0, 0); - else + break; + case OB_DIRECTION_NORTHEAST: + if (config_dock_horz) + STRUT_SET(dock_strut, 0, strh, 0, 0); + else + STRUT_SET(dock_strut, 0, 0, strw, 0); + break; + case OB_DIRECTION_WEST: STRUT_SET(dock_strut, strw, 0, 0, 0); - break; - case DockPos_Top: - STRUT_SET(dock_strut, 0, strh, 0, 0); - break; - case DockPos_TopRight: - if (config_dock_horz) - STRUT_SET(dock_strut, 0, strh, 0, 0); - else + break; + case OB_DIRECTION_EAST: STRUT_SET(dock_strut, 0, 0, strw, 0); - break; - case DockPos_Left: - STRUT_SET(dock_strut, strw, 0, 0, 0); - break; - case DockPos_Right: - STRUT_SET(dock_strut, 0, 0, strw, 0); - break; - case DockPos_BottomLeft: - if (config_dock_horz) - STRUT_SET(dock_strut, 0, 0, 0, strh); - else - STRUT_SET(dock_strut, strw, 0, 0, 0); - break; - case DockPos_Bottom: - STRUT_SET(dock_strut, 0, 0, 0, strh); - break; - case DockPos_BottomRight: - if (config_dock_horz) + break; + case OB_DIRECTION_SOUTHWEST: + if (config_dock_horz) + STRUT_SET(dock_strut, 0, 0, 0, strh); + else + STRUT_SET(dock_strut, strw, 0, 0, 0); + break; + case OB_DIRECTION_SOUTH: STRUT_SET(dock_strut, 0, 0, 0, strh); - else - STRUT_SET(dock_strut, 0, 0, strw, 0); - break; + break; + case OB_DIRECTION_SOUTHEAST: + if (config_dock_horz) + STRUT_SET(dock_strut, 0, 0, 0, strh); + else + STRUT_SET(dock_strut, 0, 0, strw, 0); + break; + } } dock->w += minw; @@ -384,18 +386,18 @@ void dock_configure() screen_update_areas(); } -void dock_app_configure(DockApp *app, int w, int h) +void dock_app_configure(ObDockApp *app, gint w, gint h) { app->w = w; app->h = h; dock_configure(); } -void dock_app_drag(DockApp *app, XMotionEvent *e) +void dock_app_drag(ObDockApp *app, XMotionEvent *e) { - DockApp *over = NULL; + ObDockApp *over = NULL; GList *it; - int x, y; + gint x, y; gboolean after; x = e->x_root; diff --git a/openbox/dock.h b/openbox/dock.h index d70519a3..aa18da84 100644 --- a/openbox/dock.h +++ b/openbox/dock.h @@ -11,50 +11,44 @@ #include #include -typedef enum { - DockPos_Floating, - DockPos_TopLeft, - DockPos_Top, - DockPos_TopRight, - DockPos_Right, - DockPos_BottomRight, - DockPos_Bottom, - DockPos_BottomLeft, - DockPos_Left -} DockPosition; - -typedef struct Dock { +typedef struct _ObDock ObDock; +typedef struct _ObDockApp ObDockApp; + +struct _ObDock +{ ObWindow obwin; Window frame; RrAppearance *a_frame; /* actual position (when not auto-hidden) */ - int x, y; - int w, h; + gint x; + gint y; + gint w; + gint h; gboolean hidden; Timer *hide_timer; GList *dock_apps; -} Dock; +}; -typedef struct DockApp { +struct _ObDockApp { ObWindow obwin; - int ignore_unmaps; + gint ignore_unmaps; Window icon_win; Window win; - char *name; - char *class; + gchar *name; + gchar *class; - int x; - int y; - int w; - int h; -} DockApp; + gint x; + gint y; + gint w; + gint h; +}; extern Strut dock_strut; @@ -67,9 +61,9 @@ void dock_hide(gboolean hide); void dock_add(Window win, XWMHints *wmhints); void dock_remove_all(); -void dock_remove(DockApp *app, gboolean reparent); +void dock_remove(ObDockApp *app, gboolean reparent); -void dock_app_drag(DockApp *app, XMotionEvent *e); -void dock_app_configure(DockApp *app, int w, int h); +void dock_app_drag(ObDockApp *app, XMotionEvent *e); +void dock_app_configure(ObDockApp *app, gint w, gint h); #endif diff --git a/openbox/event.c b/openbox/event.c index 7c5ab11f..8acca386 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -38,8 +38,8 @@ static void event_process(XEvent *e); static void event_handle_root(XEvent *e); -static void event_handle_dock(Dock *s, XEvent *e); -static void event_handle_dockapp(DockApp *app, XEvent *e); +static void event_handle_dock(ObDock *s, XEvent *e); +static void event_handle_dockapp(ObDockApp *app, XEvent *e); static void event_handle_client(ObClient *c, XEvent *e); static void event_handle_menu(ObClient *c, XEvent *e); static void fd_event_handle(); @@ -468,8 +468,8 @@ static void event_process(XEvent *e) { Window window; ObClient *client = NULL; - Dock *dock = NULL; - DockApp *dockapp = NULL; + ObDock *dock = NULL; + ObDockApp *dockapp = NULL; Menu *menu = NULL; ObWindow *obwin = NULL; @@ -1145,7 +1145,7 @@ static void fd_event_handle() g_datalist_foreach(&fd_handler_list, fd_event_handle_foreach, NULL); } -static void event_handle_dock(Dock *s, XEvent *e) +static void event_handle_dock(ObDock *s, XEvent *e) { switch (e->type) { case ButtonPress: @@ -1160,7 +1160,7 @@ static void event_handle_dock(Dock *s, XEvent *e) } } -static void event_handle_dockapp(DockApp *app, XEvent *e) +static void event_handle_dockapp(ObDockApp *app, XEvent *e) { switch (e->type) { case MotionNotify: diff --git a/openbox/window.c b/openbox/window.c index 15cebcd7..781aa5db 100644 --- a/openbox/window.c +++ b/openbox/window.c @@ -23,7 +23,7 @@ Window window_top(ObWindow *self) case Window_Menu: return ((Menu*)self)->frame; case Window_Dock: - return ((Dock*)self)->frame; + return ((ObDock*)self)->frame; case Window_DockApp: /* not to be used for stacking */ g_assert_not_reached(); diff --git a/openbox/window.h b/openbox/window.h index edb54e17..7e7e4d34 100644 --- a/openbox/window.h +++ b/openbox/window.h @@ -30,13 +30,13 @@ typedef struct InternalWindow { #define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal) struct Menu; -struct Dock; -struct DockApp; +struct _ObDock; +struct _ObDockApp; struct _ObClient; #define WINDOW_AS_MENU(win) ((struct Menu*)win) -#define WINDOW_AS_DOCK(win) ((struct Dock*)win) -#define WINDOW_AS_DOCKAPP(win) ((struct DockApp*)win) +#define WINDOW_AS_DOCK(win) ((struct _ObDock*)win) +#define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win) #define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win) #define WINDOW_AS_INTERNAL(win) ((struct InternalWindow*)win) -- 2.45.2