Skip to content

Commit

Permalink
Fixed a menu-positioning problem where a menu window could appear on …
Browse files Browse the repository at this point in the history
…another screen

than where expected. Occurred when one screen has negative x coordinates.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10211 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Jun 28, 2014
1 parent a8d1251 commit a59a3d2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Fl_Menu.cxx
Expand Up @@ -353,7 +353,11 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (Wp > W) W = Wp;
if (Wtitle > W) W = Wtitle;

if (X < scr_x) X = scr_x; if (X > scr_x+scr_w-W) X = right_edge-W;
if (X < scr_x) X = scr_x;
// this change improves popup submenu positioning at right screen edge,
// but it makes right_edge argument useless
//if (X > scr_x+scr_w-W) X = right_edge-W;
if (X > scr_x+scr_w-W) X = scr_x+scr_w-W;
x(X); w(W);
h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3);
if (selected >= 0) {
Expand Down Expand Up @@ -916,10 +920,12 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
if (n->selected>=0) {
int dy = n->y()-nY;
int dx = n->x()-nX;
int waX, waY, waW, waH;
Fl::screen_work_area(waX, waY, waW, waH, X, Y);
for (int menu = 0; menu <= pp.menu_number; menu++) {
menuwindow* tt = pp.p[menu];
int nx = tt->x()+dx; if (nx < 0) {nx = 0; dx = -tt->x();}
int ny = tt->y()+dy; if (ny < 0) {ny = 0; dy = -tt->y();}
int nx = tt->x()+dx; if (nx < waX) {nx = waX; dx = -tt->x() + waX;}
int ny = tt->y()+dy; if (ny < waY) {ny = waY; dy = -tt->y() + waY;}
tt->position(nx, ny);
}
setitem(pp.nummenus-1, n->selected);
Expand Down

0 comments on commit a59a3d2

Please sign in to comment.