mirror of
https://github.com/davatorium/rofi.git
synced 2025-01-27 15:25:24 -05:00
widget: Rely on find_mouse_target to send motion events
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
30da7e587a
commit
685d4f0e13
8 changed files with 13 additions and 41 deletions
|
@ -124,8 +124,9 @@ struct RofiViewState
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
widget *motion_target;
|
||||||
} mouse;
|
} mouse;
|
||||||
|
|
||||||
/** Regexs used for matching */
|
/** Regexs used for matching */
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct _widget
|
||||||
void ( *update )( struct _widget * );
|
void ( *update )( struct _widget * );
|
||||||
|
|
||||||
/** Handle mouse motion, used for dragging */
|
/** Handle mouse motion, used for dragging */
|
||||||
gboolean ( *motion_notify )( struct _widget *, xcb_motion_notify_event_t * );
|
gboolean ( *motion_notify )( struct _widget *, gint x, gint y );
|
||||||
|
|
||||||
int ( *get_desired_height )( struct _widget * );
|
int ( *get_desired_height )( struct _widget * );
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb c
|
||||||
* TODO make this like clicked with callback.
|
* TODO make this like clicked with callback.
|
||||||
* returns TRUE when handled.
|
* returns TRUE when handled.
|
||||||
*/
|
*/
|
||||||
gboolean widget_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme );
|
gboolean widget_motion_notify ( widget *wid, gint x, gint y );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wid The widget handle
|
* @param wid The widget handle
|
||||||
|
|
|
@ -1410,8 +1410,11 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb
|
||||||
xcb_motion_notify_event_t xme = *( (xcb_motion_notify_event_t *) event );
|
xcb_motion_notify_event_t xme = *( (xcb_motion_notify_event_t *) event );
|
||||||
state->mouse.x = xme.event_x;
|
state->mouse.x = xme.event_x;
|
||||||
state->mouse.y = xme.event_y;
|
state->mouse.y = xme.event_y;
|
||||||
if ( widget_motion_notify ( WIDGET ( state->main_window ), &xme ) ) {
|
if ( state->mouse.motion_target != NULL ) {
|
||||||
return;
|
gint x = state->mouse.x;
|
||||||
|
gint y = state->mouse.y;
|
||||||
|
widget_xy_to_relative ( state->mouse.motion_target, &x, &y );
|
||||||
|
widget_motion_notify ( state->mouse.motion_target, x, y );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,24 +297,6 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean box_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme )
|
|
||||||
{
|
|
||||||
box *b = (box *) wid;
|
|
||||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
|
||||||
widget * child = (widget *) iter->data;
|
|
||||||
if ( !child->enabled ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( widget_intersect ( child, xme->event_x, xme->event_y ) ) {
|
|
||||||
xcb_motion_notify_event_t rel = *xme;
|
|
||||||
rel.event_x -= child->x;
|
|
||||||
rel.event_y -= child->y;
|
|
||||||
return widget_motion_notify ( child, &rel );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
box * box_create ( const char *name, boxType type )
|
box * box_create ( const char *name, boxType type )
|
||||||
{
|
{
|
||||||
box *b = g_malloc0 ( sizeof ( box ) );
|
box *b = g_malloc0 ( sizeof ( box ) );
|
||||||
|
@ -326,7 +308,6 @@ box * box_create ( const char *name, boxType type )
|
||||||
b->widget.resize = box_resize;
|
b->widget.resize = box_resize;
|
||||||
b->widget.update = box_update;
|
b->widget.update = box_update;
|
||||||
b->widget.find_mouse_target = box_find_mouse_target;
|
b->widget.find_mouse_target = box_find_mouse_target;
|
||||||
b->widget.motion_notify = box_motion_notify;
|
|
||||||
b->widget.get_desired_height = box_get_desired_height;
|
b->widget.get_desired_height = box_get_desired_height;
|
||||||
b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
|
b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
|
||||||
|
|
||||||
|
|
|
@ -100,18 +100,6 @@ static widget *container_find_mouse_target ( widget *wid, WidgetType type, gint
|
||||||
return widget_find_mouse_target ( b->child, type, x, y );
|
return widget_find_mouse_target ( b->child, type, x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean container_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme )
|
|
||||||
{
|
|
||||||
container *b = (container *) wid;
|
|
||||||
if ( widget_intersect ( b->child, xme->event_x, xme->event_y ) ) {
|
|
||||||
xcb_motion_notify_event_t rel = *xme;
|
|
||||||
rel.event_x -= b->child->x;
|
|
||||||
rel.event_y -= b->child->y;
|
|
||||||
return widget_motion_notify ( b->child, &rel );
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
container * container_create ( const char *name )
|
container * container_create ( const char *name )
|
||||||
{
|
{
|
||||||
container *b = g_malloc0 ( sizeof ( container ) );
|
container *b = g_malloc0 ( sizeof ( container ) );
|
||||||
|
@ -122,7 +110,6 @@ container * container_create ( const char *name )
|
||||||
b->widget.resize = container_resize;
|
b->widget.resize = container_resize;
|
||||||
b->widget.update = container_update;
|
b->widget.update = container_update;
|
||||||
b->widget.find_mouse_target = container_find_mouse_target;
|
b->widget.find_mouse_target = container_find_mouse_target;
|
||||||
b->widget.motion_notify = container_motion_notify;
|
|
||||||
b->widget.get_desired_height = container_get_desired_height;
|
b->widget.get_desired_height = container_get_desired_height;
|
||||||
b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
|
b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
|
||||||
return b;
|
return b;
|
||||||
|
|
|
@ -83,7 +83,7 @@ static gboolean scrollbar_trigger_action ( widget *wid, MouseBindingMouseDefault
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean scrollbar_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme )
|
static gboolean scrollbar_motion_notify ( widget *wid, G_GNUC_UNUSED gint x, gint y )
|
||||||
{
|
{
|
||||||
/* FIXME: scoll
|
/* FIXME: scoll
|
||||||
scrollbar *sb = (scrollbar *) wid;
|
scrollbar *sb = (scrollbar *) wid;
|
||||||
|
|
|
@ -467,10 +467,10 @@ void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb c
|
||||||
wid->trigger_action_cb_data = cb_data;
|
wid->trigger_action_cb_data = cb_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean widget_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme )
|
gboolean widget_motion_notify ( widget *wid, gint x, gint y )
|
||||||
{
|
{
|
||||||
if ( wid && wid->motion_notify ) {
|
if ( wid && wid->motion_notify ) {
|
||||||
wid->motion_notify ( wid, xme );
|
wid->motion_notify ( wid, x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue