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. It moves the x and y coordinates to the
right place.
---
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].