Make xcb and wayland implementations coexist

This commit is contained in:
lbonn 2020-06-02 21:29:28 +02:00
parent c4bd599aec
commit 98a9635173
15 changed files with 604 additions and 149 deletions

View file

@ -36,7 +36,13 @@ Settings config = {
/** List of enabled modi. */
/** -modi */
#ifdef WINDOW_MODE
#ifdef ENABLE_WAYLAND
// change the default if we build with wayland support
// window mode will still be available if running on X11
.modi = "run,ssh",
#else
.modi = "window,run,ssh",
#endif
#else
.modi = "run,ssh",
#endif

View file

@ -56,6 +56,28 @@ typedef struct _workarea
struct _workarea *next;
} workarea;
struct _view_proxy;
typedef struct _display_proxy {
gboolean (*setup) ( GMainLoop *main_loop, NkBindings *bindings );
gboolean (*late_setup) ( void );
void (*early_cleanup) ( void );
void (*cleanup) ( void );
void (*dump_monitor_layout) ( void );
void (*startup_notification) ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data );
int (*monitor_active) ( workarea *mon );
const struct _view_proxy* (*view) ( void );
} display_proxy;
/* Implementations */
extern display_proxy * const xcb_proxy;
#ifdef ENABLE_WAYLAND
extern display_proxy * const wayland_proxy;
#endif
void display_init( const display_proxy *disp_in );
/**
* @param mon workarea to be filled in.
*
@ -106,4 +128,5 @@ void display_dump_monitor_layout ( void );
*/
void display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data );
#endif

View file

@ -52,6 +52,12 @@ typedef enum
SORT_FZF = 1
} SortingMethod;
typedef enum
{
DISPLAY_XCB,
DISPLAY_WAYLAND,
} DisplayBackend;
/**
* Settings structure holding all (static) configurable options.
* @ingroup CONFIGURATION
@ -99,6 +105,9 @@ typedef struct
/** Theme for icons */
char * icon_theme;
/** Backend */
DisplayBackend backend;
/** Windows location/gravity */
WindowLocation location;
/** Padding between elements */

View file

@ -150,4 +150,5 @@ struct RofiViewState
rofi_int_matcher **tokens;
};
/** @} */
#endif

View file

@ -302,11 +302,6 @@ void rofi_view_get_current_monitor ( int *width, int *height );
* Takes a screenshot.
*/
void rofi_capture_screenshot ( void );
/**
* Set the window title.
*/
void rofi_view_set_window_title ( const char * title );
/**
* set ellipsize mode to start.
@ -318,4 +313,56 @@ void rofi_view_set_size ( RofiViewState * state, gint width, gint height );
void rofi_view_get_size ( RofiViewState * state, gint *width, gint *height );
typedef struct _view_proxy {
RofiViewState* (*create) ( Mode *sw, const char *input, MenuFlags menu_flags, void ( *finalize )( RofiViewState * ) );
void (*finalize) ( RofiViewState *state );
MenuReturn (*get_return_value) ( const RofiViewState *state );
unsigned int (*get_next_position) ( const RofiViewState *state );
void (*handle_text) ( RofiViewState *state, char *text );
void (*handle_mouse_motion) ( RofiViewState *state, gint x, gint y );
void (*maybe_update) ( RofiViewState *state );
void (*temp_configure_notify) ( RofiViewState *state, xcb_configure_notify_event_t *xce );
void (*temp_click_to_exit) ( RofiViewState *state, xcb_window_t target );
void (*frame_callback) ( void );
unsigned int (*get_completed) ( const RofiViewState *state );
const char * (*get_user_input) ( const RofiViewState *state );
void (*set_selected_line) ( RofiViewState *state, unsigned int selected_line );
unsigned int (*get_selected_line) ( const RofiViewState *state );
void (*restart) ( RofiViewState *state );
gboolean (*trigger_action) ( RofiViewState *state, BindingsScope scope, guint action );
void (*free) ( RofiViewState *state );
RofiViewState * (*get_active) ( void );
void (*set_active) ( RofiViewState *state );
int (*error_dialog) ( const char *msg, int markup );
void (*queue_redraw) ( void );
void (*cleanup) ( void );
Mode * (*get_mode) ( RofiViewState *state );
void (*hide) ( void );
void (*reload) ( void );
void (*switch_mode) ( RofiViewState *state, Mode *mode );
void (*set_overlay) ( RofiViewState *state, const char *text );
void (*clear_input) ( RofiViewState *state );
void (*__create_window) ( MenuFlags menu_flags );
xcb_window_t (*get_window) ( void );
void (*workers_initialize) ( void );
void (*workers_finalize) ( void );
void (*get_current_monitor) ( int *width, int *height );
void (*capture_screenshot) ( void );
void (*ellipsize_start) ( RofiViewState *state );
void (*set_size) ( RofiViewState * state, gint width, gint height );
void (*get_size) ( RofiViewState * state, gint *width, gint *height );
} view_proxy;
/* Implementations */
extern const view_proxy *xcb_view_proxy;
#ifdef ENABLE_WAYLAND
extern const view_proxy *wayland_view_proxy;
#endif
void view_init( const view_proxy *view_in );
#endif

View file

@ -31,6 +31,8 @@
#include <glib.h>
#include <cairo.h>
#include "display.h"
typedef struct _display_buffer_pool display_buffer_pool;
display_buffer_pool *display_buffer_pool_new(gint width, gint height);
void display_buffer_pool_free(display_buffer_pool *pool);
@ -41,5 +43,4 @@ void display_surface_commit(cairo_surface_t *surface);
gboolean display_get_surface_dimensions ( int *width, int *height );
void display_set_surface_dimensions ( int width, int height, int loc );
#endif

View file

@ -95,7 +95,7 @@ header_conf.set('GLIB_VERSION_MIN_REQUIRED', '(G_ENCODE_VERSION(@0@,@1@))'.forma
header_conf.set('GLIB_VERSION_MAX_ALLOWED', '(G_ENCODE_VERSION(@0@,@1@))'.format(glib_min_major, glib_min_minor))
header_conf.set('ENABLE_DRUN', get_option('drun'))
#header_conf.set('WINDOW_MODE', get_option('window'))
header_conf.set('WINDOW_MODE', get_option('window'))
header_conf.set('ENABLE_WAYLAND', wayland_client.found())
@ -150,14 +150,14 @@ rofi_sources = files(
'source/mode.c',
'source/keyb.c',
'config/config.c',
'source/display.c',
'source/helper.c',
'source/timings.c',
'source/history.c',
'source/theme.c',
'source/rofi-icon-fetcher.c',
'source/css-colors.c',
'source/wayland/view.c',
'source/wayland/display.c',
'source/view.c',
'source/widgets/box.c',
'source/widgets/icon.c',
'source/widgets/container.c',
@ -172,11 +172,11 @@ rofi_sources = files(
'source/dialogs/drun.c',
'source/dialogs/dmenu.c',
'source/dialogs/combi.c',
#'source/dialogs/window.c',
'source/dialogs/window.c',
'source/dialogs/script.c',
'source/dialogs/help-keys.c',
#'source/xcb/display.c',
#'source/xcb/view.c',
'source/xcb/display.c',
'source/xcb/view.c',
'include/display.h',
'include/xcb.h',
'include/xcb-internal.h',
@ -195,7 +195,6 @@ rofi_sources = files(
'include/theme.h',
'include/rofi-types.h',
'include/css-colors.h',
'include/wayland-internal.h',
'include/widgets/box.h',
'include/widgets/icon.h',
'include/widgets/container.h',
@ -248,6 +247,11 @@ if get_option('wayland').enabled()
rofi_sources += proto_srcs
rofi_sources += proto_headers
rofi_sources += files(
'source/wayland/view.c',
'source/wayland/display.c',
'include/wayland-internal.h',
)
endif

58
source/display.c Normal file
View file

@ -0,0 +1,58 @@
#include <glib.h>
#include <xcb/xkb.h>
#include "keyb.h"
#include "display.h"
#include "view.h"
#include "view-internal.h"
static const display_proxy *proxy;
void display_init( const display_proxy *disp_in )
{
proxy = disp_in;
view_init( proxy->view() );
}
int
monitor_active ( workarea *mon )
{
return proxy->monitor_active( mon );
}
gboolean
display_setup ( GMainLoop *main_loop, NkBindings *bindings )
{
return proxy->setup( main_loop, bindings );
}
gboolean
display_late_setup ( void )
{
return proxy->late_setup ( );
}
void
display_early_cleanup ( void )
{
proxy->early_cleanup ( );
}
void
display_cleanup ( void )
{
proxy->cleanup ( );
}
void
display_dump_monitor_layout ( void )
{
proxy->dump_monitor_layout ( );
}
void
display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
{
proxy->startup_notification ( context, child_setup, user_data );
}

View file

@ -617,11 +617,9 @@ int config_sanity_check ( void )
}
// Check size
#if 0
// TODO
{
workarea mon;
if ( !monitor_active ( &mon ) ) {
if ( config.backend == DISPLAY_XCB && !monitor_active ( &mon ) ) {
const char *name = config.monitor;
if ( name && name[0] == '-' ) {
int index = name[1] - '0';
@ -633,7 +631,6 @@ int config_sanity_check ( void )
found_error = TRUE;
}
}
#endif
if ( config.menu_font ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );

View file

@ -306,7 +306,7 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
printf ( "Global options:\n" );
print_options ();
printf ( "\n" );
//display_dump_monitor_layout ();
display_dump_monitor_layout ();
printf ( "\n" );
printf ( "Detected modi:\n" );
print_list_of_modi ( is_term );
@ -549,8 +549,10 @@ static void rofi_collect_modi_dir ( const char *base_dir )
static void rofi_collect_modi ( void )
{
#ifdef WINDOW_MODE
rofi_collect_modi_add ( &window_mode );
rofi_collect_modi_add ( &window_mode_cd );
if ( config.backend == DISPLAY_XCB ) {
rofi_collect_modi_add ( &window_mode );
rofi_collect_modi_add ( &window_mode_cd );
}
#endif
rofi_collect_modi_add ( &run_mode );
rofi_collect_modi_add ( &ssh_mode );
@ -855,6 +857,20 @@ int main ( int argc, char *argv[] )
}
TICK_N ( "Setup Locale" );
const display_proxy *proxy = xcb_proxy;
config.backend = DISPLAY_XCB;
#ifdef ENABLE_WAYLAND
if ( find_arg ( "-x11" ) < 0 ) {
const gchar *d = g_getenv ( "WAYLAND_DISPLAY" );
if ( d != NULL && strlen(d) != 0 ) {
config.backend = DISPLAY_WAYLAND;
proxy = wayland_proxy;
}
}
#endif
TICK_N ( "Select Backend" );
rofi_collect_modi ();
TICK_N ( "Collect MODI" );
rofi_collect_modi_setup ();
@ -867,6 +883,7 @@ int main ( int argc, char *argv[] )
bindings = nk_bindings_new ( 0 );
TICK_N ( "NK Bindings" );
display_init ( proxy );
if ( !display_setup ( main_loop, bindings ) ) {
g_warning ( "Connection has error" );
cleanup ();
@ -926,7 +943,9 @@ int main ( int argc, char *argv[] )
g_free ( etc );
}
// Load in config from X resources.
// config_parse_xresource_options ( xcb );
if ( config.backend == DISPLAY_XCB ) {
config_parse_xresource_options ( xcb );
}
if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {
if ( rofi_theme_parse_file ( config_path_new ) ) {

164
source/view.c Normal file
View file

@ -0,0 +1,164 @@
#include <glib.h>
#include <xcb/xcb.h>
#include "keyb.h"
#include "display.h"
#include "view.h"
#include "view-internal.h"
static const view_proxy *proxy;
void view_init( const view_proxy *view_in )
{
proxy = view_in;
}
GThreadPool *tpool = NULL;
RofiViewState *rofi_view_create ( Mode *sw, const char *input, MenuFlags menu_flags, void ( *finalize )( RofiViewState * ) ) {
return proxy->create ( sw, input, menu_flags, finalize );
}
void rofi_view_finalize ( RofiViewState *state ) {
return proxy->finalize ( state );
}
MenuReturn rofi_view_get_return_value ( const RofiViewState *state ) {
return proxy->get_return_value ( state );
}
unsigned int rofi_view_get_next_position ( const RofiViewState *state ) {
return proxy->get_next_position ( state );
}
void rofi_view_handle_text ( RofiViewState *state, char *text ) {
proxy->handle_text ( state, text );
}
void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y ) {
proxy->handle_mouse_motion ( state, x , y );
}
void rofi_view_maybe_update ( RofiViewState *state ) {
proxy->maybe_update ( state );
}
void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce ) {
proxy->temp_configure_notify ( state, xce );
}
void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target ) {
proxy->temp_click_to_exit ( state, target );
}
void rofi_view_frame_callback ( void ) {
proxy->frame_callback ( );
}
unsigned int rofi_view_get_completed ( const RofiViewState *state ) {
return proxy->get_completed ( state );
}
const char * rofi_view_get_user_input ( const RofiViewState *state ) {
return proxy->get_user_input ( state );
}
void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line ) {
proxy->set_selected_line ( state, selected_line );
}
unsigned int rofi_view_get_selected_line ( const RofiViewState *state ) {
return proxy->get_selected_line ( state );
}
void rofi_view_restart ( RofiViewState *state ) {
proxy->restart ( state );
}
gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action ) {
return proxy->trigger_action ( state, scope, action );
}
void rofi_view_free ( RofiViewState *state ) {
return proxy->free ( state );
}
RofiViewState * rofi_view_get_active ( void ) {
return proxy->get_active ( );
}
void rofi_view_set_active ( RofiViewState *state ) {
proxy->set_active ( state );
}
int rofi_view_error_dialog ( const char *msg, int markup ) {
return proxy->error_dialog ( msg, markup );
}
void rofi_view_queue_redraw ( void ) {
proxy->queue_redraw ( );
}
void rofi_view_cleanup ( void ) {
proxy->cleanup ( );
}
Mode * rofi_view_get_mode ( RofiViewState *state ) {
return proxy->get_mode ( state );
}
void rofi_view_hide ( void ) {
proxy->hide ( );
}
void rofi_view_reload ( void ) {
proxy->reload ( );
}
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode ) {
proxy->switch_mode ( state, mode );
}
void rofi_view_set_overlay ( RofiViewState *state, const char *text ) {
proxy->set_overlay ( state, text );
}
void rofi_view_clear_input ( RofiViewState *state ) {
proxy->clear_input ( state );
}
void __create_window ( MenuFlags menu_flags ) {
proxy->__create_window ( menu_flags );
}
xcb_window_t rofi_view_get_window ( void ) {
return proxy->get_window ( );
}
void rofi_view_workers_initialize ( void ) {
proxy->workers_initialize ( );
}
void rofi_view_workers_finalize ( void ) {
proxy->workers_finalize ( );
}
void rofi_view_get_current_monitor ( int *width, int *height ) {
proxy->get_current_monitor ( width, height );
}
void rofi_capture_screenshot ( void ) {
proxy->capture_screenshot ( );
}
void rofi_view_ellipsize_start ( RofiViewState *state ) {
proxy->ellipsize_start ( state );
}
void rofi_view_set_size ( RofiViewState * state, gint width, gint height ) {
proxy->set_size ( state, width, height );
}
void rofi_view_get_size ( RofiViewState * state, gint *width, gint *height ) {
proxy->get_size ( state, width, height );
}

View file

@ -26,6 +26,7 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <config.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
@ -977,8 +978,8 @@ wayland_error(gpointer user_data)
}
gboolean
display_setup(GMainLoop *main_loop, NkBindings *bindings)
static gboolean
wayland_display_setup(GMainLoop *main_loop, NkBindings *bindings)
{
wayland->main_loop = main_loop;
@ -1035,8 +1036,8 @@ display_setup(GMainLoop *main_loop, NkBindings *bindings)
return TRUE;
}
gboolean
display_late_setup ( void )
static gboolean
wayland_display_late_setup ( void )
{
// note: ANCHOR_LEFT is needed to get the full window width
zwlr_layer_surface_v1_set_anchor( wayland->wlr_surface, ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT );
@ -1107,13 +1108,13 @@ display_set_surface_dimensions ( int width, int height, int loc )
zwlr_layer_surface_v1_set_anchor( wayland->wlr_surface, wlr_anchor );
}
void
display_early_cleanup(void)
static void
wayland_display_early_cleanup(void)
{
}
void
display_cleanup(void)
static void
wayland_display_cleanup(void)
{
if ( wayland->main_loop_source == NULL )
return;
@ -1130,12 +1131,38 @@ display_cleanup(void)
g_water_wayland_source_free ( wayland->main_loop_source );
}
int monitor_active ( workarea *mon )
static void
wayland_display_dump_monitor_layout ( void )
{
// TODO: return the "first" monitor for now
}
static void
wayland_display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
{
}
static int wayland_display_monitor_active ( workarea *mon )
{
// TODO: do something?
return FALSE;
}
void display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
static const struct _view_proxy* wayland_display_view_proxy ( void )
{
return wayland_view_proxy;
}
static display_proxy display_ = {
.setup = wayland_display_setup,
.late_setup = wayland_display_late_setup,
.early_cleanup = wayland_display_early_cleanup,
.cleanup = wayland_display_cleanup,
.dump_monitor_layout = wayland_display_dump_monitor_layout,
.startup_notification = wayland_display_startup_notification,
.monitor_active = wayland_display_monitor_active,
.view = wayland_display_view_proxy,
};
display_proxy * const wayland_proxy = &display_;

View file

@ -67,20 +67,20 @@
*
* Update the state of the view. This involves filter state.
*/
void rofi_view_update ( RofiViewState *state, gboolean qr );
static void wayland_rofi_view_update ( RofiViewState *state, gboolean qr );
static int rofi_view_calculate_height ( RofiViewState *state );
static int calculate_height ( RofiViewState *state );
/** Thread pool used for filtering */
GThreadPool *tpool = NULL;
extern GThreadPool *tpool;
/** Global pointer to the currently active RofiViewState */
RofiViewState *current_active_menu = NULL;
static RofiViewState *current_active_menu = NULL;
/**
* Structure holding cached state.
*/
struct
static struct
{
/** Main flags */
MenuFlags flags;
@ -107,7 +107,7 @@ struct
.fullscreen = FALSE,
};
void rofi_view_get_current_monitor ( int *width, int *height )
static void wayland_rofi_view_get_current_monitor ( int *width, int *height )
{
display_get_surface_dimensions( width, height );
}
@ -145,7 +145,7 @@ static int lev_sort ( const void *p1, const void *p2, void *arg )
/**
* Stores a screenshot of Rofi at that point in time.
*/
void rofi_capture_screenshot ( void )
static void wayland_rofi_view_capture_screenshot ( void )
{
}
@ -192,7 +192,7 @@ static void rofi_view_window_update_size ( RofiViewState * state )
display_set_surface_dimensions ( state->width, state->height, rofi_get_location(state) );
}
void rofi_view_set_size ( RofiViewState * state, gint width, gint height )
static void wayland_rofi_view_set_size ( RofiViewState * state, gint width, gint height )
{
if ( width > -1 )
state->width = width;
@ -201,7 +201,7 @@ void rofi_view_set_size ( RofiViewState * state, gint width, gint height )
rofi_view_window_update_size(state);
}
void rofi_view_get_size ( RofiViewState * state, gint *width, gint *height )
static void wayland_rofi_view_get_size ( RofiViewState * state, gint *width, gint *height )
{
*width = state->width;
*height = state->height;
@ -237,14 +237,14 @@ static gboolean rofi_view_reload_idle ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_REMOVE;
}
void rofi_view_reload ( void )
static void wayland_rofi_view_reload ( void )
{
// @TODO add check if current view is equal to the callee
if ( CacheState.idle_timeout == 0 ) {
CacheState.idle_timeout = g_timeout_add ( 1000 / 15, rofi_view_reload_idle, NULL );
}
}
void rofi_view_queue_redraw ( void )
static void wayland_rofi_view_queue_redraw ( void )
{
if ( current_active_menu && CacheState.repaint_source == 0 ) {
CacheState.count++;
@ -256,18 +256,18 @@ void rofi_view_queue_redraw ( void )
}
}
void rofi_view_restart ( RofiViewState *state )
static void wayland_rofi_view_restart ( RofiViewState *state )
{
state->quit = FALSE;
state->retv = MENU_CANCEL;
}
RofiViewState * rofi_view_get_active ( void )
static RofiViewState * wayland_rofi_view_get_active ( void )
{
return current_active_menu;
}
void rofi_view_set_active ( RofiViewState *state )
static void wayland_rofi_view_set_active ( RofiViewState *state )
{
if ( current_active_menu != NULL && state != NULL ) {
g_queue_push_head ( &( CacheState.views ), current_active_menu );
@ -290,7 +290,7 @@ void rofi_view_set_active ( RofiViewState *state )
rofi_view_queue_redraw ();
}
void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line )
static void wayland_rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line )
{
state->selected_line = selected_line;
// Find the line.
@ -304,7 +304,7 @@ void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_l
listview_set_selected ( state->list_view, selected );
}
void rofi_view_free ( RofiViewState *state )
static void wayland_rofi_view_free ( RofiViewState *state )
{
if ( state->tokens ) {
helper_tokenize_free ( state->tokens );
@ -324,17 +324,17 @@ void rofi_view_free ( RofiViewState *state )
g_free ( state );
}
MenuReturn rofi_view_get_return_value ( const RofiViewState *state )
static MenuReturn wayland_rofi_view_get_return_value ( const RofiViewState *state )
{
return state->retv;
}
unsigned int rofi_view_get_selected_line ( const RofiViewState *state )
static unsigned int wayland_rofi_view_get_selected_line ( const RofiViewState *state )
{
return state->selected_line;
}
unsigned int rofi_view_get_next_position ( const RofiViewState *state )
static unsigned int wayland_rofi_view_get_next_position ( const RofiViewState *state )
{
unsigned int next_pos = state->selected_line;
unsigned int selected = listview_get_selected ( state->list_view );
@ -344,12 +344,12 @@ unsigned int rofi_view_get_next_position ( const RofiViewState *state )
return next_pos;
}
unsigned int rofi_view_get_completed ( const RofiViewState *state )
static unsigned int wayland_rofi_view_get_completed ( const RofiViewState *state )
{
return state->quit;
}
const char * rofi_view_get_user_input ( const RofiViewState *state )
static const char * wayland_rofi_view_get_user_input ( const RofiViewState *state )
{
if ( state->text ) {
return state->text->text;
@ -442,7 +442,7 @@ static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data
g_mutex_unlock ( t->mutex );
}
}
void __create_window ( MenuFlags menu_flags )
static void wayland___create_window ( MenuFlags menu_flags )
{
// FIXME: create surface
// FIXME: roll next buffer
@ -626,7 +626,7 @@ static void update_callback ( textbox *t, icon *ico, unsigned int index, void *u
}
}
void rofi_view_update ( RofiViewState *state, gboolean qr )
static void wayland_rofi_view_update ( RofiViewState *state, gboolean qr )
{
if ( !widget_need_redraw ( WIDGET ( state->main_window ) ) ) {
return;
@ -769,7 +769,7 @@ static void rofi_view_refilter ( RofiViewState *state )
}
// Size the window.
int height = rofi_view_calculate_height ( state );
int height = calculate_height ( state );
if ( height != state->height ) {
state->height = height;
//rofi_view_calculate_window_position ( state );
@ -786,7 +786,7 @@ static void rofi_view_refilter ( RofiViewState *state )
* Check if a finalize function is set, and if sets executes it.
*/
void process_result ( RofiViewState *state );
void rofi_view_finalize ( RofiViewState *state )
static void wayland_rofi_view_finalize ( RofiViewState *state )
{
if ( state && state->finalize != NULL ) {
state->finalize ( state );
@ -1013,7 +1013,7 @@ static void rofi_view_trigger_global_action ( KeyBindingAction action )
}
}
gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
static gboolean wayland_rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
{
switch ( scope )
{
@ -1051,14 +1051,14 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g
return FALSE;
}
void rofi_view_handle_text ( RofiViewState *state, char *text )
static void wayland_rofi_view_handle_text ( RofiViewState *state, char *text )
{
if ( textbox_append_text ( state->text, text, strlen ( text ) ) ) {
state->refilter = TRUE;
}
}
void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
static void wayland_rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
{
state->mouse.x = x;
state->mouse.y = y;
@ -1068,7 +1068,7 @@ void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
}
}
void rofi_view_maybe_update ( RofiViewState *state )
static void wayland_rofi_view_maybe_update ( RofiViewState *state )
{
if ( rofi_view_get_completed ( state ) ) {
// This menu is done.
@ -1088,25 +1088,17 @@ void rofi_view_maybe_update ( RofiViewState *state )
if ( state->refilter ) {
rofi_view_refilter ( state );
}
rofi_view_update ( state, TRUE );
wayland_rofi_view_update ( state, TRUE );
}
/**
* Handle window configure event.
* Handles resizes.
*/
void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce )
{
}
void rofi_view_frame_callback ( void )
static void wayland_rofi_view_frame_callback ( void )
{
if ( CacheState.repaint_source == 0 ) {
CacheState.repaint_source = g_idle_add_full ( G_PRIORITY_HIGH_IDLE, rofi_view_repaint, NULL, NULL );
}
}
static int rofi_view_calculate_height ( RofiViewState *state )
static int calculate_height ( RofiViewState *state )
{
if ( CacheState.fullscreen == TRUE ) {
int height = 1080;
@ -1367,7 +1359,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
}
}
RofiViewState *rofi_view_create ( Mode *sw,
static RofiViewState *wayland_rofi_view_create ( Mode *sw,
const char *input,
MenuFlags menu_flags,
void ( *finalize )( RofiViewState * ) )
@ -1415,19 +1407,19 @@ RofiViewState *rofi_view_create ( Mode *sw,
listview_set_fixed_num_lines ( state->list_view );
}
state->height = rofi_view_calculate_height ( state );
state->height = calculate_height ( state );
// Move the window to the correct x,y position.
//rofi_view_calculate_window_position ( state );
rofi_view_window_update_size ( state );
state->quit = FALSE;
rofi_view_refilter ( state );
rofi_view_update ( state, TRUE );
wayland_rofi_view_update ( state, TRUE );
widget_queue_redraw ( WIDGET ( state->main_window ) );
return state;
}
int rofi_view_error_dialog ( const char *msg, int markup )
static int wayland_rofi_view_error_dialog ( const char *msg, int markup )
{
RofiViewState *state = __rofi_view_state_create ();
state->retv = MENU_CANCEL;
@ -1462,11 +1454,11 @@ int rofi_view_error_dialog ( const char *msg, int markup )
return TRUE;
}
void rofi_view_hide ( void )
static void wayland_rofi_view_hide ( void )
{
}
void rofi_view_cleanup ()
static void wayland_rofi_view_cleanup ()
{
//g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Cleanup." );
if ( CacheState.idle_timeout > 0 ) {
@ -1479,7 +1471,8 @@ void rofi_view_cleanup ()
}
g_assert ( g_queue_is_empty ( &( CacheState.views ) ) );
}
void rofi_view_workers_initialize ( void )
static void wayland_rofi_view_workers_initialize ( void )
{
TICK_N ( "Setup Threadpool, start" );
if ( config.threads == 0 ) {
@ -1506,19 +1499,21 @@ void rofi_view_workers_initialize ( void )
}
TICK_N ( "Setup Threadpool, done" );
}
void rofi_view_workers_finalize ( void )
static void wayland_rofi_view_workers_finalize ( void )
{
if ( tpool ) {
g_thread_pool_free ( tpool, TRUE, TRUE );
tpool = NULL;
}
}
Mode * rofi_view_get_mode ( RofiViewState *state )
static Mode * wayland_rofi_view_get_mode ( RofiViewState *state )
{
return state->sw;
}
void rofi_view_set_overlay ( RofiViewState *state, const char *text )
static void wayland_rofi_view_set_overlay ( RofiViewState *state, const char *text )
{
if ( state->overlay == NULL || state->list_view == NULL ) {
return;
@ -1533,7 +1528,7 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
rofi_view_queue_redraw ( );
}
void rofi_view_clear_input ( RofiViewState *state )
static void wayland_rofi_view_clear_input ( RofiViewState *state )
{
if ( state->text ) {
textbox_text ( state->text, "" );
@ -1541,12 +1536,12 @@ void rofi_view_clear_input ( RofiViewState *state )
}
}
void rofi_view_ellipsize_start ( RofiViewState *state )
static void wayland_rofi_view_ellipsize_start ( RofiViewState *state )
{
listview_set_ellipsize_start ( state->list_view );
}
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
static void wayland_rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
{
state->sw = mode;
// Update prompt;
@ -1563,12 +1558,50 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
state->reload = TRUE;
state->refilter = TRUE;
rofi_view_refilter ( state );
rofi_view_update ( state, TRUE );
wayland_rofi_view_update ( state, TRUE );
}
/*
xcb_window_t rofi_view_get_window ( void )
{
return CacheState.main_window;
}
*/
static view_proxy view_ = {
.create = wayland_rofi_view_create,
.finalize = wayland_rofi_view_finalize,
.get_return_value = wayland_rofi_view_get_return_value,
.get_next_position = wayland_rofi_view_get_next_position,
.handle_text = wayland_rofi_view_handle_text,
.handle_mouse_motion = wayland_rofi_view_handle_mouse_motion,
.maybe_update = wayland_rofi_view_maybe_update,
.temp_configure_notify = NULL,
.temp_click_to_exit = NULL,
.frame_callback = wayland_rofi_view_frame_callback,
.get_completed = wayland_rofi_view_get_completed,
.get_user_input = wayland_rofi_view_get_user_input,
.set_selected_line = wayland_rofi_view_set_selected_line,
.get_selected_line = wayland_rofi_view_get_selected_line,
.restart = wayland_rofi_view_restart,
.trigger_action = wayland_rofi_view_trigger_action,
.free = wayland_rofi_view_free,
.get_active = wayland_rofi_view_get_active,
.set_active = wayland_rofi_view_set_active,
.error_dialog = wayland_rofi_view_error_dialog,
.queue_redraw = wayland_rofi_view_queue_redraw,
.cleanup = wayland_rofi_view_cleanup,
.get_mode = wayland_rofi_view_get_mode,
.hide = wayland_rofi_view_hide,
.reload = wayland_rofi_view_reload,
.switch_mode = wayland_rofi_view_switch_mode,
.set_overlay = wayland_rofi_view_set_overlay,
.clear_input = wayland_rofi_view_clear_input,
.__create_window = wayland___create_window,
.get_window = NULL,
.workers_initialize = wayland_rofi_view_workers_initialize,
.workers_finalize = wayland_rofi_view_workers_finalize,
.get_current_monitor = wayland_rofi_view_get_current_monitor,
.capture_screenshot = wayland_rofi_view_capture_screenshot,
.ellipsize_start = wayland_rofi_view_ellipsize_start,
.set_size = wayland_rofi_view_set_size,
.get_size = wayland_rofi_view_get_size,
};
const view_proxy *wayland_view_proxy = &view_;

View file

@ -493,7 +493,7 @@ static void x11_build_monitor_layout ()
}
}
void display_dump_monitor_layout ( void )
static void xcb_display_dump_monitor_layout ( void )
{
int is_term = isatty ( fileno ( stdout ) );
printf ( "Monitor layout:\n" );
@ -520,7 +520,7 @@ void display_dump_monitor_layout ( void )
}
}
void display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
static void xcb_display_startup_notification ( RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data )
{
if ( context == NULL ) {
return;
@ -748,7 +748,7 @@ static int monitor_active_from_id ( int mon_id, workarea *mon )
}
// determine which monitor holds the active window, or failing that the mouse pointer
int monitor_active ( workarea *mon )
static int xcb_display_monitor_active ( workarea *mon )
{
if ( config.monitor != NULL ) {
for ( workarea *iter = xcb->monitors; iter; iter = iter->next ) {
@ -1161,7 +1161,7 @@ static void x11_helper_discover_window_manager ( void )
}
}
gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings )
static gboolean xcb_display_setup ( GMainLoop *main_loop, NkBindings *bindings )
{
// Get DISPLAY, first env, then argument.
// We never modify display_str content.
@ -1356,7 +1356,7 @@ static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_CONTINUE;
}
gboolean display_late_setup ( void )
static gboolean xcb_display_late_setup ( void )
{
x11_create_visual_and_colormap ();
@ -1394,14 +1394,14 @@ xcb_window_t xcb_stuff_get_root_window ( void )
return xcb->screen->root;
}
void display_early_cleanup ( void )
static void xcb_display_early_cleanup ( void )
{
release_keyboard ( );
release_pointer ( );
xcb_flush ( xcb->connection );
}
void display_cleanup ( void )
static void xcb_display_cleanup ( void )
{
if ( xcb->connection == NULL ) {
return;
@ -1453,3 +1453,22 @@ void x11_disable_decoration ( xcb_window_t window )
xcb_atom_t ha = netatoms[_MOTIF_WM_HINTS];
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints );
}
static const struct _view_proxy* xcb_display_view_proxy ( void )
{
return xcb_view_proxy;
}
static display_proxy display_ = {
.setup = xcb_display_setup,
.late_setup = xcb_display_late_setup,
.early_cleanup = xcb_display_early_cleanup,
.cleanup = xcb_display_cleanup,
.dump_monitor_layout = xcb_display_dump_monitor_layout,
.startup_notification = xcb_display_startup_notification,
.monitor_active = xcb_display_monitor_active,
.view = xcb_display_view_proxy,
};
display_proxy * const xcb_proxy = &display_;

View file

@ -75,12 +75,14 @@
*
* Update the state of the view. This involves filter state.
*/
void rofi_view_update ( RofiViewState *state, gboolean qr );
static void xcb_rofi_view_update ( RofiViewState *state, gboolean qr );
static int rofi_view_calculate_height ( RofiViewState *state );
static void xcb_rofi_view_set_window_title ( const char * title );
/** Thread pool used for filtering */
GThreadPool *tpool = NULL;
extern GThreadPool *tpool;
/** Global pointer to the currently active RofiViewState */
RofiViewState *current_active_menu = NULL;
@ -88,7 +90,7 @@ RofiViewState *current_active_menu = NULL;
/**
* Structure holding cached state.
*/
struct
static struct
{
/** main x11 windows */
xcb_window_t main_window;
@ -132,7 +134,7 @@ struct
.fullscreen = FALSE,
};
void rofi_view_get_current_monitor ( int *width, int *height )
static void xcb_rofi_view_get_current_monitor ( int *width, int *height )
{
if ( width ) {
*width = CacheState.mon.w;
@ -174,7 +176,7 @@ static int lev_sort ( const void *p1, const void *p2, void *arg )
/**
* Stores a screenshot of Rofi at that point in time.
*/
void rofi_capture_screenshot ( void )
static void xcb_rofi_view_capture_screenshot ( void )
{
const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" );
if ( CacheState.edit_surf == NULL ) {
@ -270,7 +272,7 @@ static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
// Repaint the view (if needed).
// After a resize the edit_pixmap surface might not contain anything anymore.
// If we already re-painted, this does nothing.
rofi_view_update ( current_active_menu, FALSE );
xcb_rofi_view_update ( current_active_menu, FALSE );
g_debug ( "expose event" );
TICK_N ( "Expose" );
xcb_copy_area ( xcb->connection, CacheState.edit_pixmap, CacheState.main_window, CacheState.gc,
@ -463,14 +465,14 @@ static gboolean rofi_view_reload_idle ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_REMOVE;
}
void rofi_view_reload ( void )
static void xcb_rofi_view_reload ( void )
{
// @TODO add check if current view is equal to the callee
if ( CacheState.idle_timeout == 0 ) {
CacheState.idle_timeout = g_timeout_add ( 1000 / 10, rofi_view_reload_idle, NULL );
}
}
void rofi_view_queue_redraw ( void )
static void xcb_rofi_view_queue_redraw ( void )
{
if ( current_active_menu && CacheState.repaint_source == 0 ) {
CacheState.count++;
@ -479,18 +481,18 @@ void rofi_view_queue_redraw ( void )
}
}
void rofi_view_restart ( RofiViewState *state )
static void xcb_rofi_view_restart ( RofiViewState *state )
{
state->quit = FALSE;
state->retv = MENU_CANCEL;
}
RofiViewState * rofi_view_get_active ( void )
static RofiViewState * xcb_rofi_view_get_active ( void )
{
return current_active_menu;
}
void rofi_view_set_active ( RofiViewState *state )
static void xcb_rofi_view_set_active ( RofiViewState *state )
{
if ( current_active_menu != NULL && state != NULL ) {
g_queue_push_head ( &( CacheState.views ), current_active_menu );
@ -513,7 +515,7 @@ void rofi_view_set_active ( RofiViewState *state )
rofi_view_queue_redraw ();
}
void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line )
static void xcb_rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_line )
{
state->selected_line = selected_line;
// Find the line.
@ -529,7 +531,7 @@ void rofi_view_set_selected_line ( RofiViewState *state, unsigned int selected_l
xcb_flush ( xcb->connection );
}
void rofi_view_free ( RofiViewState *state )
static void xcb_rofi_view_free ( RofiViewState *state )
{
if ( state->tokens ) {
helper_tokenize_free ( state->tokens );
@ -548,17 +550,17 @@ void rofi_view_free ( RofiViewState *state )
g_free ( state );
}
MenuReturn rofi_view_get_return_value ( const RofiViewState *state )
static MenuReturn xcb_rofi_view_get_return_value ( const RofiViewState *state )
{
return state->retv;
}
unsigned int rofi_view_get_selected_line ( const RofiViewState *state )
static unsigned int xcb_rofi_view_get_selected_line ( const RofiViewState *state )
{
return state->selected_line;
}
unsigned int rofi_view_get_next_position ( const RofiViewState *state )
static unsigned int xcb_rofi_view_get_next_position ( const RofiViewState *state )
{
unsigned int next_pos = state->selected_line;
unsigned int selected = listview_get_selected ( state->list_view );
@ -568,12 +570,12 @@ unsigned int rofi_view_get_next_position ( const RofiViewState *state )
return next_pos;
}
unsigned int rofi_view_get_completed ( const RofiViewState *state )
static unsigned int xcb_rofi_view_get_completed ( const RofiViewState *state )
{
return state->quit;
}
const char * rofi_view_get_user_input ( const RofiViewState *state )
static const char * xcb_rofi_view_get_user_input ( const RofiViewState *state )
{
if ( state->text ) {
return state->text->text;
@ -585,7 +587,7 @@ const char * rofi_view_get_user_input ( const RofiViewState *state )
* Create a new, 0 initialized RofiViewState structure.
*
* @returns a new 0 initialized RofiViewState
*/
static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_static xcb_*/
static RofiViewState * __rofi_view_state_create ( void )
{
return g_malloc0 ( sizeof ( RofiViewState ) );
@ -716,7 +718,7 @@ static void rofi_view_setup_fake_transparency ( const char* const fake_backgroun
TICK_N ( "Fake transparency" );
}
}
void __create_window ( MenuFlags menu_flags )
static void xcb___create_window ( MenuFlags menu_flags )
{
uint32_t selmask = XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
uint32_t selval[] = {
@ -835,7 +837,7 @@ void __create_window ( MenuFlags menu_flags )
TICK_N ( "setup window fullscreen" );
// Set the WM_NAME
rofi_view_set_window_title ( "rofi" );
xcb_rofi_view_set_window_title ( "rofi" );
const char wm_class_name[] = "rofi\0Rofi";
xcb_icccm_set_wm_class ( xcb->connection, box_window, sizeof ( wm_class_name ), wm_class_name );
@ -1018,7 +1020,7 @@ static void update_callback ( textbox *t, icon *ico, unsigned int index, void *u
}
}
void rofi_view_update ( RofiViewState *state, gboolean qr )
static void xcb_rofi_view_update ( RofiViewState *state, gboolean qr )
{
if ( !widget_need_redraw ( WIDGET ( state->main_window ) ) ) {
return;
@ -1186,7 +1188,7 @@ static void rofi_view_refilter ( RofiViewState *state )
* Check if a finalize function is set, and if sets executes it.
*/
void process_result ( RofiViewState *state );
void rofi_view_finalize ( RofiViewState *state )
static void xcb_rofi_view_finalize ( RofiViewState *state )
{
if ( state && state->finalize != NULL ) {
state->finalize ( state );
@ -1418,7 +1420,7 @@ static void rofi_view_trigger_global_action ( KeyBindingAction action )
}
}
gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
static gboolean xcb_rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, guint action )
{
switch ( scope )
{
@ -1456,14 +1458,14 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g
return FALSE;
}
void rofi_view_handle_text ( RofiViewState *state, char *text )
static void xcb_rofi_view_handle_text ( RofiViewState *state, char *text )
{
if ( textbox_append_text ( state->text, text, strlen ( text ) ) ) {
state->refilter = TRUE;
}
}
void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
static void xcb_rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
{
state->mouse.x = x;
state->mouse.y = y;
@ -1473,7 +1475,7 @@ void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
}
}
void rofi_view_maybe_update ( RofiViewState *state )
static void xcb_rofi_view_maybe_update ( RofiViewState *state )
{
if ( rofi_view_get_completed ( state ) ) {
// This menu is done.
@ -1493,14 +1495,14 @@ void rofi_view_maybe_update ( RofiViewState *state )
if ( state->refilter ) {
rofi_view_refilter ( state );
}
rofi_view_update ( state, TRUE );
xcb_rofi_view_update ( state, TRUE );
}
/**
* Handle window configure event.
* Handles resizes.
*/
void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce )
static void xcb_rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notify_event_t *xce )
{
if ( xce->window == CacheState.main_window ) {
if ( state->x != xce->x || state->y != xce->y ) {
@ -1531,7 +1533,7 @@ void rofi_view_temp_configure_notify ( RofiViewState *state, xcb_configure_notif
/**
* Quit rofi on click (outside of view )
*/
void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target )
static void xcb_rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target )
{
if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == 0 ) {
if ( target != CacheState.main_window ) {
@ -1541,7 +1543,7 @@ void rofi_view_temp_click_to_exit ( RofiViewState *state, xcb_window_t target )
}
}
void rofi_view_frame_callback ( void )
static void xcb_rofi_view_frame_callback ( void )
{
if ( CacheState.repaint_source == 0 ) {
CacheState.repaint_source = g_idle_add_full ( G_PRIORITY_HIGH_IDLE, rofi_view_repaint, NULL, NULL );
@ -1805,7 +1807,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
}
}
RofiViewState *rofi_view_create ( Mode *sw,
static RofiViewState *xcb_rofi_view_create ( Mode *sw,
const char *input,
MenuFlags menu_flags,
void ( *finalize )( RofiViewState * ) )
@ -1829,11 +1831,11 @@ RofiViewState *rofi_view_create ( Mode *sw,
if ( state->sw ) {
char * title = g_strdup_printf ( "rofi - %s", mode_get_display_name ( state->sw ) );
rofi_view_set_window_title ( title );
xcb_rofi_view_set_window_title ( title );
g_free ( title );
}
else {
rofi_view_set_window_title ( "rofi" );
xcb_rofi_view_set_window_title ( "rofi" );
}
TICK_N ( "Startup notification" );
@ -1872,7 +1874,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
state->quit = FALSE;
rofi_view_refilter ( state );
rofi_view_update ( state, TRUE );
xcb_rofi_view_update ( state, TRUE );
xcb_map_window ( xcb->connection, CacheState.main_window );
widget_queue_redraw ( WIDGET ( state->main_window ) );
xcb_flush ( xcb->connection );
@ -1882,7 +1884,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
return state;
}
int rofi_view_error_dialog ( const char *msg, int markup )
static int xcb_rofi_view_error_dialog ( const char *msg, int markup )
{
RofiViewState *state = __rofi_view_state_create ();
state->retv = MENU_CANCEL;
@ -1925,7 +1927,7 @@ int rofi_view_error_dialog ( const char *msg, int markup )
return TRUE;
}
void rofi_view_hide ( void )
static void xcb_rofi_view_hide ( void )
{
if ( CacheState.main_window != XCB_WINDOW_NONE ) {
xcb_unmap_window ( xcb->connection, CacheState.main_window );
@ -1933,7 +1935,7 @@ void rofi_view_hide ( void )
}
}
void rofi_view_cleanup ()
static void xcb_rofi_view_cleanup ()
{
g_debug ( "Cleanup." );
if ( CacheState.idle_timeout > 0 ) {
@ -1971,7 +1973,7 @@ void rofi_view_cleanup ()
xcb_flush ( xcb->connection );
g_assert ( g_queue_is_empty ( &( CacheState.views ) ) );
}
void rofi_view_workers_initialize ( void )
static void xcb_rofi_view_workers_initialize ( void )
{
TICK_N ( "Setup Threadpool, start" );
if ( config.threads == 0 ) {
@ -1998,19 +2000,19 @@ void rofi_view_workers_initialize ( void )
}
TICK_N ( "Setup Threadpool, done" );
}
void rofi_view_workers_finalize ( void )
static void xcb_rofi_view_workers_finalize ( void )
{
if ( tpool ) {
g_thread_pool_free ( tpool, TRUE, TRUE );
tpool = NULL;
}
}
Mode * rofi_view_get_mode ( RofiViewState *state )
static Mode * xcb_rofi_view_get_mode ( RofiViewState *state )
{
return state->sw;
}
void rofi_view_set_overlay ( RofiViewState *state, const char *text )
static void xcb_rofi_view_set_overlay ( RofiViewState *state, const char *text )
{
if ( state->overlay == NULL || state->list_view == NULL ) {
return;
@ -2025,7 +2027,7 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
rofi_view_queue_redraw ( );
}
void rofi_view_clear_input ( RofiViewState *state )
static void xcb_rofi_view_clear_input ( RofiViewState *state )
{
if ( state->text ) {
textbox_text ( state->text, "" );
@ -2033,12 +2035,12 @@ void rofi_view_clear_input ( RofiViewState *state )
}
}
void rofi_view_ellipsize_start ( RofiViewState *state )
static void xcb_rofi_view_ellipsize_start ( RofiViewState *state )
{
listview_set_ellipsize_start ( state->list_view );
}
void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
static void xcb_rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
{
state->sw = mode;
// Update prompt;
@ -2047,11 +2049,11 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
}
if ( state->sw ) {
char * title = g_strdup_printf ( "rofi - %s", mode_get_display_name ( state->sw ) );
rofi_view_set_window_title ( title );
xcb_rofi_view_set_window_title ( title );
g_free ( title );
}
else {
rofi_view_set_window_title ( "rofi" );
xcb_rofi_view_set_window_title ( "rofi" );
}
if ( state->sidebar_bar ) {
for ( unsigned int j = 0; j < state->num_modi; j++ ) {
@ -2063,17 +2065,62 @@ void rofi_view_switch_mode ( RofiViewState *state, Mode *mode )
state->reload = TRUE;
state->refilter = TRUE;
rofi_view_refilter ( state );
rofi_view_update ( state, TRUE );
xcb_rofi_view_update ( state, TRUE );
}
xcb_window_t rofi_view_get_window ( void )
static xcb_window_t xcb_rofi_view_get_window ( void )
{
return CacheState.main_window;
}
void rofi_view_set_window_title ( const char * title )
static void xcb_rofi_view_set_window_title ( const char * title )
{
ssize_t len = strlen ( title );
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, CacheState.main_window, xcb->ewmh._NET_WM_NAME, xcb->ewmh.UTF8_STRING, 8, len, title );
xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, CacheState.main_window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, len, title );
}
static view_proxy view_ = {
.create = xcb_rofi_view_create,
.finalize = xcb_rofi_view_finalize,
.get_return_value = xcb_rofi_view_get_return_value,
.get_next_position = xcb_rofi_view_get_next_position,
.handle_text = xcb_rofi_view_handle_text,
.handle_mouse_motion = xcb_rofi_view_handle_mouse_motion,
.maybe_update = xcb_rofi_view_maybe_update,
.temp_configure_notify = xcb_rofi_view_temp_configure_notify,
.temp_click_to_exit = xcb_rofi_view_temp_click_to_exit,
.frame_callback = xcb_rofi_view_frame_callback,
.get_completed = xcb_rofi_view_get_completed,
.get_user_input = xcb_rofi_view_get_user_input,
.set_selected_line = xcb_rofi_view_set_selected_line,
.get_selected_line = xcb_rofi_view_get_selected_line,
.restart = xcb_rofi_view_restart,
.trigger_action = xcb_rofi_view_trigger_action,
.free = xcb_rofi_view_free,
.get_active = xcb_rofi_view_get_active,
.set_active = xcb_rofi_view_set_active,
.error_dialog = xcb_rofi_view_error_dialog,
.queue_redraw = xcb_rofi_view_queue_redraw,
.cleanup = xcb_rofi_view_cleanup,
.get_mode = xcb_rofi_view_get_mode,
.hide = xcb_rofi_view_hide,
.reload = xcb_rofi_view_reload,
.switch_mode = xcb_rofi_view_switch_mode,
.set_overlay = xcb_rofi_view_set_overlay,
.clear_input = xcb_rofi_view_clear_input,
.__create_window = xcb___create_window,
.get_window = xcb_rofi_view_get_window,
.workers_initialize = xcb_rofi_view_workers_initialize,
.workers_finalize = xcb_rofi_view_workers_finalize,
.get_current_monitor = xcb_rofi_view_get_current_monitor,
.capture_screenshot = xcb_rofi_view_capture_screenshot,
.ellipsize_start = xcb_rofi_view_ellipsize_start,
.set_size = NULL,
.get_size = NULL,
};
const view_proxy *xcb_view_proxy = &view_;