summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMenu.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-04-19 20:17:15 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-04-19 20:17:15 (GMT)
commit8988c753dc6194511db17263f46c215ba7cfd56c (patch)
tree67bc31dd39aec3f305436d2b53c7442b787de960 /macosx/tkMacOSXMenu.c
parent39c57bc380140a3893242cfc781b20d08647df21 (diff)
parentfdbf6ba60692e27d6079db2fd7b675f35f1f7727 (diff)
downloadtk-8988c753dc6194511db17263f46c215ba7cfd56c.zip
tk-8988c753dc6194511db17263f46c215ba7cfd56c.tar.gz
tk-8988c753dc6194511db17263f46c215ba7cfd56c.tar.bz2
Merge 8.7
Diffstat (limited to 'macosx/tkMacOSXMenu.c')
-rw-r--r--macosx/tkMacOSXMenu.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index c29e470..98674d2 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -1004,13 +1004,6 @@ TkpPostTearoffMenu(
int vRootX, vRootY, vRootWidth, vRootHeight;
int result;
- if (index >= (int) menuPtr->numEntries) {
- index = menuPtr->numEntries - 1;
- }
- if (index >= 0) {
- y -= menuPtr->entries[index]->y;
- }
-
TkActivateMenuEntry(menuPtr, -1);
TkRecomputeMenu(menuPtr);
result = TkPostCommand(menuPtr);
@@ -1028,6 +1021,18 @@ TkpPostTearoffMenu(
}
/*
+ * Adjust the menu y position so that the specified entry will be located
+ * at the given coordinates.
+ */
+
+ if (index >= menuPtr->numEntries) {
+ index = menuPtr->numEntries - 1;
+ }
+ if (index >= 0) {
+ y -= menuPtr->entries[index]->y;
+ }
+
+ /*
* Adjust the position of the menu if necessary to keep it visible on the
* screen. There are two special tricks to make this work right:
*
@@ -1591,26 +1596,26 @@ void
MenuSelectEvent(
TkMenu *menuPtr) /* the menu we have selected. */
{
- XVirtualEvent event;
-
- bzero(&event, sizeof(XVirtualEvent));
- event.type = VirtualEvent;
- event.serial = LastKnownRequestProcessed(menuPtr->display);
- event.send_event = false;
- event.display = menuPtr->display;
- event.event = Tk_WindowId(menuPtr->tkwin);
- event.root = XRootWindow(menuPtr->display, 0);
- event.subwindow = None;
- event.time = TkpGetMS();
- XQueryPointer(NULL, None, NULL, NULL, &event.x_root, &event.y_root, NULL,
- NULL, &event.state);
- event.same_screen = true;
- event.name = Tk_GetUid("MenuSelect");
+ union {XEvent general; XVirtualEvent virt;} event;
+
+ bzero(&event, sizeof(event));
+ event.virt.type = VirtualEvent;
+ event.virt.serial = LastKnownRequestProcessed(menuPtr->display);
+ event.virt.send_event = false;
+ event.virt.display = menuPtr->display;
+ event.virt.event = Tk_WindowId(menuPtr->tkwin);
+ event.virt.root = XRootWindow(menuPtr->display, 0);
+ event.virt.subwindow = None;
+ event.virt.time = TkpGetMS();
+ XQueryPointer(NULL, None, NULL, NULL, &event.virt.x_root, &event.virt.y_root, NULL,
+ NULL, &event.virt.state);
+ event.virt.same_screen = true;
+ event.virt.name = Tk_GetUid("MenuSelect");
Tk_MakeWindowExist(menuPtr->tkwin);
if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
- Tk_HandleEvent((XEvent *) &event);
+ Tk_HandleEvent(&event.general);
} else {
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+ Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
}