Removing XCB from view.c, paste less

This commit is contained in:
Dave Davenport 2016-02-27 17:42:50 +01:00
parent 9cb5829303
commit 15ad8e1da3
5 changed files with 29 additions and 15 deletions

View File

@ -83,7 +83,7 @@ dnl ---------------------------------------------------------------------
dnl X11, Glib, Xinerama, Pango, Cairo, libstartup notification dnl X11, Glib, Xinerama, Pango, Cairo, libstartup notification
dnl --------------------------------------------------------------------- dnl ---------------------------------------------------------------------
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40]) 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([x11], [x11 x11-xcb])
PKG_CHECK_MODULES([xinerama], [xinerama]) PKG_CHECK_MODULES([xinerama], [xinerama])
PKG_CHECK_MODULES([pango], [pango pangocairo]) PKG_CHECK_MODULES([pango], [pango pangocairo])

View File

@ -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 ); 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 ); 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 window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
int count ); int count );

View File

@ -36,6 +36,7 @@
#include <locale.h> #include <locale.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xkb.h> #include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h> #include <xkbcommon/xkbcommon-compose.h>
@ -76,6 +77,7 @@ const char *cache_dir = NULL;
SnDisplay *sndisplay = NULL; SnDisplay *sndisplay = NULL;
SnLauncheeContext *sncontext = NULL; SnLauncheeContext *sncontext = NULL;
xcb_connection_t *xcb_connection = NULL; xcb_connection_t *xcb_connection = NULL;
xcb_ewmh_connection_t xcb_ewmh;
xcb_screen_t *xcb_screen = NULL; xcb_screen_t *xcb_screen = NULL;
struct xkb_stuff xkb = { NULL }; struct xkb_stuff xkb = { NULL };
Display *display = NULL; Display *display = NULL;
@ -657,6 +659,13 @@ int main ( int argc, char *argv[] )
xcb_connection = XGetXCBConnection ( display ); xcb_connection = XGetXCBConnection ( display );
xcb_screen = xcb_aux_get_screen ( xcb_connection, DefaultScreen ( 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, 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 ) { XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) {
fprintf ( stderr, "cannot setup XKB extension!\n" ); fprintf ( stderr, "cannot setup XKB extension!\n" );

View File

@ -36,6 +36,7 @@
#include <locale.h> #include <locale.h>
#include <xkbcommon/xkbcommon-x11.h> #include <xkbcommon/xkbcommon-x11.h>
#include <xcb/xkb.h> #include <xcb/xkb.h>
#include <xcb/xcb_ewmh.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -71,6 +72,7 @@ extern Display *display;
extern xcb_connection_t *xcb_connection; extern xcb_connection_t *xcb_connection;
extern xcb_screen_t *xcb_screen; extern xcb_screen_t *xcb_screen;
extern SnLauncheeContext *sncontext; extern SnLauncheeContext *sncontext;
extern xcb_ewmh_connection_t xcb_ewmh;
GThreadPool *tpool = NULL; GThreadPool *tpool = NULL;
@ -209,8 +211,8 @@ void rofi_view_queue_redraw ( void )
{ {
if ( current_active_menu ) { if ( current_active_menu ) {
current_active_menu->update = TRUE; current_active_menu->update = TRUE;
XClearArea ( display, main_window, 0, 0, 1, 1, True ); xcb_clear_area ( xcb_connection, main_window, 1, 0, 0, 1, 1 );
XFlush ( display ); xcb_flush ( xcb_connection );
} }
} }
@ -250,12 +252,14 @@ void rofi_view_free ( RofiViewState *state )
{ {
// Do this here? // Do this here?
// Wait for final release? // Wait for final release?
#if 0
if ( !state->skip_absorb ) { if ( !state->skip_absorb ) {
XEvent ev; XEvent ev;
do { do {
XNextEvent ( display, &ev ); XNextEvent ( display, &ev );
} while ( ev.type != KeyRelease ); } while ( ev.type != KeyRelease );
} }
#endif
textbox_free ( state->text ); textbox_free ( state->text );
textbox_free ( state->prompt_tb ); textbox_free ( state->prompt_tb );
textbox_free ( state->case_indicator ); 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 // // make it an unmanaged window
if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) && !config.fullscreen ) { 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 ); window_set_atom_prop ( xcb_connection, box, xcb_ewmh._NET_WM_STATE, &xcb_ewmh._NET_WM_STATE_ABOVE, 1 );
XSetWindowAttributes sattr = { .override_redirect = True }; uint32_t values[] = {1};
XChangeWindowAttributes ( display, box, CWOverrideRedirect, &sattr ); xcb_change_window_attributes ( xcb_connection, box, XCB_CW_OVERRIDE_REDIRECT, values);
} }
else{ 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 ) { if ( config.fullscreen ) {
Atom atoms[] = { xcb_atom_t atoms[] = {
netatoms[_NET_WM_STATE_FULLSCREEN], xcb_ewmh._NET_WM_STATE_FULLSCREEN,
netatoms[_NET_WM_STATE_ABOVE] 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 // 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 ); x11_set_window_opacity ( display, box, config.window_opacity );
return box; return box;

View File

@ -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; 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 ) int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list, int count )