1 /* winmenu.c - command menu for windows
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <X11/Xutil.h>
31 #include <X11/XKBlib.h>
33 #include "WindowMaker.h"
39 #include "application.h"
43 #include "workspace.h"
44 #include "winspector.h"
78 unsigned int shortcut_idx
;
80 } menu_maximize_entries
[] = {
81 { N_("Maximize vertically"), WKBD_VMAXIMIZE
, MAX_VERTICAL
},
82 { N_("Maximize horizontally"), WKBD_HMAXIMIZE
, MAX_HORIZONTAL
},
83 { N_("Maximize left half"), WKBD_LHMAXIMIZE
, MAX_VERTICAL
| MAX_LEFTHALF
},
84 { N_("Maximize right half"), WKBD_RHMAXIMIZE
, MAX_VERTICAL
| MAX_RIGHTHALF
},
85 { N_("Maximize top half"), WKBD_THMAXIMIZE
, MAX_HORIZONTAL
| MAX_TOPHALF
},
86 { N_("Maximize bottom half"), WKBD_BHMAXIMIZE
, MAX_HORIZONTAL
| MAX_BOTTOMHALF
},
87 { N_("Maximize left top corner"), WKBD_LTCMAXIMIZE
, MAX_LEFTHALF
| MAX_TOPHALF
},
88 { N_("Maximize right top corner"), WKBD_RTCMAXIMIZE
, MAX_RIGHTHALF
| MAX_TOPHALF
},
89 { N_("Maximize left bottom corner"), WKBD_LBCMAXIMIZE
, MAX_LEFTHALF
| MAX_BOTTOMHALF
},
90 { N_("Maximize right bottom corner"), WKBD_RBCMAXIMIZE
, MAX_RIGHTHALF
| MAX_BOTTOMHALF
},
91 { N_("Maximus: tiled maximization"), WKBD_MAXIMUS
, MAX_MAXIMUS
}
94 static void updateOptionsMenu(WMenu
* menu
, WWindow
* wwin
);
96 static void execWindowOptionCommand(WMenu
* menu
, WMenuEntry
* entry
)
98 WWindow
*wwin
= (WWindow
*) entry
->clientdata
;
100 /* Parameter not used, but tell the compiler that it is ok */
103 switch (entry
->order
) {
105 if (wwin
->frame
->core
->stacking
->window_level
!= WMFloatingLevel
)
106 ChangeStackingLevel(wwin
->frame
->core
, WMFloatingLevel
);
108 ChangeStackingLevel(wwin
->frame
->core
, WMNormalLevel
);
111 case WO_KEEP_AT_BOTTOM
:
112 if (wwin
->frame
->core
->stacking
->window_level
!= WMSunkenLevel
)
113 ChangeStackingLevel(wwin
->frame
->core
, WMSunkenLevel
);
115 ChangeStackingLevel(wwin
->frame
->core
, WMNormalLevel
);
119 wWindowSetOmnipresent(wwin
, !wwin
->flags
.omnipresent
);
124 static void execMaximizeCommand(WMenu
* menu
, WMenuEntry
* entry
)
126 WWindow
*wwin
= (WWindow
*) entry
->clientdata
;
128 /* Parameter not used, but tell the compiler that it is ok */
131 handleMaximize(wwin
, menu_maximize_entries
[entry
->order
].maxim_direction
);
134 static void updateUnmaximizeShortcut(WMenuEntry
* entry
, int flags
)
138 switch (flags
& (MAX_HORIZONTAL
| MAX_VERTICAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_TOPHALF
| MAX_BOTTOMHALF
| MAX_MAXIMUS
)) {
140 key
= WKBD_HMAXIMIZE
;
144 key
= WKBD_VMAXIMIZE
;
147 case MAX_LEFTHALF
| MAX_VERTICAL
:
148 key
= WKBD_LHMAXIMIZE
;
151 case MAX_RIGHTHALF
| MAX_VERTICAL
:
152 key
= WKBD_RHMAXIMIZE
;
155 case MAX_TOPHALF
| MAX_HORIZONTAL
:
156 key
= WKBD_THMAXIMIZE
;
159 case MAX_BOTTOMHALF
| MAX_HORIZONTAL
:
160 key
= WKBD_BHMAXIMIZE
;
163 case MAX_LEFTHALF
| MAX_TOPHALF
:
164 key
= WKBD_LTCMAXIMIZE
;
167 case MAX_RIGHTHALF
| MAX_TOPHALF
:
168 key
= WKBD_RTCMAXIMIZE
;
171 case MAX_LEFTHALF
| MAX_BOTTOMHALF
:
172 key
= WKBD_LBCMAXIMIZE
;
175 case MAX_RIGHTHALF
| MAX_BOTTOMHALF
:
176 key
= WKBD_RBCMAXIMIZE
;
188 entry
->rtext
= GetShortcutKey(wKeyBindings
[key
]);
191 static void execMenuCommand(WMenu
* menu
, WMenuEntry
* entry
)
193 WWindow
*wwin
= (WWindow
*) entry
->clientdata
;
196 CloseWindowMenu(menu
->frame
->screen_ptr
);
198 switch (entry
->order
) {
200 /* send delete message */
201 wClientSendProtocol(wwin
, w_global
.atom
.wm
.delete_window
,
202 w_global
.timestamp
.last_event
);
207 if (wPreferences
.dont_confirm_kill
208 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
210 ("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."),
211 _("Yes"), _("No"), NULL
) == WAPRDefault
) {
212 if (!wwin
->flags
.destroyed
)
219 if (wwin
->flags
.miniaturized
) {
220 wDeiconifyWindow(wwin
);
222 if (wwin
->protocols
.MINIATURIZE_WINDOW
) {
223 wClientSendProtocol(wwin
, w_global
.atom
.gnustep
.wm_miniaturize_window
,
224 w_global
.timestamp
.last_event
);
226 wIconifyWindow(wwin
);
232 if (wwin
->flags
.maximized
)
233 wUnmaximizeWindow(wwin
);
235 wMaximizeWindow(wwin
, MAX_VERTICAL
| MAX_HORIZONTAL
);
239 if (wwin
->flags
.shaded
)
240 wUnshadeWindow(wwin
);
246 if (!wwin
->flags
.miniaturized
)
247 wSelectWindow(wwin
, !wwin
->flags
.selected
);
249 wIconSelect(wwin
->icon
);
253 wKeyboardMoveResizeWindow(wwin
);
257 wShowInspectorForWindow(wwin
);
261 (void) RelaunchWindow(wwin
);
265 wapp
= wApplicationOf(wwin
->main_window
);
266 wHideApplication(wapp
);
271 static void switchWSCommand(WMenu
* menu
, WMenuEntry
* entry
)
273 WWindow
*wwin
= (WWindow
*) entry
->clientdata
;
275 /* Parameter not used, but tell the compiler that it is ok */
278 wSelectWindow(wwin
, False
);
279 wWindowChangeWorkspace(wwin
, entry
->order
);
282 static void makeShortcutCommand(WMenu
*menu
, WMenuEntry
*entry
)
284 WWindow
*wwin
= (WWindow
*) entry
->clientdata
;
285 WScreen
*scr
= wwin
->screen_ptr
;
286 int index
= entry
->order
- WO_ENTRIES
;
288 /* Parameter not used, but tell the compiler that it is ok */
291 if (w_global
.shortcut
.windows
[index
]) {
292 WMFreeArray(w_global
.shortcut
.windows
[index
]);
293 w_global
.shortcut
.windows
[index
] = NULL
;
296 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
297 w_global
.shortcut
.windows
[index
] = WMDuplicateArray(scr
->selected_windows
);
299 w_global
.shortcut
.windows
[index
] = WMCreateArray(4);
300 WMAddToArray(w_global
.shortcut
.windows
[index
], wwin
);
303 wSelectWindow(wwin
, !wwin
->flags
.selected
);
306 wSelectWindow(wwin
, !wwin
->flags
.selected
);
310 static void updateWorkspaceMenu(WMenu
* menu
)
312 char title
[MAX_WORKSPACENAME_WIDTH
+ 1];
316 for (i
= 0; i
< w_global
.workspace
.count
; i
++) {
317 if (i
< menu
->entry_no
) {
319 entry
= menu
->entries
[i
];
320 if (strcmp(entry
->text
, w_global
.workspace
.array
[i
]->name
) != 0) {
322 strncpy(title
, w_global
.workspace
.array
[i
]->name
, MAX_WORKSPACENAME_WIDTH
);
323 title
[MAX_WORKSPACENAME_WIDTH
] = 0;
324 menu
->entries
[i
]->text
= wstrdup(title
);
325 menu
->entries
[i
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MOVE_WORKSPACE1
+ i
]);
326 menu
->flags
.realized
= 0;
329 strncpy(title
, w_global
.workspace
.array
[i
]->name
, MAX_WORKSPACENAME_WIDTH
);
330 title
[MAX_WORKSPACENAME_WIDTH
] = 0;
332 entry
= wMenuAddCallback(menu
, title
, switchWSCommand
, NULL
);
333 entry
->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MOVE_WORKSPACE1
+ i
]);
335 menu
->flags
.realized
= 0;
338 /* workspace shortcut labels */
339 if (i
/ 10 == w_global
.workspace
.current
/ 10)
340 entry
->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MOVE_WORKSPACE1
+ (i
% 10)]);
345 if (!menu
->flags
.realized
)
349 static void updateMakeShortcutMenu(WMenu
*menu
, WWindow
*wwin
)
351 WMenu
*smenu
= menu
->cascades
[menu
->entries
[MC_OPTIONS
]->cascade
];
360 buflen
= strlen(_("Set Shortcut")) + 16;
361 buffer
= wmalloc(buflen
);
363 for (i
= WO_ENTRIES
; i
< smenu
->entry_no
; i
++) {
365 int shortcutNo
= i
- WO_ENTRIES
;
366 WMenuEntry
*entry
= smenu
->entries
[i
];
367 WMArray
*shortSelWindows
= w_global
.shortcut
.windows
[shortcutNo
];
369 snprintf(buffer
, buflen
, "%s %i", _("Set Shortcut"), shortcutNo
+ 1);
371 if (!shortSelWindows
) {
372 entry
->flags
.indicator_on
= 0;
374 entry
->flags
.indicator_on
= 1;
375 if (WMCountInArray(shortSelWindows
, wwin
))
376 entry
->flags
.indicator_type
= MI_DIAMOND
;
378 entry
->flags
.indicator_type
= MI_CHECK
;
381 if (strcmp(buffer
, entry
->text
) != 0) {
383 entry
->text
= wstrdup(buffer
);
384 smenu
->flags
.realized
= 0;
387 kcode
= wKeyBindings
[WKBD_WINDOW1
+ shortcutNo
].keycode
;
390 if ((tmp
= GetShortcutKey(wKeyBindings
[WKBD_WINDOW1
+ shortcutNo
]))
391 && (!entry
->rtext
|| strcmp(tmp
, entry
->rtext
) != 0)) {
395 smenu
->flags
.realized
= 0;
397 wMenuSetEnabled(smenu
, i
, True
);
399 wMenuSetEnabled(smenu
, i
, False
);
403 smenu
->flags
.realized
= 0;
406 entry
->clientdata
= wwin
;
409 if (!smenu
->flags
.realized
)
413 static void updateOptionsMenu(WMenu
* menu
, WWindow
* wwin
)
415 WMenu
*smenu
= menu
->cascades
[menu
->entries
[MC_OPTIONS
]->cascade
];
417 /* keep on top check */
418 smenu
->entries
[WO_KEEP_ON_TOP
]->clientdata
= wwin
;
419 smenu
->entries
[WO_KEEP_ON_TOP
]->flags
.indicator_on
=
420 (wwin
->frame
->core
->stacking
->window_level
== WMFloatingLevel
) ? 1 : 0;
421 wMenuSetEnabled(smenu
, WO_KEEP_ON_TOP
, !wwin
->flags
.miniaturized
);
423 /* keep at bottom check */
424 smenu
->entries
[WO_KEEP_AT_BOTTOM
]->clientdata
= wwin
;
425 smenu
->entries
[WO_KEEP_AT_BOTTOM
]->flags
.indicator_on
=
426 (wwin
->frame
->core
->stacking
->window_level
== WMSunkenLevel
) ? 1 : 0;
427 wMenuSetEnabled(smenu
, WO_KEEP_AT_BOTTOM
, !wwin
->flags
.miniaturized
);
429 /* omnipresent check */
430 smenu
->entries
[WO_OMNIPRESENT
]->clientdata
= wwin
;
431 smenu
->entries
[WO_OMNIPRESENT
]->flags
.indicator_on
= IS_OMNIPRESENT(wwin
);
433 smenu
->flags
.realized
= 0;
437 static void updateMaximizeMenu(WMenu
* menu
, WWindow
* wwin
)
439 WMenu
*smenu
= menu
->cascades
[menu
->entries
[MC_OTHERMAX
]->cascade
];
442 for (i
= 0; i
< smenu
->entry_no
; i
++) {
443 smenu
->entries
[i
]->clientdata
= wwin
;
444 smenu
->entries
[i
]->rtext
= GetShortcutKey(wKeyBindings
[menu_maximize_entries
[i
].shortcut_idx
]);
447 smenu
->flags
.realized
= 0;
451 static WMenu
*makeWorkspaceMenu(WScreen
* scr
)
455 menu
= wMenuCreate(scr
, NULL
, False
);
457 wwarning(_("could not create submenu for window menu"));
461 updateWorkspaceMenu(menu
);
466 static WMenu
*makeMakeShortcutMenu(WMenu
*menu
)
470 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
472 entry
= wMenuAddCallback(menu
, "", makeShortcutCommand
, NULL
);
474 entry
->flags
.indicator
= 1;
480 static WMenu
*makeOptionsMenu(WScreen
* scr
)
485 menu
= wMenuCreate(scr
, NULL
, False
);
487 wwarning(_("could not create submenu for window menu"));
491 entry
= wMenuAddCallback(menu
, _("Keep on top"), execWindowOptionCommand
, NULL
);
492 entry
->flags
.indicator
= 1;
493 entry
->flags
.indicator_type
= MI_CHECK
;
495 entry
= wMenuAddCallback(menu
, _("Keep at bottom"), execWindowOptionCommand
, NULL
);
496 entry
->flags
.indicator
= 1;
497 entry
->flags
.indicator_type
= MI_CHECK
;
499 entry
= wMenuAddCallback(menu
, _("Omnipresent"), execWindowOptionCommand
, NULL
);
500 entry
->flags
.indicator
= 1;
501 entry
->flags
.indicator_type
= MI_CHECK
;
506 static WMenu
*makeMaximizeMenu(WScreen
* scr
)
511 menu
= wMenuCreate(scr
, NULL
, False
);
513 wwarning(_("could not create submenu for window menu"));
517 for (i
= 0; i
< wlengthof(menu_maximize_entries
); i
++)
518 wMenuAddCallback(menu
, _(menu_maximize_entries
[i
].label
), execMaximizeCommand
, NULL
);
523 static WMenu
*createWindowMenu(WScreen
* scr
)
528 menu
= wMenuCreate(scr
, NULL
, False
);
530 * Warning: If you make some change that affects the order of the
531 * entries, you must update the command enum in the top of
534 entry
= wMenuAddCallback(menu
, _("Maximize"), execMenuCommand
, NULL
);
536 entry
= wMenuAddCallback(menu
, _("Other maximization"), NULL
, NULL
);
537 wMenuEntrySetCascade(menu
, entry
, makeMaximizeMenu(scr
));
539 entry
= wMenuAddCallback(menu
, _("Miniaturize"), execMenuCommand
, NULL
);
541 entry
= wMenuAddCallback(menu
, _("Shade"), execMenuCommand
, NULL
);
543 entry
= wMenuAddCallback(menu
, _("Hide"), execMenuCommand
, NULL
);
545 entry
= wMenuAddCallback(menu
, _("Resize/Move"), execMenuCommand
, NULL
);
547 entry
= wMenuAddCallback(menu
, _("Select"), execMenuCommand
, NULL
);
549 entry
= wMenuAddCallback(menu
, _("Move To"), NULL
, NULL
);
550 w_global
.workspace
.submenu
= makeWorkspaceMenu(scr
);
551 if (w_global
.workspace
.submenu
)
552 wMenuEntrySetCascade(menu
, entry
, w_global
.workspace
.submenu
);
554 entry
= wMenuAddCallback(menu
, _("Attributes..."), execMenuCommand
, NULL
);
556 entry
= wMenuAddCallback(menu
, _("Options"), NULL
, NULL
);
557 wMenuEntrySetCascade(menu
, entry
, makeMakeShortcutMenu(makeOptionsMenu(scr
)));
559 entry
= wMenuAddCallback(menu
, _("Launch"), execMenuCommand
, NULL
);
561 entry
= wMenuAddCallback(menu
, _("Close"), execMenuCommand
, NULL
);
563 entry
= wMenuAddCallback(menu
, _("Kill"), execMenuCommand
, NULL
);
568 void CloseWindowMenu(WScreen
* scr
)
570 if (scr
->window_menu
) {
571 if (scr
->window_menu
->flags
.mapped
)
572 wMenuUnmap(scr
->window_menu
);
574 if (scr
->window_menu
->entries
[0]->clientdata
) {
575 WWindow
*wwin
= (WWindow
*) scr
->window_menu
->entries
[0]->clientdata
;
577 wwin
->flags
.menu_open_for_me
= 0;
579 scr
->window_menu
->entries
[0]->clientdata
= NULL
;
583 static void updateMenuForWindow(WMenu
* menu
, WWindow
* wwin
)
585 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
588 updateOptionsMenu(menu
, wwin
);
589 updateMaximizeMenu(menu
, wwin
);
591 updateMakeShortcutMenu(menu
, wwin
);
593 wMenuSetEnabled(menu
, MC_HIDE
, wapp
!= NULL
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
));
595 wMenuSetEnabled(menu
, MC_CLOSE
, (wwin
->protocols
.DELETE_WINDOW
&& !WFLAGP(wwin
, no_closable
)));
597 if (wwin
->flags
.miniaturized
) {
598 static char *text
= NULL
;
600 text
= _("Deminiaturize");
602 menu
->entries
[MC_MINIATURIZE
]->text
= text
;
604 static char *text
= NULL
;
606 text
= _("Miniaturize");
608 menu
->entries
[MC_MINIATURIZE
]->text
= text
;
611 wMenuSetEnabled(menu
, MC_MINIATURIZE
, !WFLAGP(wwin
, no_miniaturizable
));
613 if (wwin
->flags
.maximized
) {
614 static char *text
= NULL
;
616 text
= _("Unmaximize");
618 menu
->entries
[MC_MAXIMIZE
]->text
= text
;
619 updateUnmaximizeShortcut(menu
->entries
[MC_MAXIMIZE
], wwin
->flags
.maximized
);
621 static char *text
= NULL
;
623 text
= _("Maximize");
625 menu
->entries
[MC_MAXIMIZE
]->text
= text
;
626 menu
->entries
[MC_MAXIMIZE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MAXIMIZE
]);
628 wMenuSetEnabled(menu
, MC_MAXIMIZE
, IS_RESIZABLE(wwin
));
630 wMenuSetEnabled(menu
, MC_MOVERESIZE
, IS_RESIZABLE(wwin
)
631 && !wwin
->flags
.miniaturized
);
633 if (wwin
->flags
.shaded
) {
634 static char *text
= NULL
;
638 menu
->entries
[MC_SHADE
]->text
= text
;
640 static char *text
= NULL
;
644 menu
->entries
[MC_SHADE
]->text
= text
;
647 wMenuSetEnabled(menu
, MC_SHADE
, !WFLAGP(wwin
, no_shadeable
)
648 && !wwin
->flags
.miniaturized
);
650 if (wwin
->flags
.selected
) {
651 static char *text
= NULL
;
653 text
= _("Deselect");
655 menu
->entries
[MC_SELECT
]->text
= text
;
657 static char *text
= NULL
;
661 menu
->entries
[MC_SELECT
]->text
= text
;
664 wMenuSetEnabled(menu
, MC_DUMMY_MOVETO
, !IS_OMNIPRESENT(wwin
));
666 if (!wwin
->flags
.inspector_open
) {
667 wMenuSetEnabled(menu
, MC_PROPERTIES
, True
);
669 wMenuSetEnabled(menu
, MC_PROPERTIES
, False
);
672 /* Update shortcut labels except for (Un)Maximize which is
673 * handled separately.
675 menu
->entries
[MC_MINIATURIZE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MINIATURIZE
]);
676 menu
->entries
[MC_SHADE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_SHADE
]);
677 menu
->entries
[MC_HIDE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_HIDE
]);
678 menu
->entries
[MC_MOVERESIZE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_MOVERESIZE
]);
679 menu
->entries
[MC_SELECT
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_SELECT
]);
680 menu
->entries
[MC_RELAUNCH
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_RELAUNCH
]);
681 menu
->entries
[MC_CLOSE
]->rtext
= GetShortcutKey(wKeyBindings
[WKBD_CLOSE
]);
683 /* set the client data of the entries to the window */
684 for (i
= 0; i
< menu
->entry_no
; i
++) {
685 menu
->entries
[i
]->clientdata
= wwin
;
688 for (i
= 0; i
< w_global
.workspace
.submenu
->entry_no
; i
++) {
689 w_global
.workspace
.submenu
->entries
[i
]->clientdata
= wwin
;
691 if (i
== w_global
.workspace
.current
)
692 wMenuSetEnabled(w_global
.workspace
.submenu
, i
, False
);
694 wMenuSetEnabled(w_global
.workspace
.submenu
, i
, True
);
697 menu
->flags
.realized
= 0;
701 static WMenu
*open_window_menu_core(WWindow
*wwin
)
703 WScreen
*scr
= wwin
->screen_ptr
;
706 wwin
->flags
.menu_open_for_me
= 1;
708 if (!scr
->window_menu
) {
709 scr
->window_menu
= createWindowMenu(scr
);
711 /* hack to save some memory allocation/deallocation */
712 wfree(scr
->window_menu
->entries
[MC_MINIATURIZE
]->text
);
713 wfree(scr
->window_menu
->entries
[MC_MAXIMIZE
]->text
);
714 wfree(scr
->window_menu
->entries
[MC_SHADE
]->text
);
715 wfree(scr
->window_menu
->entries
[MC_SELECT
]->text
);
717 updateWorkspaceMenu(w_global
.workspace
.submenu
);
720 menu
= scr
->window_menu
;
721 if (menu
->flags
.mapped
) {
723 if (menu
->entries
[0]->clientdata
== wwin
)
727 updateMenuForWindow(menu
, wwin
);
732 static void prepare_menu_position(WMenu
*menu
, int *x
, int *y
)
736 rect
= wGetRectForHead(menu
->frame
->screen_ptr
,
737 wGetHeadForPointerLocation(menu
->frame
->screen_ptr
));
738 if (*x
< rect
.pos
.x
- menu
->frame
->core
->width
/ 2)
739 *x
= rect
.pos
.x
- menu
->frame
->core
->width
/ 2;
744 void OpenWindowMenu(WWindow
*wwin
, int x
, int y
, int keyboard
)
748 menu
= open_window_menu_core(wwin
);
752 /* Specific menu position */
753 x
-= menu
->frame
->core
->width
/ 2;
754 if (x
+ menu
->frame
->core
->width
> wwin
->frame_x
+ wwin
->frame
->core
->width
)
755 x
= wwin
->frame_x
+ wwin
->frame
->core
->width
- menu
->frame
->core
->width
;
756 if (x
< wwin
->frame_x
)
759 /* Common menu position */
760 prepare_menu_position(menu
, &x
, &y
);
762 if (!wwin
->flags
.internal_window
)
763 wMenuMapAt(menu
, x
, y
, keyboard
);
766 void OpenWindowMenu2(WWindow
*wwin
, int x
, int y
, int keyboard
)
771 menu
= open_window_menu_core(wwin
);
775 /* Specific menu position */
776 for (i
= 0; i
< w_global
.workspace
.submenu
->entry_no
; i
++) {
777 w_global
.workspace
.submenu
->entries
[i
]->clientdata
= wwin
;
778 wMenuSetEnabled(w_global
.workspace
.submenu
, i
, True
);
781 x
-= menu
->frame
->core
->width
/ 2;
783 /* Common menu position */
784 prepare_menu_position(menu
, &x
, &y
);
786 if (!wwin
->flags
.internal_window
)
787 wMenuMapAt(menu
, x
, y
, keyboard
);
790 void OpenMiniwindowMenu(WWindow
* wwin
, int x
, int y
)
794 menu
= open_window_menu_core(wwin
);
798 x
-= menu
->frame
->core
->width
/ 2;
800 wMenuMapAt(menu
, x
, y
, False
);
803 void DestroyWindowMenu(WScreen
*scr
)
805 if (scr
->window_menu
) {
806 scr
->window_menu
->entries
[MC_MINIATURIZE
]->text
= NULL
;
807 scr
->window_menu
->entries
[MC_MAXIMIZE
]->text
= NULL
;
808 scr
->window_menu
->entries
[MC_SHADE
]->text
= NULL
;
809 scr
->window_menu
->entries
[MC_SELECT
]->text
= NULL
;
810 wMenuDestroy(scr
->window_menu
, True
);
811 scr
->window_menu
= NULL
;