From 10322b45a5510d257e5f7509f0ee2ec2cb6ae4ee Mon Sep 17 00:00:00 2001 From: QC Date: Fri, 5 Sep 2014 17:14:50 +0200 Subject: [PATCH] Fix #81, this should now work correctly. * Put old (broken) simpleswitcher code back. * Fix call to window_get_prop * Translate address with XTranslateCoordinates. --- source/rofi.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source/rofi.c b/source/rofi.c index df7461e3..95b88f95 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -615,6 +615,23 @@ void monitor_active ( workarea *mon ) Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) ); int x, y; + Window id; + Atom type; + int count; + if ( window_get_prop ( root, netatoms[_NET_ACTIVE_WINDOW], &type, &count, &id, sizeof ( Window ) ) + && type == XA_WINDOW && count > 0 ) { + XWindowAttributes *attr = window_get_attributes ( id ); + if ( attr != NULL ) { + Window junkwin; + if ( XTranslateCoordinates ( display, id, attr->root, + -attr->border_width, + -attr->border_width, + &x, &y, &junkwin ) == True ) { + monitor_dimensions ( screen, x, y, mon ); + return; + } + } + } if ( pointer_get ( root, &x, &y ) ) { monitor_dimensions ( screen, x, y, mon ); return; @@ -930,7 +947,7 @@ typedef struct MenuState // Return state int *selected_line; MenuReturn retv; - char **lines; + char **lines; }MenuState; /** @@ -1185,12 +1202,12 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in state->selected = state->filtered_lines - 1; state->update = TRUE; } - else if ( key == XK_space && (modstate & ControlMask ) == ControlMask ) { + else if ( key == XK_space && ( modstate & ControlMask ) == ControlMask ) { // If a valid item is selected, return that.. if ( state->selected < state->filtered_lines && state->filtered[state->selected] != NULL ) { - textbox_text( state->text, state->lines[state->line_map[state->selected]] ); - textbox_cursor_end( state->text ); - state->update = TRUE; + textbox_text ( state->text, state->lines[state->line_map[state->selected]] ); + textbox_cursor_end ( state->text ); + state->update = TRUE; state->refilter = TRUE; } }