mirror of https://github.com/davatorium/rofi.git
Position the overlay in the top right corner of the listview.
This commit is contained in:
parent
c53e6cc20c
commit
26d9da7263
|
@ -306,5 +306,21 @@ int widget_get_desired_height ( widget *wid );
|
||||||
* @returns the desired width of the widget in pixels.
|
* @returns the desired width of the widget in pixels.
|
||||||
*/
|
*/
|
||||||
int widget_get_desired_width ( widget *wid );
|
int widget_get_desired_width ( widget *wid );
|
||||||
|
/**
|
||||||
|
* @param wid The widget handle
|
||||||
|
*
|
||||||
|
* Get the absolute x-position on the root widget..
|
||||||
|
*
|
||||||
|
* @returns the absolute x-position of widget of the widget in pixels.
|
||||||
|
*/
|
||||||
|
int widget_get_absolute_xpos ( widget *wid );
|
||||||
|
/**
|
||||||
|
* @param wid The widget handle
|
||||||
|
*
|
||||||
|
* Get the absolute y-position on the root widget..
|
||||||
|
*
|
||||||
|
* @returns the absolute y-position of widget of the widget in pixels.
|
||||||
|
*/
|
||||||
|
int widget_get_absolute_ypos ( widget *wid );
|
||||||
/*@}*/
|
/*@}*/
|
||||||
#endif // ROFI_WIDGET_H
|
#endif // ROFI_WIDGET_H
|
||||||
|
|
|
@ -510,7 +510,7 @@ static int drun_mode_init ( Mode *sw )
|
||||||
"gnome",
|
"gnome",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
||||||
pd->disabled_entries = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL );
|
pd->disabled_entries = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL );
|
||||||
mode_set_private_data ( sw, (void *) pd );
|
mode_set_private_data ( sw, (void *) pd );
|
||||||
pd->xdg_context = nk_xdg_theme_context_new ( drun_icon_fallback_themes, NULL );
|
pd->xdg_context = nk_xdg_theme_context_new ( drun_icon_fallback_themes, NULL );
|
||||||
|
|
|
@ -288,30 +288,30 @@ static void rofi_view_calculate_window_position ( RofiViewState *state )
|
||||||
{
|
{
|
||||||
case WL_NORTH_WEST:
|
case WL_NORTH_WEST:
|
||||||
state->x = CacheState.mon.x;
|
state->x = CacheState.mon.x;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WL_NORTH:
|
case WL_NORTH:
|
||||||
state->y = CacheState.mon.y;
|
state->y = CacheState.mon.y;
|
||||||
break;
|
break;
|
||||||
case WL_NORTH_EAST:
|
case WL_NORTH_EAST:
|
||||||
state->y = CacheState.mon.y;
|
state->y = CacheState.mon.y;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WL_EAST:
|
case WL_EAST:
|
||||||
state->x = CacheState.mon.x + CacheState.mon.w;
|
state->x = CacheState.mon.x + CacheState.mon.w;
|
||||||
break;
|
break;
|
||||||
case WL_SOUTH_EAST:
|
case WL_SOUTH_EAST:
|
||||||
state->x = CacheState.mon.x + CacheState.mon.w;
|
state->x = CacheState.mon.x + CacheState.mon.w;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WL_SOUTH:
|
case WL_SOUTH:
|
||||||
state->y = CacheState.mon.y + CacheState.mon.h;
|
state->y = CacheState.mon.y + CacheState.mon.h;
|
||||||
break;
|
break;
|
||||||
case WL_SOUTH_WEST:
|
case WL_SOUTH_WEST:
|
||||||
state->y = CacheState.mon.y + CacheState.mon.h;
|
state->y = CacheState.mon.y + CacheState.mon.h;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WL_WEST:
|
case WL_WEST:
|
||||||
state->x = CacheState.mon.x;
|
state->x = CacheState.mon.x;
|
||||||
break;
|
break;
|
||||||
case WL_CENTER:
|
case WL_CENTER:
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1342,10 +1342,10 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
|
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_END:
|
||||||
target = NULL;
|
target = NULL;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
|
case WIDGET_TRIGGER_ACTION_RESULT_GRAB_MOTION_BEGIN:
|
||||||
state->mouse.motion_target = target;
|
state->mouse.motion_target = target;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
|
case WIDGET_TRIGGER_ACTION_RESULT_HANDLED:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1811,7 +1811,7 @@ Mode * rofi_view_get_mode ( RofiViewState *state )
|
||||||
|
|
||||||
void rofi_view_set_overlay ( RofiViewState *state, const char *text )
|
void rofi_view_set_overlay ( RofiViewState *state, const char *text )
|
||||||
{
|
{
|
||||||
if ( state->overlay == NULL ) {
|
if ( state->overlay == NULL || state->list_view == NULL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( text == NULL ) {
|
if ( text == NULL ) {
|
||||||
|
@ -1820,16 +1820,12 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
|
||||||
}
|
}
|
||||||
widget_enable ( WIDGET ( state->overlay ) );
|
widget_enable ( WIDGET ( state->overlay ) );
|
||||||
textbox_text ( state->overlay, text );
|
textbox_text ( state->overlay, text );
|
||||||
int x_offset = widget_get_width ( WIDGET ( state->main_window ) );
|
int x_offset = widget_get_width ( WIDGET ( state->list_view ) );
|
||||||
// Within padding of window.
|
// Within padding of window.
|
||||||
x_offset -= widget_padding_get_right ( WIDGET ( state->main_window ) );
|
x_offset += widget_get_absolute_xpos ( WIDGET ( state->list_view ) );
|
||||||
// Within the border of widget.
|
|
||||||
//x_offset -= widget_padding_get_right ( WIDGET ( state->main_box ) );
|
|
||||||
//x_offset -= widget_padding_get_right ( WIDGET ( state->input_bar ) );
|
|
||||||
x_offset -= widget_get_width ( WIDGET ( state->case_indicator ) );
|
|
||||||
x_offset -= widget_get_width ( WIDGET ( state->overlay ) );
|
x_offset -= widget_get_width ( WIDGET ( state->overlay ) );
|
||||||
int top_offset = widget_padding_get_top ( WIDGET ( state->main_window ) );
|
// Within the border of widget.
|
||||||
//top_offset += widget_padding_get_top ( WIDGET ( state->main_box ) );
|
int top_offset = widget_get_absolute_ypos ( WIDGET ( state->list_view ) );
|
||||||
widget_move ( WIDGET ( state->overlay ), x_offset, top_offset );
|
widget_move ( WIDGET ( state->overlay ), x_offset, top_offset );
|
||||||
// We want to queue a repaint.
|
// We want to queue a repaint.
|
||||||
rofi_view_queue_redraw ( );
|
rofi_view_queue_redraw ( );
|
||||||
|
|
|
@ -504,7 +504,7 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
|
||||||
break;
|
break;
|
||||||
case ACCEPT_HOVERED_CUSTOM:
|
case ACCEPT_HOVERED_CUSTOM:
|
||||||
custom = TRUE;
|
custom = TRUE;
|
||||||
__attribute__ ((fallthrough));
|
__attribute__ ( ( fallthrough ) );
|
||||||
case ACCEPT_HOVERED_ENTRY:
|
case ACCEPT_HOVERED_ENTRY:
|
||||||
listview_set_selected ( lv, lv->last_offset + i );
|
listview_set_selected ( lv, lv->last_offset + i );
|
||||||
lv->mouse_activated ( lv, custom, lv->mouse_activated_data );
|
lv->mouse_activated ( lv, custom, lv->mouse_activated_data );
|
||||||
|
|
|
@ -569,3 +569,26 @@ int widget_get_desired_width ( widget *wid )
|
||||||
}
|
}
|
||||||
return wid->w;
|
return wid->w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int widget_get_absolute_xpos ( widget *wid )
|
||||||
|
{
|
||||||
|
int retv = 0;
|
||||||
|
if ( wid ) {
|
||||||
|
retv += wid->x;
|
||||||
|
if ( wid->parent ) {
|
||||||
|
retv += widget_get_absolute_xpos ( wid->parent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
int widget_get_absolute_ypos ( widget *wid )
|
||||||
|
{
|
||||||
|
int retv = 0;
|
||||||
|
if ( wid ) {
|
||||||
|
retv += wid->y;
|
||||||
|
if ( wid->parent ) {
|
||||||
|
retv += widget_get_absolute_ypos ( wid->parent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue