summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/util.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index a68d340d..02b22ed9 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -195,24 +195,27 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
195 195
196void openMenu_Widget(iWidget *d, iInt2 coord) { 196void openMenu_Widget(iWidget *d, iInt2 coord) {
197 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */ 197 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */
198// processEvents_App(postedEventsOnly_AppEventMode);
199 setFlags_Widget(d, hidden_WidgetFlag, iFalse); 198 setFlags_Widget(d, hidden_WidgetFlag, iFalse);
200 arrange_Widget(d); 199 arrange_Widget(d);
201 d->rect.pos = coord; 200 d->rect.pos = coord;
202 /* Ensure the full menu is visible. */ 201 /* Ensure the full menu is visible. */
203 const iInt2 rootSize = rootSize_Window(get_Window()); 202 const iInt2 rootSize = rootSize_Window(get_Window());
204 const int bottomExcess = bottom_Rect(bounds_Widget(d)) - rootSize.y; 203 const iRect bounds = bounds_Widget(d);
204 const int leftExcess = -left_Rect(bounds);
205 const int rightExcess = right_Rect(bounds) - rootSize.x;
206 const int topExcess = -top_Rect(bounds);
207 const int bottomExcess = bottom_Rect(bounds) - rootSize.y;
205 if (bottomExcess > 0) { 208 if (bottomExcess > 0) {
206 d->rect.pos.y -= bottomExcess; 209 d->rect.pos.y -= bottomExcess;
207 } 210 }
208 if (top_Rect(d->rect) < 0) { 211 if (topExcess > 0) {
209 d->rect.pos.y += -top_Rect(d->rect); 212 d->rect.pos.y += topExcess;
210 } 213 }
211 if (right_Rect(bounds_Widget(d)) > rootSize.x) { 214 if (rightExcess > 0) {
212 d->rect.pos.x = coord.x - d->rect.size.x; 215 d->rect.pos.x -= rightExcess;
213 } 216 }
214 if (left_Rect(d->rect) < 0) { 217 if (leftExcess > 0) {
215 d->rect.pos.x = 0; 218 d->rect.pos.x += leftExcess;
216 } 219 }
217 refresh_App(); 220 refresh_App();
218} 221}