1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

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 ---------------------------------------------------------------------
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])

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 );
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 );

View file

@ -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" );

View file

@ -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;

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;
}
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 )