On Wed, 3 Apr 2013 at 20:01:49 +0200, Rodolfo García Peñas (kix) wrote:
> From: "Rodolfo García Peñas (kix)" <[email protected]>
>
> The function get_right_position_on_screen() sets the right position
> in the screen using a WRect.
This description confuses me a bit. The function is named get_ but it sets the
position, so it should be named set_, no?
> It moves the x and y coordinates to the right place.
So what's the _right_ in the name? It is 'right' as opposed
to 'left' or is it 'right' as 'correct'?
>From my brief reading of the function, I think that dropping
the 'right' from the name would not create confusion, or do
you envision having a set_left_position_on_screen()?
I don't know if I'm making sense, though :-)
> ---
> src/menu.c | 16 +++-------------
> src/placement.c | 17 +++++++++++++++++
> 2 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/src/menu.c b/src/menu.c
> index 696daa0..5a52d36 100644
> --- a/src/menu.c
> +++ b/src/menu.c
> @@ -43,6 +43,7 @@
> #include "workspace.h"
> #include "dialog.h"
> #include "rootmenu.h"
> +#include "placement.h"
>
> /****** Global Variables ******/
>
> @@ -1068,19 +1069,8 @@ void wMenuMapAt(WMenu * menu, int x, int y, int
> keyboard)
> }
>
> if (!menu->flags.mapped) {
> - if (wPreferences.wrap_menus) {
> - WScreen *scr = menu->frame->screen_ptr;
> - WMRect rect = wGetRectForHead(scr,
> wGetHeadForPointerLocation(scr));
> -
> - if (x < rect.pos.x)
> - x = rect.pos.x;
> - if (y < rect.pos.y)
> - y = rect.pos.y;
> - if (x + MENUW(menu) > rect.pos.x + rect.size.width)
> - x = rect.pos.x + rect.size.width - MENUW(menu);
> - if (y + MENUH(menu) > rect.pos.y + rect.size.height)
> - y = rect.pos.y + rect.size.height - MENUH(menu);
> - }
> + if (wPreferences.wrap_menus)
> + get_right_position_on_screen(menu->frame->screen_ptr,
> &x, &y, MENUW(menu), MENUH(menu));
>
> XMoveWindow(dpy, menu->frame->core->window, x, y);
> menu->frame_x = x;
> diff --git a/src/placement.c b/src/placement.c
> index 5e4a8e7..5a3eaa9 100644
> --- a/src/placement.c
> +++ b/src/placement.c
> @@ -565,3 +565,20 @@ void PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
> unsigned width, unsigned
> if (*y_ret < usableArea.y1)
> *y_ret = usableArea.y1;
> }
> +
> +void get_right_position_on_screen(WScreen *scr, int *x, int *y, int size_x,
> int size_y)
> +{
> + WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
> +
> + if (*x < rect.pos.x)
> + *x = rect.pos.x;
> +
> + if (*y < rect.pos.y)
> + *y = rect.pos.y;
> +
> + if (*x + size_x > rect.pos.x + rect.size.width)
> + *x = rect.pos.x + rect.size.width - size_x;
> +
> + if (*y + size_y > rect.pos.y + rect.size.height)
> + *y = rect.pos.y + rect.size.height - size_y;
> +}
> --
> 1.7.10.4
>
>
> --
> To unsubscribe, send mail to [email protected].
--
To unsubscribe, send mail to [email protected].