diff options
42 files changed, 2837 insertions, 2158 deletions
diff --git a/Makefile.am b/Makefile.am index 467b6ebb..dd1ff99f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,6 @@ ACLOCAL_AMFLAGS = -I libgwater ${ACLOCAL_FLAGS} AM_YFLAGS = -d noinst_LIBRARIES = -include $(top_srcdir)/libgwater-xcb-nolibtool.mk ## # PKG CONFIG file @@ -59,17 +58,16 @@ SOURCES=\ source/widgets/listview.c\ source/widgets/scrollbar.c\ source/xrmoptions.c\ + source/xkb.c\ source/x11-helper.c\ source/dialogs/run.c\ source/dialogs/ssh.c\ source/dialogs/drun.c\ source/dialogs/dmenu.c\ source/dialogs/combi.c\ - source/dialogs/window.c\ source/dialogs/script.c\ source/dialogs/help-keys.c\ - include/xcb.h\ - include/xcb-internal.h\ + include/display.h\ include/rofi.h\ include/mode.h\ include/mode-private.h\ @@ -92,17 +90,38 @@ SOURCES=\ include/widgets/scrollbar.h\ include/xrmoptions.h\ include/x11-helper.h\ + include/dialogs/window.h\ include/dialogs/ssh.h\ include/dialogs/run.h\ include/dialogs/drun.h\ include/dialogs/dmenu.h\ include/dialogs/combi.h\ include/dialogs/script.h\ - include/dialogs/window.h\ include/dialogs/dialogs.h\ include/dialogs/help-keys.h\ - include/xkb.h\ - include/xkb-internal.h + include/xkb-internal.h\ + include/xkb.h + +if WAYLAND_BACKEND +SOURCES += source/wayland.c include/wayland.h +nodist_rofi_SOURCES += source/unstable/launcher-menu/launcher-menu-unstable-v1-protocol.c +include $(top_srcdir)/libgwater-wayland-nolibtool.mk +if WINDOW_MODE +SOURCES += source/dialogs/window-wayland.c +nodist_rofi_SOURCES += source/unstable/window-switcher/window-switcher-unstable-v1-protocol.c +endif + +rofi source/rofi-wayland.o: include/unstable/launcher-menu/launcher-menu-unstable-v1-client-protocol.h +rofi source/rofi-wayland.o source/dialogs/rofi-window-wayland.o: include/unstable/window-switcher/window-switcher-unstable-v1-client-protocol.h +endif + +if XCB_BACKEND +SOURCES += source/xcb.c include/xcb.h +include $(top_srcdir)/libgwater-xcb-nolibtool.mk +if WINDOW_MODE +SOURCES += source/dialogs/window-xcb.c +endif +endif rofi_SOURCES=\ lexer/theme-parser.y\ @@ -112,12 +131,14 @@ rofi_SOURCES=\ rofi_CFLAGS=\ $(AM_CFLAGS)\ $(glib_CFLAGS)\ + $(GW_WAYLAND_CFLAGS)\ $(GW_XCB_CFLAGS)\ + $(xrm_CFLAGS)\ $(pango_CFLAGS)\ - $(libsn_CFLAGS)\ $(cairo_CFLAGS)\ -DMANPAGE_PATH="\"$(mandir)/\""\ -I$(top_srcdir)/include/\ + -I$(top_builddir)/include/\ -I$(top_srcdir)/config/\ -I$(top_builddir)/\ -Werror=missing-prototypes\ @@ -127,8 +148,9 @@ rofi_CFLAGS=\ rofi_LDADD=\ $(glib_LIBS)\ + $(GW_WAYLAND_LIBS)\ $(GW_XCB_LIBS)\ - $(libsn_LIBS)\ + $(xrm_LIBS)\ $(pango_LIBS)\ $(cairo_LIBS)\ $(LIBS) @@ -253,9 +275,8 @@ textbox_test_CFLAGS=\ $(AM_CFLAGS)\ $(glib_CFLAGS)\ $(pango_CFLAGS)\ - $(GW_XCB_CFLAGS)\ + $(GW_WAYLAND_CFLAGS)\ $(cairo_CFLAGS)\ - $(libsn_CFLAGS)\ -I$(top_srcdir)/include/\ -I$(top_srcdir)/config/\ -I$(top_builddir)/ @@ -263,9 +284,8 @@ textbox_test_CFLAGS=\ textbox_test_LDADD=\ $(glib_LIBS)\ $(pango_LIBS)\ - $(GW_XCB_LIBS)\ - $(cairo_LIBS)\ - $(libsn_LIBS) + $(GW_WAYLAND_LIBS)\ + $(cairo_LIBS) helper_pidfile_CFLAGS=$(textbox_test_CFLAGS) helper_pidfile_LDADD=$(textbox_test_LDADD) @@ -278,7 +298,7 @@ helper_pidfile_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ - source/xrmoptions.c\ + source/xrmoptions-dummy.c\ source/x11-helper.c\ include/x11-helper.h\ test/helper-pidfile.c @@ -294,7 +314,7 @@ helper_tokenize_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ - source/xrmoptions.c\ + source/xrmoptions-dummy.c\ source/x11-helper.c\ include/x11-helper.h\ test/helper-tokenize.c @@ -365,7 +385,7 @@ helper_test_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ - source/xrmoptions.c\ + source/xrmoptions-dummy.c\ source/x11-helper.c\ test/helper-test.c @@ -373,9 +393,8 @@ helper_test_CFLAGS=\ $(AM_CFLAGS)\ $(glib_CFLAGS)\ $(pango_CFLAGS)\ - $(GW_XCB_CFLAGS)\ + $(GW_WAYLAND_CFLAGS)\ $(cairo_CFLAGS)\ - $(libsn_CFLAGS)\ -I$(top_srcdir)/include/\ -I$(top_srcdir)/config/\ -I$(top_builddir)/ @@ -383,8 +402,7 @@ helper_test_CFLAGS=\ helper_test_LDADD=\ $(glib_LIBS)\ $(pango_LIBS)\ - $(GW_XCB_LIBS)\ - $(libsn_LIBS)\ + $(GW_WAYLAND_LIBS)\ $(cairo_LIBS) helper_expand_SOURCES=\ @@ -396,7 +414,7 @@ helper_expand_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ - source/xrmoptions.c\ + source/xrmoptions-dummy.c\ source/x11-helper.c\ test/helper-expand.c @@ -416,7 +434,7 @@ helper_config_cmdline_parser_SOURCES=\ include/helper.h\ include/helper-theme.h\ include/xrmoptions.h\ - source/xrmoptions.c\ + source/xrmoptions-dummy.c\ source/x11-helper.c\ test/helper-config-cmdline-parser.c @@ -524,3 +542,22 @@ coverage-clean: .PHONY: .FORCE .FORCE: + +# Wayland protocol code generation rules +source/%-protocol.c: $(wpprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) code < $< > $@ + +include/%-server-protocol.h: $(wpprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) server-header < $< > $@ + +include/%-client-protocol.h: $(wpprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) client-header < $< > $@ + +source/%-protocol.c: $(wwprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) code < $< > $@ + +include/%-server-protocol.h: $(wwprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) server-header < $< > $@ + +include/%-client-protocol.h: $(wwprotocoldir)/%.xml + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) client-header < $< > $@ diff --git a/config/config.c b/config/config.c index 813f88af..9f10d21c 100644 --- a/config/config.c +++ b/config/config.c @@ -56,22 +56,6 @@ Settings config = { .run_shell_command = "{terminal} -e {cmd}", /** Command executed on accep-entry-custom for window modus */ .window_command = "xkill -id {window}", - /** - * Location of the window. - * Enumeration indicating location or gravity of window. - * - * WL_NORTH_WEST WL_NORTH WL_NORTH_EAST - * - * WL_EAST WL_CENTER WL_EAST - * - * WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST - * - */ - .location = WL_CENTER, - /** Y offset */ - .y_offset = 0, - /** X offset */ - .x_offset = 0, /** Always show config.menu_lines lines, even if less lines are available */ .fixed_num_lines = TRUE, /** Do not use history */ @@ -99,12 +83,9 @@ Settings config = { .tokenize = TRUE, .matching = "normal", .matching_method = MM_NORMAL, - /** Monitor */ - .monitor = "-5", /** Set filter */ .filter = NULL, .fullscreen = FALSE, - .dpi = -1, .threads = 0, .scroll_method = 0, .window_format = "{w} {c} {t}", diff --git a/configure.ac b/configure.ac index 1b027d2e..ce668dd6 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ dnl --------------------------------------------------------------------- dnl Setup automake to be silent and in foreign mode. dnl We want xz distribution dnl --------------------------------------------------------------------- -AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects dist-xz]) +AM_INIT_AUTOMAKE([-Wall -Wno-portability -Werror foreign subdir-objects dist-xz]) AM_SILENT_RULES([yes]) dnl --------------------------------------------------------------------- @@ -71,12 +71,6 @@ AC_ARG_ENABLE([drun], AS_HELP_STRING([--disable-drun],[Disable desktop file run AS_IF([test "x${enable_drun}" != "xno"], [AC_DEFINE([ENABLE_DRUN], [1], [Enable desktop file run dialog])]) dnl --------------------------------------------------------------------- -dnl Disable window mode -dnl --------------------------------------------------------------------- -AC_ARG_ENABLE([windowmode], AS_HELP_STRING([--disable-windowmode],[Disable window mode])) -AS_IF([ test "x$enable_windowmode" != "xno"], [AC_DEFINE([WINDOW_MODE],[1],[Enable the window mode])]) - -dnl --------------------------------------------------------------------- dnl Output timing information dnl --------------------------------------------------------------------- AC_ARG_ENABLE([timings], AS_HELP_STRING([--enable-timings],[Enable timing output])) @@ -85,6 +79,7 @@ AS_IF( [ test "x$enable_timings" = "xyes"], [AC_DEFINE([TIMINGS],[1], [Enable ti dnl --------------------------------------------------------------------- dnl Check for C functions. dnl --------------------------------------------------------------------- +AC_FUNC_MMAP AC_CHECK_FUNC([getline],, AC_MSG_ERROR("Could not find getline in c library")) AC_CHECK_FUNC([open],, AC_MSG_ERROR("Could not find open in c library")) AC_CHECK_FUNC([sysconf],, AC_MSG_ERROR("Could not find sysconf")) @@ -105,16 +100,47 @@ dnl Check dependencies dnl --------------------------------------------------------------------- PKG_PROG_PKG_CONFIG +AC_ARG_VAR([WAYLAND_SCANNER], [Wayland XML scanner executable]) +AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner]) +if test -z "${WAYLAND_SCANNER}"; then + AC_MSG_ERROR([wayland-scanner not found]) +fi + dnl --------------------------------------------------------------------- dnl PKG_CONFIG based dependencies dnl --------------------------------------------------------------------- PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0]) -GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama]) PKG_CHECK_MODULES([pango], [pango pangocairo]) -PKG_CHECK_MODULES([cairo], [cairo cairo-xcb]) -PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ]) - +PKG_CHECK_MODULES([cairo], [cairo]) + +PKG_CHECK_MODULES([xrm], [xcb-xrm]) + +dnl --------------------------------------------------------------------- +dnl Display backend and window mode +dnl --------------------------------------------------------------------- +AC_ARG_WITH([display-backend], AS_HELP_STRING([--with-display-backend=@<:@wayland|xcb@:>@], [The display backend to use, Wayland or XCB]), [], [with_display_backend=yes]) +AS_CASE([${with_display_backend}], + [xcb], [ + GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama cairo-xcb]) + enable_windowmode_default=yes + ] ,[ + GW_CHECK_WAYLAND([wayland-cursor wayland-wall xkbcommon >= 0.5.0]) + PKG_CHECK_MODULES([WAYLAND_PROTOCLS], [wayland-protocols]) + PKG_CHECK_MODULES([WAYLAND_WALL], [wayland-wall]) + wpprotocoldir=`${PKG_CONFIG} --variable=pkgdatadir wayland-protocols` + wwprotocoldir=`${PKG_CONFIG} --variable=pkgdatadir wayland-wall` + AC_SUBST([wpprotocoldir]) + AC_SUBST([wwprotocoldir]) + with_display_backend=wayland + enable_windowmode_default=yes +]) +AM_CONDITIONAL([WAYLAND_BACKEND], [test x${with_display_backend} = xwayland]) +AM_CONDITIONAL([XCB_BACKEND], [test x${with_display_backend} = xxcb]) + +AC_ARG_ENABLE([windowmode], AS_HELP_STRING([--disable-windowmode],[Disable window mode]), [], [enable_windowmode=${enable_windowmode_default}]) +AM_CONDITIONAL([WINDOW_MODE], [test x${enable_windowmode} = xyes]) +AS_IF([ test "x$enable_windowmode" = "xyes"], [AC_DEFINE([WINDOW_MODE],[1],[Enable the window mode])]) dnl --------------------------------------------------------------------- dnl Add extra compiler flags diff --git a/include/display.h b/include/display.h new file mode 100644 index 00000000..7b73b8cf --- /dev/null +++ b/include/display.h @@ -0,0 +1,20 @@ +#ifndef ROFI_DISPLAY_H +#define ROFI_DISPLAY_H + +#include <glib.h> +#include <cairo.h> +#include <xkbcommon/xkbcommon.h> +#include "widgets/widget.h" + +typedef struct _display_buffer_pool display_buffer_pool; + +gboolean display_init(GMainLoop *main_loop, const gchar *display); +void display_cleanup(void); + +display_buffer_pool *display_buffer_pool_new(gint width, gint height); +void display_buffer_pool_free(display_buffer_pool *pool); + +cairo_surface_t *display_buffer_pool_get_next_buffer(display_buffer_pool *pool); +void display_surface_commit(cairo_surface_t *surface); + +#endif diff --git a/include/keyb.h b/include/keyb.h index 9da1996b..0e7ee403 100644 --- a/include/keyb.h +++ b/include/keyb.h @@ -1,6 +1,8 @@ #ifndef ROFI_KEYB_H #define ROFI_KEYB_H +#include "display.h" + /** * @defgroup KEYB KeyboardBindings * @@ -116,9 +118,13 @@ 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 ); +KeyBindingAction abe_find_action ( widget_modifier_mask modmask, xkb_keysym_t key ); /** + * Reset state of all on-release bindings + */ +void abe_reset_release ( void ); +/** * Trigger keybinding on key release. */ void abe_trigger_release ( void ); diff --git a/include/rofi.h b/include/rofi.h index ee2d4ccd..2dd330b4 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -1,6 +1,5 @@ #ifndef ROFI_MAIN_H #define ROFI_MAIN_H -#include <xcb/xcb.h> #include <xkbcommon/xkbcommon.h> #include <glib.h> #include <string.h> @@ -49,6 +48,7 @@ void rofi_add_error_message ( GString *str ); * This function sets the code that rofi will return on exit. */ void rofi_set_return_code ( int code ); +void rofi_quit_main_loop(void); /** * @param name Search for mode with this name. diff --git a/include/settings.h b/include/settings.h index e14ee48d..0c41998c 100644 --- a/include/settings.h +++ b/include/settings.h @@ -79,12 +79,6 @@ typedef struct /** Command for window */ char * window_command; - /** Windows location/gravity */ - WindowLocation location; - /** Y offset */ - int y_offset; - /** X offset */ - int x_offset; /** Always should config.menu_lines lines, even if less lines are available */ unsigned int fixed_num_lines; /** Do not use history */ @@ -114,14 +108,10 @@ typedef struct char *matching; MatchingMethod matching_method; unsigned int tokenize; - /** Monitors */ - char *monitor; /** filter */ char *filter; /** fullscreen */ unsigned int fullscreen; - /** dpi */ - int dpi; /** Number threads (1 to disable) */ unsigned int threads; unsigned int scroll_method; diff --git a/include/view-internal.h b/include/view-internal.h index 10b42260..47b859b6 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -58,7 +58,7 @@ struct RofiViewState /** Previously called key action. */ KeyBindingAction prev_action; /** Time previous key action was executed. */ - xcb_timestamp_t last_button_press; + int32_t last_button_press; /** Indicate view should terminate */ int quit; @@ -68,8 +68,6 @@ struct RofiViewState unsigned int selected_line; /** The return state of the view */ MenuReturn retv; - /** Monitor #workarea the view is displayed on */ - workarea mon; /** #box holding the different modi buttons */ box *sidebar_bar; @@ -90,10 +88,9 @@ struct RofiViewState int width; /** Height of the view */ int height; - /** X position of the view */ - int x; - /** Y position of the view */ - int y; + /** Buffer pool */ + display_buffer_pool *pool; + gboolean frame_callback; /** Regexs used for matching */ GRegex **tokens; diff --git a/include/view.h b/include/view.h index ca3a5721..ecb31ea7 100644 --- a/include/view.h +++ b/include/view.h @@ -1,7 +1,8 @@ #ifndef ROFI_VIEW_H #define ROFI_VIEW_H #include "mode.h" -#include "xkb.h" +#include "keyb.h" +#include "display.h" /** * @defgroup View View @@ -21,7 +22,7 @@ typedef enum /** Create a menu for entering passwords */ MENU_PASSWORD = 1, /** Create amanaged window. */ - MENU_NORMAL_WINDOW = 2, + _DEPRECATED_MENU_NORMAL_WINDOW = 2, /** ERROR dialog */ MENU_ERROR_DIALOG = 4, /** INDICATOR */ @@ -72,7 +73,7 @@ unsigned int rofi_view_get_next_position ( const RofiViewState *state ); * * Process an Xevent. */ -void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb ); +//FIXME: void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb ); /** * @param state the Menu handle * @@ -109,6 +110,7 @@ unsigned int rofi_view_get_selected_line ( const RofiViewState *state ); * Resets RofiViewState::quit and RofiViewState::retv. */ void rofi_view_restart ( RofiViewState *state ); +void rofi_view_quit ( RofiViewState *state ); /** * @param state The handle to the view @@ -159,6 +161,23 @@ void rofi_view_set_active ( RofiViewState *state ); int rofi_view_error_dialog ( const char *msg, int markup ); /** + * Inform rofi that the last frame properly hit the screen + * and it can repaint a new one if needed + */ +void rofi_view_frame_callback( void ); +void rofi_view_handle_keypress ( widget_modifier_mask modmask, xkb_keysym_t key, char *text, int len ); +typedef enum { + ROFI_MOUSE_WHEEL_UP, + ROFI_MOUSE_WHEEL_DOWN, + ROFI_MOUSE_WHEEL_LEFT, + ROFI_MOUSE_WHEEL_RIGHT, +} rofi_mouse_wheel_direction; +void rofi_view_mouse_navigation ( rofi_mouse_wheel_direction direction ); +void rofi_view_handle_mouse_button ( widget_button_event *be ); +void rofi_view_handle_mouse_motion ( widget_motion_event *me ); +void rofi_view_set_size ( RofiViewState * state, gint width, gint height ); +void rofi_view_maybe_update ( void ); +/** * Queue a redraw. * This triggers a X11 Expose Event. */ @@ -221,12 +240,6 @@ void rofi_view_clear_input ( RofiViewState *state ); * TODO: Internal call to view exposed. */ void __create_window ( MenuFlags menu_flags ); -/** - * Get the handle of the main window. - * - * @returns the xcb_window_t for rofi's view or XCB_WINDOW_NONE. - */ -xcb_window_t rofi_view_get_window ( void ); /** @} */ /*** diff --git a/include/wayland.h b/include/wayland.h new file mode 100644 index 00000000..d7c7397d --- /dev/null +++ b/include/wayland.h @@ -0,0 +1,80 @@ +#ifndef ROFI_XCB_H +#define ROFI_XCB_H + +#include <glib.h> +#include <cairo.h> +#include <xkbcommon/xkbcommon.h> +#include <wayland-client.h> +#include <libgwater-wayland.h> + +#include "unstable/window-switcher/window-switcher-unstable-v1-client-protocol.h" +#include "xkb.h" + +typedef enum { + WAYLAND_GLOBAL_COMPOSITOR, + WAYLAND_GLOBAL_LAUNCHER_MENU, + WAYLAND_GLOBAL_WINDOW_SWITCHER, + WAYLAND_GLOBAL_SHM, + _WAYLAND_GLOBAL_SIZE, +} wayland_global_name; + +typedef struct _wayland_seat wayland_seat; + +typedef struct { + GMainLoop *main_loop; + GWaterWaylandSource *main_loop_source; + struct wl_display *display; + struct wl_registry *registry; + uint32_t global_names[_WAYLAND_GLOBAL_SIZE]; + struct wl_compositor *compositor; + struct zww_launcher_menu_v1 *launcher_menu; + struct zww_window_switcher_v1 *window_switcher; + struct wl_shm *shm; + size_t buffer_count; + struct { + char *theme_name; + char **name; + struct wl_cursor_theme *theme; + struct wl_cursor *cursor; + struct wl_cursor_image *image; + struct wl_surface *surface; + struct wl_callback *frame_cb; + } cursor; + GHashTable *seats; + GHashTable *seats_by_name; + wayland_seat *last_seat; + GHashTable *outputs; + struct wl_surface *surface; + struct wl_callback *frame_cb; + size_t scales[3]; + int32_t scale; +} wayland_stuff; + +struct _wayland_seat { + wayland_stuff *context; + uint32_t global_name; + struct wl_seat *seat; + gchar *name; + uint32_t serial; + struct wl_keyboard *keyboard; + xkb_stuff xkb; + struct wl_pointer *pointer; + widget_button_event button; + widget_motion_event motion; + struct { + gint vertical; + gint horizontal; + } wheel; +}; + +/* Supported interface versions */ +#define WL_COMPOSITOR_INTERFACE_VERSION 3 +#define WW_LAUNCHER_MENU_INTERFACE_VERSION 1 +#define WW_WINDOW_SWITCHER_INTERFACE_VERSION 1 +#define WL_SHM_INTERFACE_VERSION 1 +#define WL_SEAT_INTERFACE_VERSION 5 +#define WL_OUTPUT_INTERFACE_VERSION 2 + +extern wayland_stuff *wayland; + +#endif diff --git a/include/widgets/listview.h b/include/widgets/listview.h index 773b29c9..c193d7d2 100644 --- a/include/widgets/listview.h +++ b/include/widgets/listview.h @@ -39,7 +39,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 *, widget_button_event *, void * ); /** * @param name The name of the to be created widget. diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h index 4e9826ed..6347a660 100644 --- a/include/widgets/widget-internal.h +++ b/include/widgets/widget-internal.h @@ -49,7 +49,7 @@ 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 *, widget_motion_event * ); int ( *get_desired_height )( struct _widget * ); diff --git a/include/widgets/widget.h b/include/widgets/widget.h index 955d939e..57f38ac8 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -2,8 +2,6 @@ #define ROFI_WIDGET_H #include <glib.h> #include <cairo.h> -#include <xcb/xcb.h> -#include <xcb/xproto.h> /** * @defgroup widget widget * @@ -22,10 +20,57 @@ */ typedef struct _widget widget; +typedef enum +{ + /** Shift key */ + WIDGET_MOD_SHIFT, + /** Control Key */ + WIDGET_MOD_CONTROL, + /** Alt key */ + WIDGET_MOD_ALT, + /** Meta key */ + WIDGET_MOD_META, + /** Super (window) key */ + WIDGET_MOD_SUPER, + /** Hyper key */ + WIDGET_MOD_HYPER, + /** Number of modifier keys */ +#define NUM_WIDGET_MOD (WIDGET_MOD_HYPER+1) +} widget_modifier; + +typedef enum { + WIDGET_MODMASK_SHIFT = (1 << WIDGET_MOD_SHIFT), + WIDGET_MODMASK_CONTROL = (1 << WIDGET_MOD_CONTROL), + WIDGET_MODMASK_ALT = (1 << WIDGET_MOD_ALT), + WIDGET_MODMASK_META = (1 << WIDGET_MOD_META), + WIDGET_MODMASK_SUPER = (1 << WIDGET_MOD_SUPER), + WIDGET_MODMASK_HYPER = (1 << WIDGET_MOD_HYPER), + WIDGET_MODMASK_ALL = (WIDGET_MODMASK_SHIFT | WIDGET_MODMASK_CONTROL | WIDGET_MODMASK_ALT | WIDGET_MODMASK_META | WIDGET_MODMASK_SUPER | WIDGET_MODMASK_HYPER) +} widget_modifier_mask; + +type |