summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--include/x11-helper.h2
-rw-r--r--source/rofi.c9
-rw-r--r--source/view.c27
-rw-r--r--source/x11-helper.c4
5 files changed, 29 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index 4df0b2b6..9dc8a39b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,7 +83,7 @@ dnl ---------------------------------------------------------------------
dnl X11, Glib, Xinerama, Pango, Cairo, libstartup notification
dnl ---------------------------------------------------------------------
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40])
-GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11])
+GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh])
PKG_CHECK_MODULES([x11], [x11 x11-xcb])
PKG_CHECK_MODULES([xinerama], [xinerama])
PKG_CHECK_MODULES([pango], [pango pangocairo])
diff --git a/include/x11-helper.h b/include/x11-helper.h
index 02167248..d7855e6a 100644
--- a/include/x11-helper.h
+++ b/include/x11-helper.h
@@ -28,7 +28,7 @@ int window_get_prop ( Display *display, Window w, Atom prop,
char* window_get_text_prop ( Display *display, Window w, Atom atom );
int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, int count );
-void window_set_atom_prop ( Display *display, Window w, Atom atom, Atom *atoms, int count );
+void window_set_atom_prop ( xcb_connection_t *xcb_connection, Window w, xcb_atom_t prop, xcb_atom_t *atoms, int count );
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
int count );
diff --git a/source/rofi.c b/source/rofi.c
index 1bfc0387..2cfd706b 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -36,6 +36,7 @@
#include <locale.h>
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>
+#include <xcb/xcb_ewmh.h>
#include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
@@ -76,6 +77,7 @@ const char *cache_dir = NULL;
SnDisplay *sndisplay = NULL;
SnLauncheeContext *sncontext = NULL;
xcb_connection_t *xcb_connection = NULL;
+xcb_ewmh_connection_t xcb_ewmh;
xcb_screen_t *xcb_screen = NULL;
struct xkb_stuff xkb = { NULL };
Display *display = NULL;
@@ -657,6 +659,13 @@ int main ( int argc, char *argv[] )
xcb_connection = XGetXCBConnection ( display );
xcb_screen = xcb_aux_get_screen ( xcb_connection, DefaultScreen ( display ) );
+ xcb_intern_atom_cookie_t *ac = xcb_ewmh_init_atoms(xcb_connection, &xcb_ewmh);
+ xcb_generic_error_t **errors = NULL;
+ xcb_ewmh_init_atoms_replies(&xcb_ewmh, ac, errors);
+ if (errors){
+ fprintf(stderr, "Failed to create EWMH atoms\n");
+ }
+
if ( xkb_x11_setup_xkb_extension ( xcb_connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
fprintf ( stderr, "cannot setup XKB extension!\n" );
diff --git a/source/view.c b/source/view.c
index 8bd99f81..b942b4b0 100644
--- a/source/view.c
+++ b/source/view.c
@@ -36,6 +36,7 @@
#include <locale.h>
#include <xkbcommon/xkbcommon-x11.h>
#include <xcb/xkb.h>
+#include <xcb/xcb_ewmh.h>
#include <X11/X.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
@@ -71,6 +72,7 @@ extern Display *display;
extern xcb_connection_t *xcb_connection;
extern xcb_screen_t *xcb_screen;
extern SnLauncheeContext *sncontext;
+extern xcb_ewmh_connection_t xcb_ewmh;
GThreadPool *tpool = NULL;
@@ -209,8 +211,8 @@ void rofi_view_queue_redraw ( void )
{
if ( current_active_menu ) {
current_active_menu->update = TRUE;
- XClearArea ( display, main_window, 0, 0, 1, 1, True );
- XFlush ( display );
+ xcb_clear_area ( xcb_connection, main_window, 1, 0, 0, 1, 1 );
+ xcb_flush ( xcb_connection );
}
}
@@ -250,12 +252,14 @@ void rofi_view_free ( RofiViewState *state )
{
// Do this here?
// Wait for final release?
+#if 0
if ( !state->skip_absorb ) {
XEvent ev;
do {
XNextEvent ( display, &ev );
} while ( ev.type != KeyRelease );
}
+#endif
textbox_free ( state->text );
textbox_free ( state->prompt_tb );
textbox_free ( state->case_indicator );
@@ -542,23 +546,24 @@ static Window __create_window ( xcb_connection_t *xcb_connection, xcb_screen_t *
// // make it an unmanaged window
if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) && !config.fullscreen ) {
- window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], &netatoms[_NET_WM_STATE_ABOVE], 1 );
- XSetWindowAttributes sattr = { .override_redirect = True };
- XChangeWindowAttributes ( display, box, CWOverrideRedirect, &sattr );
+ window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_STATE, &xcb_ewmh._NET_WM_STATE_ABOVE, 1 );
+ uint32_t values[] = {1};
+ xcb_change_window_attributes ( xcb_connection, box, XCB_CW_OVERRIDE_REDIRECT, values);
}
else{
- window_set_atom_prop ( display, box, netatoms[_NET_WM_WINDOW_TYPE], &netatoms[_NET_WM_WINDOW_TYPE_NORMAL], 1 );
+ window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_WINDOW_TYPE, &xcb_ewmh._NET_WM_WINDOW_TYPE_NORMAL, 1 );
}
if ( config.fullscreen ) {
- Atom atoms[] = {
- netatoms[_NET_WM_STATE_FULLSCREEN],
- netatoms[_NET_WM_STATE_ABOVE]
+ xcb_atom_t atoms[] = {
+ xcb_ewmh._NET_WM_STATE_FULLSCREEN,
+ xcb_ewmh._NET_WM_STATE_ABOVE
};
- window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], atoms, sizeof ( atoms ) / sizeof ( Atom ) );
+ window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_STATE, atoms, sizeof ( atoms ) / sizeof ( Atom ) );
}
// Set the WM_NAME
- XStoreName ( display, box, "rofi" );
+ xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, xcb_ewmh._NET_WM_NAME, xcb_ewmh.UTF8_STRING, 8, 4,"rofi");
+ xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, box, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 4,"rofi");
x11_set_window_opacity ( display, box, config.window_opacity );
return box;
diff --git a/source/x11-helper.c b/source/x11-helper.c
index f5eb873f..983e8c71 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -150,9 +150,9 @@ int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, in
return window_get_prop ( display, w, atom, &type, &items, list, count * sizeof ( Atom ) ) && type == XA_ATOM ? items : 0;
}
-void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms, int count )
+void window_set_atom_prop ( xcb_connection_t *xcb_connection, Window w, xcb_atom_t prop, xcb_atom_t *atoms, int count )
{
- XChangeProperty ( display, w, prop, XA_ATOM, 32, PropModeReplace, ( unsigned char * ) atoms, count );
+ xcb_change_property ( xcb_connection, XCB_PROP_MODE_REPLACE, w, prop, XCB_ATOM_ATOM, 32, count, atoms);
}
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list, int count )