mirror of
https://github.com/lbonn/rofi
synced 2025-02-16 21:08:31 +00:00
Allow build without X11/XCB backend
This commit is contained in:
parent
7ce8c8584b
commit
6d18d7812a
6 changed files with 99 additions and 52 deletions
|
@ -62,15 +62,15 @@ Below is a list of the different modi:
|
|||
|
||||
# Wayland support
|
||||
|
||||
To enable Wayland support, build the project with meson and make sure the wayland feature is enabled (it is by default).
|
||||
Wayland support is enabled by default in this fork, along with X11/xcb. You can build rofi _without_ XCB, if you like:
|
||||
|
||||
```
|
||||
meson build -Dwayland=enabled
|
||||
meson build -Dxcb=disabled
|
||||
```
|
||||
|
||||
The rest of the installation process is unchanged (see [Installation](#Installation)).
|
||||
|
||||
**Rofi** can be invoked with the same CLI and configuration and can be forced to use X11 mode with the x11 flag:
|
||||
**Rofi** can be invoked with the same CLI and configuration and can be forced to use X11 mode with the x11 flag (unless the X11 backend was disabled in build):
|
||||
|
||||
rofi -x11 ...
|
||||
|
||||
|
|
80
meson.build
80
meson.build
|
@ -54,31 +54,40 @@ deps = [
|
|||
]
|
||||
|
||||
|
||||
libgwater = subproject('libgwater')
|
||||
# XCB stuff
|
||||
deps += [
|
||||
libgwater.get_variable('libgwater_xcb'),
|
||||
dependency('xcb'),
|
||||
dependency('xcb-aux'),
|
||||
dependency('xcb-xkb'),
|
||||
dependency('xkbcommon-x11'),
|
||||
dependency('xcb-ewmh'),
|
||||
dependency('xcb-icccm'),
|
||||
dependency('xcb-randr'),
|
||||
dependency('xcb-cursor'),
|
||||
dependency('xcb-xinerama'),
|
||||
dependency('cairo-xcb'),
|
||||
dependency('libstartup-notification-1.0'),
|
||||
]
|
||||
xcb_enabled = get_option('xcb').enabled()
|
||||
wayland_enabled = get_option('wayland').enabled()
|
||||
assert(xcb_enabled or wayland_enabled,
|
||||
'At least one of these options must be enabled: wayland, xcb')
|
||||
|
||||
wayland_client = dependency('wayland-client', required: get_option('wayland'))
|
||||
wayland_protocols = dependency('wayland-protocols', version: '>= 1.17', required: get_option('wayland'))
|
||||
wayland_cursor = dependency('wayland-cursor', required: get_option('wayland'))
|
||||
if wayland_client.found()
|
||||
deps += wayland_client
|
||||
deps += wayland_protocols
|
||||
deps += wayland_cursor
|
||||
deps += libgwater.get_variable('libgwater_wayland')
|
||||
libgwater = subproject('libgwater')
|
||||
|
||||
# XCB stuff
|
||||
if xcb_enabled
|
||||
deps += [
|
||||
libgwater.get_variable('libgwater_xcb'),
|
||||
dependency('xcb'),
|
||||
dependency('xcb-aux'),
|
||||
dependency('xcb-xkb'),
|
||||
dependency('xkbcommon-x11'),
|
||||
dependency('xcb-ewmh'),
|
||||
dependency('xcb-icccm'),
|
||||
dependency('xcb-randr'),
|
||||
dependency('xcb-cursor'),
|
||||
dependency('xcb-xinerama'),
|
||||
dependency('cairo-xcb'),
|
||||
dependency('libstartup-notification-1.0'),
|
||||
]
|
||||
endif
|
||||
|
||||
wayland_protocols = dependency('wayland-protocols', version: '>= 1.17', required: wayland_enabled)
|
||||
|
||||
if wayland_enabled
|
||||
deps += [
|
||||
dependency('wayland-client'),
|
||||
wayland_protocols,
|
||||
dependency('wayland-cursor'),
|
||||
libgwater.get_variable('libgwater_wayland'),
|
||||
]
|
||||
endif
|
||||
|
||||
check = dependency('check', version: '>= 0.11.0', required: get_option('check'))
|
||||
|
@ -99,9 +108,11 @@ 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'))
|
||||
# Window mode is not supported in the Wayland backend yet.
|
||||
header_conf.set('WINDOW_MODE', get_option('window') and xcb_enabled)
|
||||
|
||||
header_conf.set('ENABLE_WAYLAND', wayland_client.found())
|
||||
header_conf.set('ENABLE_WAYLAND', wayland_enabled)
|
||||
header_conf.set('ENABLE_XCB', xcb_enabled)
|
||||
|
||||
header_conf.set_quoted('MANPAGE_PATH', join_paths(get_option('prefix'), get_option('mandir')))
|
||||
header_conf.set_quoted('SYSCONFDIR', join_paths(get_option('prefix'), get_option('sysconfdir')))
|
||||
|
@ -176,15 +187,11 @@ rofi_sources = files(
|
|||
'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',
|
||||
'source/xcb/display.c',
|
||||
'source/xcb/view.c',
|
||||
'source/dialogs/filebrowser.c',
|
||||
'include/display.h',
|
||||
'include/xcb.h',
|
||||
'include/xcb-internal.h',
|
||||
'include/rofi.h',
|
||||
'include/mode.h',
|
||||
'include/mode-private.h',
|
||||
|
@ -215,19 +222,28 @@ rofi_sources = files(
|
|||
'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/dialogs/filebrowser.h',
|
||||
'include/dialogs/dmenuscriptshared.h',
|
||||
)
|
||||
if xcb_enabled
|
||||
rofi_sources += files(
|
||||
'source/dialogs/window.c',
|
||||
'source/xcb/display.c',
|
||||
'source/xcb/view.c',
|
||||
'include/dialogs/window.h',
|
||||
'include/xcb-internal.h',
|
||||
)
|
||||
endif
|
||||
|
||||
theme_lexer_sources = files('lexer/theme-lexer.l')
|
||||
theme_parser_sources = files('lexer/theme-parser.y')
|
||||
|
||||
theme_lexer = flex.process(theme_lexer_sources)
|
||||
theme_parser = bison.process(theme_parser_sources)
|
||||
|
||||
if get_option('wayland').enabled()
|
||||
if wayland_enabled
|
||||
wayland_sys_protocols_dir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')
|
||||
wayland_scanner = find_program('wayland-scanner')
|
||||
protocols = files(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
option('drun', type: 'boolean', value: true, description: 'Desktop file mode')
|
||||
option('window', type: 'boolean', value: true, description: 'Window switcher mode')
|
||||
option('check', type: 'feature', description: 'Build and run libcheck-based tests')
|
||||
option('wayland', type : 'feature', value : 'enabled', description: 'Build with wayland support')
|
||||
option('wayland', type: 'feature', value: 'enabled', description: 'Build with wayland support')
|
||||
option('xcb', type: 'feature', value: 'enabled', description: 'Build with X11/xcb support')
|
||||
|
|
|
@ -660,6 +660,7 @@ int config_sanity_check(void) {
|
|||
found_error = 1;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
// Check size
|
||||
{
|
||||
workarea mon;
|
||||
|
@ -676,6 +677,7 @@ int config_sanity_check(void) {
|
|||
found_error = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (config.menu_font) {
|
||||
PangoFontDescription *pfd =
|
||||
|
|
|
@ -875,17 +875,25 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
TICK();
|
||||
|
||||
const struct _display_proxy *proxy = xcb_proxy;
|
||||
const struct _display_proxy *proxy = NULL;
|
||||
#ifdef ENABLE_XCB
|
||||
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
|
||||
|
||||
#ifdef ENABLE_WAYLAND
|
||||
#ifdef ENABLE_XCB
|
||||
const gchar *wl_display = g_getenv("WAYLAND_DISPLAY");
|
||||
if (find_arg("-x11") < 0 && wl_display != NULL && strlen(wl_display) > 0) {
|
||||
proxy = wayland_proxy;
|
||||
config.backend = DISPLAY_WAYLAND;
|
||||
}
|
||||
#else
|
||||
proxy = wayland_proxy;
|
||||
config.backend = DISPLAY_WAYLAND;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
display_init(proxy);
|
||||
|
||||
TICK_N("Select Backend");
|
||||
|
|
|
@ -40,12 +40,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
/** Indicated we understand the startup notification api is not yet stable.*/
|
||||
#define SN_API_NOT_YET_FROZEN
|
||||
#include "rofi.h"
|
||||
#include <libsn/sn.h>
|
||||
|
||||
#include "settings.h"
|
||||
#include "timings.h"
|
||||
|
@ -55,7 +51,6 @@
|
|||
#include "helper-theme.h"
|
||||
#include "helper.h"
|
||||
#include "mode.h"
|
||||
#include "xcb-internal.h"
|
||||
#include "xrmoptions.h"
|
||||
|
||||
#include "view-internal.h"
|
||||
|
@ -63,7 +58,10 @@
|
|||
|
||||
#include "theme.h"
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
#include "xcb-internal.h"
|
||||
#include "xcb.h"
|
||||
#endif
|
||||
|
||||
static const view_proxy *proxy;
|
||||
|
||||
|
@ -219,10 +217,12 @@ void rofi_view_set_selected_line(RofiViewState *state,
|
|||
}
|
||||
listview_set_selected(state->list_view, selected);
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
if (config.backend == DISPLAY_XCB) {
|
||||
xcb_clear_area(xcb->connection, CacheState.main_window, 1, 0, 0, 1, 1);
|
||||
xcb_flush(xcb->connection);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void rofi_view_free(RofiViewState *state) {
|
||||
|
@ -622,30 +622,40 @@ static void rofi_view_trigger_global_action(KeyBindingAction action) {
|
|||
switch (action) {
|
||||
// Handling of paste
|
||||
case PASTE_PRIMARY:
|
||||
#ifdef ENABLE_XCB
|
||||
if (config.backend == DISPLAY_XCB) {
|
||||
xcb_convert_selection(xcb->connection, CacheState.main_window,
|
||||
XCB_ATOM_PRIMARY, xcb->ewmh.UTF8_STRING,
|
||||
xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME);
|
||||
xcb_flush(xcb->connection);
|
||||
} else { // config.backend == DISPLAY_WAYLAND
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WAYLAND
|
||||
if (config.backend == DISPLAY_WAYLAND) {
|
||||
char *d = display_get_clipboard_data(CLIPBOARD_PRIMARY);
|
||||
if (d != NULL) {
|
||||
rofi_view_handle_text(current_active_menu, d);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case PASTE_SECONDARY:
|
||||
#ifdef ENABLE_XCB
|
||||
if (config.backend == DISPLAY_XCB) {
|
||||
xcb_convert_selection(xcb->connection, CacheState.main_window,
|
||||
netatoms[CLIPBOARD], xcb->ewmh.UTF8_STRING,
|
||||
xcb->ewmh.UTF8_STRING, XCB_CURRENT_TIME);
|
||||
xcb_flush(xcb->connection);
|
||||
} else { // config.backend == DISPLAY_WAYLAND
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WAYLAND
|
||||
if (config.backend == DISPLAY_WAYLAND) {
|
||||
char *d = display_get_clipboard_data(CLIPBOARD_DEFAULT);
|
||||
if (d != NULL) {
|
||||
rofi_view_handle_text(current_active_menu, d);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case SCREENSHOT:
|
||||
rofi_capture_screenshot();
|
||||
|
@ -1282,14 +1292,18 @@ RofiViewState *rofi_view_create(Mode *sw, const char *input,
|
|||
state->quit = FALSE;
|
||||
rofi_view_refilter(state);
|
||||
rofi_view_update(state, TRUE);
|
||||
#ifdef ENABLE_XCB
|
||||
if (xcb->connection) {
|
||||
xcb_map_window(xcb->connection, CacheState.main_window);
|
||||
}
|
||||
#endif
|
||||
widget_queue_redraw(WIDGET(state->main_window));
|
||||
rofi_view_ping_mouse(state);
|
||||
#ifdef ENABLE_XCB
|
||||
if (xcb->connection) {
|
||||
xcb_flush(xcb->connection);
|
||||
}
|
||||
#endif
|
||||
|
||||
rofi_view_set_user_timeout(NULL);
|
||||
/* When Override Redirect, the WM will not let us know we can take focus, so
|
||||
|
@ -1298,9 +1312,11 @@ RofiViewState *rofi_view_create(Mode *sw, const char *input,
|
|||
display_set_input_focus(CacheState.main_window);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
if (xcb->sncontext != NULL) {
|
||||
sn_launchee_context_complete(xcb->sncontext);
|
||||
}
|
||||
#endif
|
||||
return state;
|
||||
}
|
||||
|
||||
|
@ -1336,15 +1352,19 @@ int rofi_view_error_dialog(const char *msg, int markup) {
|
|||
// Move the window to the correct x,y position.
|
||||
rofi_view_window_update_size(state);
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
// Display it.
|
||||
if (config.backend == DISPLAY_XCB) {
|
||||
xcb_map_window(xcb->connection, CacheState.main_window);
|
||||
}
|
||||
#endif
|
||||
widget_queue_redraw(WIDGET(state->main_window));
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
if (xcb->sncontext != NULL) {
|
||||
sn_launchee_context_complete(xcb->sncontext);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set it as current window.
|
||||
rofi_view_set_active(state);
|
||||
|
|
Loading…
Add table
Reference in a new issue