1
0
Fork 0
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:
Quentin Glidic 2017-05-30 12:13:25 +02:00
parent 30da7e587a
commit 685d4f0e13
No known key found for this signature in database
GPG key ID: AC203F96E2C34BB7
8 changed files with 13 additions and 41 deletions

View file

@ -124,8 +124,9 @@ struct RofiViewState
struct
{
int x;
int y;
int x;
int y;
widget *motion_target;
} mouse;
/** Regexs used for matching */

View file

@ -78,7 +78,7 @@ struct _widget
void ( *update )( struct _widget * );
/** 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 * );

View file

@ -268,7 +268,7 @@ void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb c
* TODO make this like clicked with callback.
* 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

View file

@ -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 );
state->mouse.x = xme.event_x;
state->mouse.y = xme.event_y;
if ( widget_motion_notify ( WIDGET ( state->main_window ), &xme ) ) {
return;
if ( state->mouse.motion_target != NULL ) {
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;
}

View file

@ -297,24 +297,6 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
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 *b = g_malloc0 ( sizeof ( box ) );
@ -326,7 +308,6 @@ box * box_create ( const char *name, boxType type )
b->widget.resize = box_resize;
b->widget.update = box_update;
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.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );

View file

@ -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 );
}
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 *b = g_malloc0 ( sizeof ( container ) );
@ -122,7 +110,6 @@ container * container_create ( const char *name )
b->widget.resize = container_resize;
b->widget.update = container_update;
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.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
return b;

View file

@ -83,7 +83,7 @@ static gboolean scrollbar_trigger_action ( widget *wid, MouseBindingMouseDefault
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
scrollbar *sb = (scrollbar *) wid;

View file

@ -467,10 +467,10 @@ void widget_set_trigger_action_handler ( widget *wid, widget_trigger_action_cb c
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 ) {
wid->motion_notify ( wid, xme );
wid->motion_notify ( wid, x, y );
}
return FALSE;