summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-02-27 17:42:50 +0100
committerDave Davenport <qball@gmpclient.org>2016-02-27 17:42:50 +0100
commit15ad8e1da3d37ce1b7c8574e8f70ecc71a5497eb (patch)
tree8a404c76f0dda3cfdc9ceb23b789c255657c97d9 /source
parent9cb582930345ab0a0e64b31d934e53c344750071 (diff)
Removing XCB from view.c, paste less
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c9
-rw-r--r--source/view.c27
-rw-r--r--source/x11-helper.c4
3 files changed, 27 insertions, 13 deletions
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 )