From a42a92778dfdb99d938ca54f9d88203851951065 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 5 Aug 2011 21:36:20 -0400 Subject: [PATCH] Make a structure to hold a keycode+modifers and mousebutton+modifiers, and use them for the config values. Makes a complete value for these so it's one variable instead of two. --- openbox/config.c | 22 ++++++++++------------ openbox/config.h | 12 +++++------- openbox/dock.c | 8 ++++---- openbox/keyboard.c | 8 ++++---- openbox/keyboard.h | 7 +++++++ openbox/mouse.h | 7 +++++++ 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/openbox/config.c b/openbox/config.c index 9dd803be..5b7caad1 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -83,11 +83,9 @@ ObOrientation config_dock_orient; gboolean config_dock_hide; guint config_dock_hide_delay; guint config_dock_show_delay; -guint config_dock_app_move_button; -guint config_dock_app_move_modifiers; +ObMouseButton config_dock_app_move_button; -guint config_keyboard_reset_keycode; -guint config_keyboard_reset_state; +ObKeyboardKey config_keyboard_reset_key; gint config_mouse_threshold; gint config_mouse_dclicktime; @@ -430,8 +428,8 @@ static void parse_keyboard(xmlNodePtr node, gpointer d) if ((n = obt_xml_find_sibling(node->children, "chainQuitKey"))) { key = obt_xml_node_string(n); - translate_key(key, &config_keyboard_reset_state, - &config_keyboard_reset_keycode); + translate_key(key, &config_keyboard_reset_key.modifiers, + &config_keyboard_reset_key.keycode); g_free(key); } @@ -857,8 +855,8 @@ static void parse_dock(xmlNodePtr node, gpointer d) gchar *str = obt_xml_node_string(n); guint b, s; if (translate_button(str, &s, &b)) { - config_dock_app_move_button = b; - config_dock_app_move_modifiers = s; + config_dock_app_move_button.button = b; + config_dock_app_move_button.modifiers = s; } else { g_message(_("Invalid button \"%s\" specified in config file"), str); } @@ -1079,13 +1077,13 @@ void config_startup(ObtXmlInst *i) config_dock_hide = FALSE; config_dock_hide_delay = 300; config_dock_show_delay = 300; - config_dock_app_move_button = 2; /* middle */ - config_dock_app_move_modifiers = 0; + config_dock_app_move_button.button = 2; /* middle */ + config_dock_app_move_button.modifiers = 0; obt_xml_register(i, "dock", parse_dock, NULL); - translate_key("C-g", &config_keyboard_reset_state, - &config_keyboard_reset_keycode); + translate_key("C-g", &config_keyboard_reset_key.modifiers, + &config_keyboard_reset_key.keycode); bind_default_keyboard(); diff --git a/openbox/config.h b/openbox/config.h index 90b6581a..834193de 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -25,6 +25,8 @@ #include "place.h" #include "client.h" #include "geom.h" +#include "keyboard.h" +#include "mouse.h" #include "moveresize.h" #include "obrender/render.h" #include "obt/xml.h" @@ -129,9 +131,7 @@ extern guint config_dock_hide_delay; /*! The number of milliseconds to wait before showing the dock */ extern guint config_dock_show_delay; /*! The mouse button to be used to move dock apps */ -extern guint config_dock_app_move_button; -/*! The modifiers to be used with the button to move dock apps */ -extern guint config_dock_app_move_modifiers; +extern ObMouseButton config_dock_app_move_button; /*! The name of the theme */ extern gchar *config_theme; @@ -167,10 +167,8 @@ extern GSList *config_desktops_names; /*! Amount of time to show the desktop switch dialog */ extern guint config_desktop_popup_time; -/*! The keycode of the key combo which resets the keybaord chains */ -extern guint config_keyboard_reset_keycode; -/*! The modifiers of the key combo which resets the keybaord chains */ -extern guint config_keyboard_reset_state; +/*! The key combo which resets the keybaord chains */ +extern ObKeyboardKey config_keyboard_reset_key; /*! Number of pixels a drag must go before being considered a drag */ extern gint config_mouse_threshold; diff --git a/openbox/dock.c b/openbox/dock.c index c26eee62..b8092a18 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -41,14 +41,14 @@ StrutPartial dock_strut; static void dock_app_grab_button(ObDockApp *app, gboolean grab) { if (grab) { - grab_button_full(config_dock_app_move_button, - config_dock_app_move_modifiers, app->icon_win, + grab_button_full(config_dock_app_move_button.button, + config_dock_app_move_button.modifiers, app->icon_win, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, GrabModeAsync, OB_CURSOR_MOVE); } else { - ungrab_button(config_dock_app_move_button, - config_dock_app_move_modifiers, app->icon_win); + ungrab_button(config_dock_app_move_button.button, + config_dock_app_move_button.modifiers, app->icon_win); } } diff --git a/openbox/keyboard.c b/openbox/keyboard.c index a3cd9d0e..8d609677 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -59,8 +59,8 @@ static void grab_keys(gboolean grab) p = p->next_sibling; } if (curpos) - grab_key(config_keyboard_reset_keycode, - config_keyboard_reset_state, + grab_key(config_keyboard_reset_key.keycode, + config_keyboard_reset_key.modifiers, obt_root(ob_screen), GrabModeAsync); } } @@ -235,8 +235,8 @@ gboolean keyboard_event(ObClient *client, const XEvent *e) mods = obt_keyboard_only_modmasks(e->xkey.state); - if (e->xkey.keycode == config_keyboard_reset_keycode && - mods == config_keyboard_reset_state) + if (e->xkey.keycode == config_keyboard_reset_key.keycode && + mods == config_keyboard_reset_key.modifiers) { if (chain_timer) g_source_remove(chain_timer); keyboard_reset_chains(-1); diff --git a/openbox/keyboard.h b/openbox/keyboard.h index 300a9106..b6bcab30 100644 --- a/openbox/keyboard.h +++ b/openbox/keyboard.h @@ -26,11 +26,18 @@ #include #include +typedef struct _ObKeyboardKey ObKeyboardKey; + struct _ObClient; struct _ObActionList; extern KeyBindingTree *keyboard_firstnode; +struct _ObKeyboardKey { + guint keycode; + guint modifiers; +}; + void keyboard_startup(gboolean reconfig); void keyboard_shutdown(gboolean reconfig); diff --git a/openbox/mouse.h b/openbox/mouse.h index 5f38c9f4..ad519e2f 100644 --- a/openbox/mouse.h +++ b/openbox/mouse.h @@ -24,8 +24,15 @@ #include +typedef struct _ObMouseButton ObMouseButton; + struct _ObActionList; +struct _ObMouseButton { + guint button; + guint modifiers; +}; + void mouse_startup(gboolean reconfig); void mouse_shutdown(gboolean reconfig); -- 2.34.1