widget: use orientation rather than position

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-05-10 16:17:39 +02:00
parent aa324d6e2b
commit 0ca7a0fd71
4 changed files with 10 additions and 10 deletions

View File

@ -156,7 +156,7 @@ event_handle_button(void *data, xcb_connection_t *connection, xcb_button_press_e
event_button_callback(ev, &wibox->buttons, 1, NULL); event_button_callback(ev, &wibox->buttons, 1, NULL);
/* then try to match a widget binding */ /* then try to match a widget binding */
widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *w = widget_getbycoords(wibox->sw.orientation, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y); &ev->event_x, &ev->event_y);
@ -400,7 +400,7 @@ event_handle_motionnotify(void *data __attribute__ ((unused)),
if((wibox = wibox_getbywin(ev->event))) if((wibox = wibox_getbywin(ev->event)))
{ {
widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *w = widget_getbycoords(wibox->sw.orientation, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y); &ev->event_x, &ev->event_y);
@ -472,7 +472,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
if((wibox = wibox_getbywin(ev->event))) if((wibox = wibox_getbywin(ev->event)))
{ {
widget_t *w = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *w = widget_getbycoords(wibox->sw.orientation, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&ev->event_x, &ev->event_y); &ev->event_x, &ev->event_y);

View File

@ -257,7 +257,7 @@ luaA_mouse_object_under_pointer(lua_State *L)
int16_t x = mouse_x - wibox->sw.geometry.x; int16_t x = mouse_x - wibox->sw.geometry.x;
int16_t y = mouse_y - wibox->sw.geometry.y; int16_t y = mouse_y - wibox->sw.geometry.y;
widget_t *widget = widget_getbycoords(wibox->position, &wibox->widgets, widget_t *widget = widget_getbycoords(wibox->sw.orientation, &wibox->widgets,
wibox->sw.geometry.width, wibox->sw.geometry.width,
wibox->sw.geometry.height, wibox->sw.geometry.height,
&x, &y); &x, &y);

View File

@ -63,7 +63,7 @@ widget_node_delete(widget_node_t *node)
} }
/** Get a widget node from a wibox by coords. /** Get a widget node from a wibox by coords.
* \param Container position. * \param orientation Wibox orientation.
* \param widgets The widget list. * \param widgets The widget list.
* \param width The container width. * \param width The container width.
* \param height The container height. * \param height The container height.
@ -72,20 +72,20 @@ widget_node_delete(widget_node_t *node)
* \return A widget. * \return A widget.
*/ */
widget_t * widget_t *
widget_getbycoords(position_t position, widget_node_array_t *widgets, widget_getbycoords(orientation_t orientation, widget_node_array_t *widgets,
int width, int height, int16_t *x, int16_t *y) int width, int height, int16_t *x, int16_t *y)
{ {
int tmp; int tmp;
/* Need to transform coordinates like it was top/bottom */ /* Need to transform coordinates like it was top/bottom */
switch(position) switch(orientation)
{ {
case Right: case South:
tmp = *y; tmp = *y;
*y = width - *x; *y = width - *x;
*x = tmp; *x = tmp;
break; break;
case Left: case North:
tmp = *y; tmp = *y;
*y = *x; *y = *x;
*x = height - tmp; *x = height - tmp;

View File

@ -69,7 +69,7 @@ struct widget_node_t
area_t geometry; area_t geometry;
}; };
widget_t *widget_getbycoords(position_t, widget_node_array_t *, int, int, int16_t *, int16_t *); widget_t *widget_getbycoords(orientation_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
void widget_render(wibox_t *); void widget_render(wibox_t *);
void luaA_table2widgets(lua_State *, widget_node_array_t *); void luaA_table2widgets(lua_State *, widget_node_array_t *);