diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/keyb.h | 59 | ||||
-rw-r--r-- | include/theme.h | 12 | ||||
-rw-r--r-- | include/view-internal.h | 8 | ||||
-rw-r--r-- | include/view.h | 2 | ||||
-rw-r--r-- | include/widgets/listview.h | 2 | ||||
-rw-r--r-- | include/widgets/scrollbar.h | 3 | ||||
-rw-r--r-- | include/widgets/textbox.h | 7 | ||||
-rw-r--r-- | include/widgets/widget-internal.h | 70 | ||||
-rw-r--r-- | include/widgets/widget.h | 55 | ||||
-rw-r--r-- | include/x11-helper.h | 38 | ||||
-rw-r--r-- | include/xkb-internal.h | 23 |
11 files changed, 145 insertions, 134 deletions
diff --git a/include/keyb.h b/include/keyb.h index 37263a34..e33b00b0 100644 --- a/include/keyb.h +++ b/include/keyb.h @@ -28,19 +28,34 @@ #ifndef ROFI_KEYB_H #define ROFI_KEYB_H +#include "nkutils-bindings.h" + /** * @defgroup KEYB KeyboardBindings * * @{ */ +typedef enum +{ + SCOPE_GLOBAL, + SCOPE_MOUSE_LISTVIEW, + SCOPE_MOUSE_LISTVIEW_ELEMENT, + +#define SCOPE_MIN_FIXED SCOPE_MOUSE_EDITBOX + SCOPE_MOUSE_EDITBOX, + SCOPE_MOUSE_SCROLLBAR, + SCOPE_MOUSE_SIDEBAR_MODI, +#define SCOPE_MAX_FIXED SCOPE_MOUSE_SIDEBAR_MODI +} BindingsScope; + /** * List of all possible actions that can be triggered by a keybinding. */ typedef enum { /** Paste from primary clipboard */ - PASTE_PRIMARY = 0, + PASTE_PRIMARY = 1, /** Paste from secondary clipboard */ PASTE_SECONDARY, /** Clear the entry box. */ @@ -119,14 +134,36 @@ typedef enum SELECT_ELEMENT_8, SELECT_ELEMENT_9, SELECT_ELEMENT_10, - NUM_ABE } KeyBindingAction; +typedef enum +{ + SCROLL_LEFT = 1, + SCROLL_RIGHT, + SCROLL_DOWN, + SCROLL_UP, +} MouseBindingListviewAction; + +typedef enum +{ + SELECT_HOVERED_ENTRY = 1, + ACCEPT_HOVERED_ENTRY, + ACCEPT_HOVERED_CUSTOM, +} MouseBindingListviewElementAction; + +typedef enum +{ + MOUSE_CLICK_DOWN = 1, + MOUSE_CLICK_UP, + MOUSE_DCLICK_DOWN, + MOUSE_DCLICK_UP, +} MouseBindingMouseDefaultAction; + /** * Parse the keybindings. * This should be called after the setting system is initialized. */ -gboolean parse_keys_abe ( void ); +gboolean parse_keys_abe ( NkBindings *bindings ); /** * Setup the keybindings @@ -134,21 +171,5 @@ gboolean parse_keys_abe ( void ); */ void setup_abe ( void ); -/** - * Cleanup. - */ -void cleanup_abe ( void ); - -/** - * Find if a binding has been triggered. - * @returns NUM_ABE if no key combo matches, a valid action otherwise. - */ -KeyBindingAction abe_find_action ( unsigned int mask, xkb_keysym_t key ); - -/** - * Trigger keybinding on key release. - */ -void abe_trigger_release ( void ); - /*@}*/ #endif // ROFI_KEYB_H diff --git a/include/theme.h b/include/theme.h index 8bdeddc1..9b03b32c 100644 --- a/include/theme.h +++ b/include/theme.h @@ -37,19 +37,19 @@ typedef enum { /** no highlight */ - HL_NONE = 0, + HL_NONE = 0, /** bold */ - HL_BOLD = 1, + HL_BOLD = 1, /** underline */ - HL_UNDERLINE = 2, + HL_UNDERLINE = 2, /** strikethrough */ HL_STRIKETHROUGH = 16, /** small caps */ - HL_SMALL_CAPS = 32, + HL_SMALL_CAPS = 32, /** italic */ - HL_ITALIC = 4, + HL_ITALIC = 4, /** color */ - HL_COLOR = 8 + HL_COLOR = 8 } HighlightStyle; /** Style of line */ diff --git a/include/view-internal.h b/include/view-internal.h index e4cb619c..4271b90e 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -122,8 +122,14 @@ struct RofiViewState /** Y position of the view */ int y; + struct + { + int x; + int y; + } mouse; + /** Regexs used for matching */ - GRegex **tokens; + GRegex **tokens; }; /** @} */ #endif diff --git a/include/view.h b/include/view.h index cb5d45d1..a7f3ebbe 100644 --- a/include/view.h +++ b/include/view.h @@ -143,7 +143,7 @@ void rofi_view_restart ( RofiViewState *state ); * * @returns TRUE if action was handled. */ -gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction action ); +gboolean rofi_view_trigger_action ( guint scope, gpointer user_data ); /** * @param state The handle to the view diff --git a/include/widgets/listview.h b/include/widgets/listview.h index 4373cc6b..81d705b1 100644 --- a/include/widgets/listview.h +++ b/include/widgets/listview.h @@ -66,7 +66,7 @@ typedef void ( *listview_update_callback )( textbox *tb, unsigned int entry, voi /** * Callback when a element is activated. */ -typedef void ( *listview_mouse_activated_cb )( listview *, xcb_button_press_event_t *, void * ); +typedef void ( *listview_mouse_activated_cb )( listview *, gboolean, void * ); /** * @param name The name of the to be created widget. diff --git a/include/widgets/scrollbar.h b/include/widgets/scrollbar.h index 75ecfbf9..50fb78bc 100644 --- a/include/widgets/scrollbar.h +++ b/include/widgets/scrollbar.h @@ -43,6 +43,7 @@ typedef struct _scrollbar { widget widget; + gboolean scrolling; unsigned int length; unsigned int pos; unsigned int pos_length; @@ -88,7 +89,7 @@ void scrollbar_set_max_value ( scrollbar *sb, unsigned int max ); * * Calculate the position of the click relative to the max value of bar */ -unsigned int scrollbar_clicked ( const scrollbar *sb, int y ); +unsigned int scrollbar_scroll ( const scrollbar *sb, int y ); /*@}*/ #endif // ROFI_SCROLLBAR_H diff --git a/include/widgets/textbox.h b/include/widgets/textbox.h index fc75baa7..2209de29 100644 --- a/include/widgets/textbox.h +++ b/include/widgets/textbox.h @@ -120,9 +120,10 @@ typedef enum * free with #widget_free * @returns a new #textbox */ -textbox* textbox_create ( const char *name, TextboxFlags flags, - TextBoxFontType tbft, - const char *text ); +textbox* textbox_create_full ( WidgetType type, const char *name, TextboxFlags flags, + TextBoxFontType tbft, + const char *text ); +#define textbox_create( n, f, tbft, t ) textbox_create_full ( WIDGET_TYPE_UNKNOWN, n, f, tbft, t ) /** * @param tb Handle to the textbox * @param tbft The style of font to render. diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h index 0ac497d5..60e1d11c 100644 --- a/include/widgets/widget-internal.h +++ b/include/widgets/widget-internal.h @@ -34,63 +34,67 @@ */ struct _widget { + /** The type of the widget */ + WidgetType type; /** X position relative to parent */ - short x; + short x; /** Y position relative to parent */ - short y; + short y; /** Width of the widget */ - short w; + short w; /** Height of the widget */ - short h; + short h; /** Padding */ - Padding def_margin; - Padding def_padding; - Padding def_border; - Padding def_border_radius; - Padding margin; - Padding padding; - Padding border; - Padding border_radius; + Padding def_margin; + Padding def_padding; + Padding def_border; + Padding def_border_radius; + Padding margin; + Padding padding; + Padding border; + Padding border_radius; /** enabled or not */ - gboolean enabled; + gboolean enabled; /** Expand the widget when packed */ - gboolean expand; + gboolean expand; /*** The packing index */ - int index; + int index; /** Place widget at end of parent */ - gboolean end; + gboolean end; /** Parent widget */ - struct _widget *parent; + struct _widget *parent; /** Internal */ - gboolean need_redraw; + gboolean need_redraw; /** get width of widget implementation function */ - int ( *get_width )( struct _widget * ); + int ( *get_width )( struct _widget * ); /** get height of widget implementation function */ - int ( *get_height )( struct _widget * ); + int ( *get_height )( struct _widget * ); /** draw widget implementation function */ - void ( *draw )( struct _widget *widget, cairo_t *draw ); + void ( *draw )( struct _widget *widget, cairo_t *draw ); /** resize widget implementation function */ - void ( *resize )( struct _widget *, short, short ); + void ( *resize )( struct _widget *, short, short ); /** update widget implementation function */ - void ( *update )( struct _widget * ); + void ( *update )( struct _widget * ); /** Handle mouse motion, used for dragging */ - gboolean ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * ); + gboolean ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * ); - int ( *get_desired_height )( struct _widget * ); + int ( *get_desired_height )( struct _widget * ); - /** widget clicked callback */ - widget_clicked_cb clicked; - /** user data for clicked callback */ - void *clicked_cb_data; + /** widget find_mouse_target callback */ + widget_find_mouse_target_cb find_mouse_target; + /** widget trigger_action callback */ + widget_trigger_action_cb trigger_action; + /** user data for find_mouse_target and trigger_action callback */ + void *trigger_action_cb_data; /** Free widget callback */ - void ( *free )( struct _widget *widget ); + void ( *free )( struct _widget *widget ); /** Name of widget (used for theming) */ - char *name; - const char *state; + char *name; + const char *state; }; /** @@ -100,7 +104,7 @@ struct _widget * Initializes the widget structure. * */ -void widget_init ( widget *widget, const char *name ); +void widget_init ( widget *widget, WidgetType type, const char *name ); /** * @param widget The widget handle. diff --git a/include/widgets/widget.h b/include/widgets/widget.h index 990e50b4..dd3ea162 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -31,6 +31,7 @@ #include <cairo.h> #include <xcb/xcb.h> #include <xcb/xproto.h> +#include "keyb.h" /** * @defgroup widget widget * @@ -48,11 +49,18 @@ * Structure is elaborated in widget-internal.h */ typedef struct _widget widget; - -/** - * Callback for when widget is clicked. - */ -typedef gboolean ( *widget_clicked_cb )( widget *, xcb_button_press_event_t *, void * ); +typedef enum +{ + WIDGET_TYPE_UNKNOWN, + WIDGET_TYPE_LISTVIEW = SCOPE_MOUSE_LISTVIEW, + WIDGET_TYPE_LISTVIEW_ELEMENT = SCOPE_MOUSE_LISTVIEW_ELEMENT, + WIDGET_TYPE_EDITBOX = SCOPE_MOUSE_EDITBOX, + WIDGET_TYPE_SCROLLBAR = SCOPE_MOUSE_SCROLLBAR, + WIDGET_TYPE_SIDEBAR_MODI = SCOPE_MOUSE_SIDEBAR_MODI, +} WidgetType; + +typedef widget * ( *widget_find_mouse_target_cb )( widget *, WidgetType type, gint *x, gint *y ); +typedef gboolean ( *widget_trigger_action_cb )( widget *, guint action, gint x, gint y, void * ); /** Macro to get widget from an implementation (e.g. textbox/scrollbar) */ #define WIDGET( a ) ( (widget *) ( a ) ) @@ -80,6 +88,14 @@ void widget_move ( widget *widget, short x, short y ); /** * @param widget Handle to widget * + * Get the type of the widget. + * @returns The type of the widget. + */ +WidgetType widget_type ( widget *widget ); + +/** + * @param widget Handle to widget + * * Check if widget is enabled. * @returns TRUE when widget is enabled. */ @@ -172,24 +188,35 @@ gboolean widget_need_redraw ( widget *wid ); /** * @param wid The widget handle - * @param xbe The button press event + * @param x A pointer to the x coordinate of the mouse event + * @param y A pointer to the y coordinate of the mouse event + * + * Get the widget that should handle a mouse event. + * @x and @y are adjusted to be relative to the widget. * - * Signal the widget that it has been clicked, - * The click should have happened within the region of the widget, check with - * ::widget_intersect. + * @returns returns the widget that should handle the mouse event. + */ +widget *widget_find_mouse_target ( widget *wid, WidgetType type, gint *x, gint *y ); + +/** + * @param wid The widget handle + * @param action The action to trigger + * @param x A pointer to the x coordinate of the click + * @param y A pointer to the y coordinate of the click * - * @returns returns TRUE if click is handled. + * Trigger an action on widget. + * @x and @y are relative to the widget. */ -gboolean widget_clicked ( widget *wid, xcb_button_press_event_t *xbe ); +gboolean widget_trigger_action ( widget *wid, guint action, gint x, gint y ); /** * @param wid The widget handle - * @param cb The widget click callback + * @param cb The widget trigger action callback * @param udata the user data to pass to callback * - * Override the widget clicked handler on widget. + * Override the widget trigger action handler on widget. */ -void widget_set_clicked_handler ( widget *wid, widget_clicked_cb cb, void *udata ); +void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb cb, void *udata ); /** * @param wid The widget handle diff --git a/include/x11-helper.h b/include/x11-helper.h index 68ebde32..01b061e6 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -171,38 +171,12 @@ int take_keyboard ( xcb_window_t w, int iters ); int take_pointer ( xcb_window_t w, int iters ); /** - * @param mask The mask to canonilize - * - * @return The canonilized mask - */ -unsigned int x11_canonalize_mask ( unsigned int mask ); - -/** - * @param xkb the xkb structure. - * - * Calculates the mask of all active modifier keys. - * - * @returns the mask describing all active modifier keys. - */ -unsigned int x11_get_current_mask ( xkb_stuff *xkb ); - -/** - * @param combo String representing the key combo - * @param mod [out] The modifier specified (or AnyModifier if not specified) - * @param key [out] The key specified - * @param release [out] If it should react on key-release, not key-press - * - * Parse key from user input string. - */ -gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release, GString * ); - -/** * Setup several items required. * * Error handling, * * Numlock detection * * Cache */ -void x11_setup ( xkb_stuff *xkb ); +void x11_setup ( void ); /** * Depth of visual @@ -250,16 +224,6 @@ void x11_build_monitor_layout ( void ); void x11_dump_monitor_layout ( void ); /** - * @param mask the mask to check for key - * @param key the key to check in mask - * - * Check if key is in the modifier mask. - * - * @returns TRUE if key is in the modifier mask - */ -int x11_modifier_active ( unsigned int mask, int key ); - -/** * @param window The X11 window to modify * * Set the right hints to disable the window decoration. diff --git a/include/xkb-internal.h b/include/xkb-internal.h index 0425baf0..2cbef99f 100644 --- a/include/xkb-internal.h +++ b/include/xkb-internal.h @@ -28,31 +28,18 @@ #ifndef ROFI_XKB_INTERNAL_H #define ROFI_XKB_INTERNAL_H +#include "nkutils-bindings.h" #include <xkbcommon/xkbcommon.h> -#include <xkbcommon/xkbcommon-compose.h> struct xkb_stuff { /** connection to the X server*/ - xcb_connection_t *xcb_connection; - /** Keyboard context */ - struct xkb_context *context; + xcb_connection_t *xcb_connection; /** Flag indicating first event */ - uint8_t first_event; + uint8_t first_event; /** Keyboard device id */ - int32_t device_id; - /** Current keymap */ - struct xkb_keymap *keymap; - /** Keyboard state */ - struct xkb_state *state; - /** Compose information */ - struct - { - /** Compose table */ - struct xkb_compose_table *table; - /** Compose state */ - struct xkb_compose_state * state; - } compose; + int32_t device_id; + NkBindings *bindings; }; #endif |