event: fix left/right events
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
8d2ace48fd
commit
669c023ca9
26
event.c
26
event.c
|
@ -88,7 +88,7 @@ event_handle_mouse_button(client_t *c,
|
||||||
* \return A widget node.
|
* \return A widget node.
|
||||||
*/
|
*/
|
||||||
static widget_node_t *
|
static widget_node_t *
|
||||||
widget_getbycoords(position_t position, widget_node_t *widgets, int width, int height, int x, int y)
|
widget_getbycoords(position_t position, widget_node_t *widgets, int width, int height, int16_t *x, int16_t *y)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
widget_node_t *w;
|
widget_node_t *w;
|
||||||
|
@ -97,22 +97,22 @@ widget_getbycoords(position_t position, widget_node_t *widgets, int width, int h
|
||||||
switch(position)
|
switch(position)
|
||||||
{
|
{
|
||||||
case Right:
|
case Right:
|
||||||
tmp = y;
|
tmp = *y;
|
||||||
y = width - x;
|
*y = width - *x;
|
||||||
x = tmp;
|
*x = tmp;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
tmp = y;
|
tmp = *y;
|
||||||
y = x;
|
*y = *x;
|
||||||
x = height - tmp;
|
*x = height - tmp;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(w = widgets; w; w = w->next)
|
for(w = widgets; w; w = w->next)
|
||||||
if(x >= w->area.x && x < w->area.x + w->area.width
|
if(*x >= w->area.x && *x < w->area.x + w->area.width
|
||||||
&& y >= w->area.y && y < w->area.y + w->area.height)
|
&& *y >= w->area.y && *y < w->area.y + w->area.height)
|
||||||
return w;
|
return w;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -153,7 +153,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
||||||
if((w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
if((w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
||||||
statusbar->sw.geometry.width,
|
statusbar->sw.geometry.width,
|
||||||
statusbar->sw.geometry.height,
|
statusbar->sw.geometry.height,
|
||||||
ev->event_x, ev->event_y)))
|
&ev->event_x, &ev->event_y)))
|
||||||
w->widget->button(w, ev, statusbar->screen, statusbar, AWESOME_TYPE_STATUSBAR);
|
w->widget->button(w, ev, statusbar->screen, statusbar, AWESOME_TYPE_STATUSBAR);
|
||||||
/* return even if no widget match */
|
/* return even if no widget match */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -164,7 +164,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
|
||||||
{
|
{
|
||||||
if((w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
if((w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
||||||
c->titlebar->width, c->titlebar->height,
|
c->titlebar->width, c->titlebar->height,
|
||||||
ev->event_x, ev->event_y)))
|
&ev->event_x, &ev->event_y)))
|
||||||
w->widget->button(w, ev, c->screen, c->titlebar, AWESOME_TYPE_TITLEBAR);
|
w->widget->button(w, ev, c->screen, c->titlebar, AWESOME_TYPE_TITLEBAR);
|
||||||
/* return even if no widget match */
|
/* return even if no widget match */
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -390,7 +390,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
|
||||||
w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
w = widget_getbycoords(statusbar->position, statusbar->widgets,
|
||||||
statusbar->sw.geometry.width,
|
statusbar->sw.geometry.width,
|
||||||
statusbar->sw.geometry.height,
|
statusbar->sw.geometry.height,
|
||||||
ev->event_x, ev->event_y);
|
&ev->event_x, &ev->event_y);
|
||||||
event_handle_widget_motionnotify(statusbar,
|
event_handle_widget_motionnotify(statusbar,
|
||||||
AWESOME_TYPE_STATUSBAR,
|
AWESOME_TYPE_STATUSBAR,
|
||||||
&statusbar->mouse_over, w);
|
&statusbar->mouse_over, w);
|
||||||
|
@ -400,7 +400,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
|
||||||
w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
w = widget_getbycoords(c->titlebar->position, c->titlebar->widgets,
|
||||||
c->titlebar->sw.geometry.width,
|
c->titlebar->sw.geometry.width,
|
||||||
c->titlebar->sw.geometry.height,
|
c->titlebar->sw.geometry.height,
|
||||||
ev->event_x, ev->event_y);
|
&ev->event_x, &ev->event_y);
|
||||||
event_handle_widget_motionnotify(c->titlebar,
|
event_handle_widget_motionnotify(c->titlebar,
|
||||||
AWESOME_TYPE_TITLEBAR,
|
AWESOME_TYPE_TITLEBAR,
|
||||||
&c->titlebar->mouse_over, w);
|
&c->titlebar->mouse_over, w);
|
||||||
|
|
Loading…
Reference in New Issue