Also allow relaunching from the window menu.
[wmaker-crm.git] / src / winmenu.c
blobef9712642845d794ca83daccc26908283e81f0fd
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.
22 #include "wconfig.h"
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <unistd.h>
27 #include <string.h>
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
32 #include "WindowMaker.h"
33 #include "actions.h"
34 #include "menu.h"
35 #include "funcs.h"
36 #include "window.h"
37 #include "client.h"
38 #include "application.h"
39 #include "keybind.h"
40 #include "framewin.h"
41 #include "workspace.h"
42 #include "winspector.h"
43 #include "dialog.h"
44 #include "stacking.h"
45 #include "icon.h"
46 #include "xinerama.h"
48 #define MC_MAXIMIZE 0
49 #define MC_MINIATURIZE 1
50 #define MC_SHADE 2
51 #define MC_HIDE 3
52 #define MC_MOVERESIZE 4
53 #define MC_SELECT 5
54 #define MC_DUMMY_MOVETO 6
55 #define MC_PROPERTIES 7
56 #define MC_OPTIONS 8
57 #define MC_SHORTCUT 8
58 #define MC_RELAUNCH 9
60 #define MC_CLOSE 10
61 #define MC_KILL 11
63 #define WO_KEEP_ON_TOP 0
64 #define WO_KEEP_AT_BOTTOM 1
65 #define WO_OMNIPRESENT 2
66 #define WO_ENTRIES 3
68 /**** Global data ***/
69 extern Time LastTimestamp;
70 extern Atom _XA_WM_DELETE_WINDOW;
71 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW;
73 extern WShortKey wKeyBindings[WKBD_LAST];
75 extern WPreferences wPreferences;
77 static void updateOptionsMenu(WMenu * menu, WWindow * wwin);
79 static void execWindowOptionCommand(WMenu * menu, WMenuEntry * entry)
81 WWindow *wwin = (WWindow *) entry->clientdata;
83 switch (entry->order) {
84 case WO_KEEP_ON_TOP:
85 if (wwin->frame->core->stacking->window_level != WMFloatingLevel)
86 ChangeStackingLevel(wwin->frame->core, WMFloatingLevel);
87 else
88 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
89 break;
91 case WO_KEEP_AT_BOTTOM:
92 if (wwin->frame->core->stacking->window_level != WMSunkenLevel)
93 ChangeStackingLevel(wwin->frame->core, WMSunkenLevel);
94 else
95 ChangeStackingLevel(wwin->frame->core, WMNormalLevel);
96 break;
98 case WO_OMNIPRESENT:
99 wWindowSetOmnipresent(wwin, !wwin->flags.omnipresent);
100 break;
104 static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
106 WWindow *wwin = (WWindow *) entry->clientdata;
107 WApplication *wapp;
109 CloseWindowMenu(menu->frame->screen_ptr);
111 switch (entry->order) {
112 case MC_CLOSE:
113 /* send delete message */
114 wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp);
115 break;
117 case MC_KILL:
118 wretain(wwin);
119 if (wPreferences.dont_confirm_kill
120 || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
122 ("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."),
123 _("Yes"), _("No"), NULL) == WAPRDefault) {
124 if (!wwin->flags.destroyed)
125 wClientKill(wwin);
127 wrelease(wwin);
128 break;
130 case MC_MINIATURIZE:
131 if (wwin->flags.miniaturized) {
132 wDeiconifyWindow(wwin);
133 } else {
134 if (wwin->protocols.MINIATURIZE_WINDOW) {
135 wClientSendProtocol(wwin, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW, LastTimestamp);
136 } else {
137 wIconifyWindow(wwin);
140 break;
142 case MC_MAXIMIZE:
143 if (wwin->flags.maximized)
144 wUnmaximizeWindow(wwin);
145 else
146 wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL);
147 break;
149 case MC_SHADE:
150 if (wwin->flags.shaded)
151 wUnshadeWindow(wwin);
152 else
153 wShadeWindow(wwin);
154 break;
156 case MC_SELECT:
157 if (!wwin->flags.miniaturized)
158 wSelectWindow(wwin, !wwin->flags.selected);
159 else
160 wIconSelect(wwin->icon);
161 break;
163 case MC_MOVERESIZE:
164 wKeyboardMoveResizeWindow(wwin);
165 break;
167 case MC_PROPERTIES:
168 wShowInspectorForWindow(wwin);
169 break;
171 case MC_RELAUNCH:
172 (void) RelaunchWindow(wwin);
173 break;
175 case MC_HIDE:
176 wapp = wApplicationOf(wwin->main_window);
177 wHideApplication(wapp);
178 break;
182 static void switchWSCommand(WMenu * menu, WMenuEntry * entry)
184 WWindow *wwin = (WWindow *) entry->clientdata;
186 wSelectWindow(wwin, False);
187 wWindowChangeWorkspace(wwin, entry->order);
190 static void makeShortcutCommand(WMenu * menu, WMenuEntry * entry)
192 WWindow *wwin = (WWindow *) entry->clientdata;
193 WScreen *scr = wwin->screen_ptr;
194 int index = entry->order - WO_ENTRIES;
196 if (scr->shortcutWindows[index]) {
197 WMFreeArray(scr->shortcutWindows[index]);
198 scr->shortcutWindows[index] = NULL;
201 if (wwin->flags.selected && scr->selected_windows) {
202 scr->shortcutWindows[index] = WMDuplicateArray(scr->selected_windows);
203 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
204 WMInsertInArray(scr->shortcutWindows[index], 0, wwin); */
205 } else {
206 scr->shortcutWindows[index] = WMCreateArray(4);
207 WMAddToArray(scr->shortcutWindows[index], wwin);
210 wSelectWindow(wwin, !wwin->flags.selected);
211 XFlush(dpy);
212 wusleep(3000);
213 wSelectWindow(wwin, !wwin->flags.selected);
214 XFlush(dpy);
217 static void updateWorkspaceMenu(WMenu * menu)
219 WScreen *scr = menu->frame->screen_ptr;
220 char title[MAX_WORKSPACENAME_WIDTH + 1];
221 int i;
223 for (i = 0; i < scr->workspace_count; i++) {
224 if (i < menu->entry_no) {
225 if (strcmp(menu->entries[i]->text, scr->workspaces[i]->name) != 0) {
226 wfree(menu->entries[i]->text);
227 strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH);
228 title[MAX_WORKSPACENAME_WIDTH] = 0;
229 menu->entries[i]->text = wstrdup(title);
230 menu->flags.realized = 0;
232 } else {
233 strncpy(title, scr->workspaces[i]->name, MAX_WORKSPACENAME_WIDTH);
234 title[MAX_WORKSPACENAME_WIDTH] = 0;
236 wMenuAddCallback(menu, title, switchWSCommand, NULL);
238 menu->flags.realized = 0;
242 if (!menu->flags.realized)
243 wMenuRealize(menu);
246 static char *getShortcutString(WShortKey key)
248 char *tmp = NULL;
249 char *k = XKeysymToString(XKeycodeToKeysym(dpy, key.keycode, 0));
250 if (!k) return NULL;
252 char **m = wPreferences.modifier_labels;
253 if (key.modifier & ControlMask) tmp = wstrappend(tmp, m[1] ? m[1] : "Ctrl+");
254 if (key.modifier & ShiftMask) tmp = wstrappend(tmp, m[0] ? m[0] : "Shift+");
255 if (key.modifier & Mod1Mask) tmp = wstrappend(tmp, m[2] ? m[2] : "Mod1+");
256 if (key.modifier & Mod2Mask) tmp = wstrappend(tmp, m[3] ? m[3] : "Mod2+");
257 if (key.modifier & Mod3Mask) tmp = wstrappend(tmp, m[4] ? m[4] : "Mod3+");
258 if (key.modifier & Mod4Mask) tmp = wstrappend(tmp, m[5] ? m[5] : "Mod4+");
259 if (key.modifier & Mod5Mask) tmp = wstrappend(tmp, m[6] ? m[6] : "Mod5+");
260 tmp = wstrappend(tmp, k);
262 return tmp;
265 static void updateMakeShortcutMenu(WMenu * menu, WWindow * wwin)
267 WMenu *smenu = menu->cascades[menu->entries[MC_SHORTCUT]->cascade];
268 int i;
269 char *buffer;
270 int buflen;
271 KeyCode kcode;
273 if (!smenu)
274 return;
276 buflen = strlen(_("Set Shortcut")) + 16;
277 buffer = wmalloc(buflen);
279 for (i = WO_ENTRIES; i < smenu->entry_no; i++) {
280 char *tmp;
281 int shortcutNo = i - WO_ENTRIES;
282 WMenuEntry *entry = smenu->entries[i];
283 WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];
285 snprintf(buffer, buflen, "%s %i", _("Set Shortcut"), shortcutNo + 1);
287 if (!shortSelWindows) {
288 entry->flags.indicator_on = 0;
289 } else {
290 entry->flags.indicator_on = 1;
291 if (WMCountInArray(shortSelWindows, wwin))
292 entry->flags.indicator_type = MI_DIAMOND;
293 else
294 entry->flags.indicator_type = MI_CHECK;
297 if (strcmp(buffer, entry->text) != 0) {
298 wfree(entry->text);
299 entry->text = wstrdup(buffer);
300 smenu->flags.realized = 0;
303 kcode = wKeyBindings[WKBD_WINDOW1 + shortcutNo].keycode;
305 if (kcode) {
306 if ((tmp = getShortcutString(wKeyBindings[WKBD_WINDOW1 + shortcutNo]))
307 && (!entry->rtext || strcmp(tmp, entry->rtext) != 0)) {
308 if (entry->rtext)
309 wfree(entry->rtext);
310 entry->rtext = tmp;
311 smenu->flags.realized = 0;
313 wMenuSetEnabled(smenu, i, True);
314 } else {
315 wMenuSetEnabled(smenu, i, False);
316 if (entry->rtext) {
317 wfree(entry->rtext);
318 entry->rtext = NULL;
319 smenu->flags.realized = 0;
322 entry->clientdata = wwin;
324 wfree(buffer);
325 if (!smenu->flags.realized)
326 wMenuRealize(smenu);
329 static void updateOptionsMenu(WMenu * menu, WWindow * wwin)
331 WMenu *smenu = menu->cascades[menu->entries[MC_OPTIONS]->cascade];
333 /* keep on top check */
334 smenu->entries[WO_KEEP_ON_TOP]->clientdata = wwin;
335 smenu->entries[WO_KEEP_ON_TOP]->flags.indicator_on =
336 (wwin->frame->core->stacking->window_level == WMFloatingLevel) ? 1 : 0;
337 wMenuSetEnabled(smenu, WO_KEEP_ON_TOP, !wwin->flags.miniaturized);
339 /* keep at bottom check */
340 smenu->entries[WO_KEEP_AT_BOTTOM]->clientdata = wwin;
341 smenu->entries[WO_KEEP_AT_BOTTOM]->flags.indicator_on =
342 (wwin->frame->core->stacking->window_level == WMSunkenLevel) ? 1 : 0;
343 wMenuSetEnabled(smenu, WO_KEEP_AT_BOTTOM, !wwin->flags.miniaturized);
345 /* omnipresent check */
346 smenu->entries[WO_OMNIPRESENT]->clientdata = wwin;
347 smenu->entries[WO_OMNIPRESENT]->flags.indicator_on = IS_OMNIPRESENT(wwin);
349 smenu->flags.realized = 0;
350 wMenuRealize(smenu);
353 static WMenu *makeWorkspaceMenu(WScreen * scr)
355 WMenu *menu;
357 menu = wMenuCreate(scr, NULL, False);
358 if (!menu) {
359 wwarning(_("could not create submenu for window menu"));
360 return NULL;
363 updateWorkspaceMenu(menu);
365 return menu;
368 static WMenu *makeMakeShortcutMenu(WScreen * scr, WMenu * menu)
371 WMenu *menu;
373 int i;
375 menu = wMenuCreate(scr, NULL, False);
376 if (!menu) {
377 wwarning(_("could not create submenu for window menu"));
378 return NULL;
382 for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
383 WMenuEntry *entry;
384 entry = wMenuAddCallback(menu, "", makeShortcutCommand, NULL);
386 entry->flags.indicator = 1;
389 return menu;
392 static WMenu *makeOptionsMenu(WScreen * scr)
394 WMenu *menu;
395 WMenuEntry *entry;
397 menu = wMenuCreate(scr, NULL, False);
398 if (!menu) {
399 wwarning(_("could not create submenu for window menu"));
400 return NULL;
403 entry = wMenuAddCallback(menu, _("Keep on top"), execWindowOptionCommand, NULL);
404 entry->flags.indicator = 1;
405 entry->flags.indicator_type = MI_CHECK;
407 entry = wMenuAddCallback(menu, _("Keep at bottom"), execWindowOptionCommand, NULL);
408 entry->flags.indicator = 1;
409 entry->flags.indicator_type = MI_CHECK;
411 entry = wMenuAddCallback(menu, _("Omnipresent"), execWindowOptionCommand, NULL);
412 entry->flags.indicator = 1;
413 entry->flags.indicator_type = MI_CHECK;
415 return menu;
418 static WMenu *createWindowMenu(WScreen * scr)
420 WMenu *menu;
421 WMenuEntry *entry;
423 menu = wMenuCreate(scr, NULL, False);
425 * Warning: If you make some change that affects the order of the
426 * entries, you must update the command #defines in the top of
427 * this file.
429 entry = wMenuAddCallback(menu, _("Maximize"), execMenuCommand, NULL);
430 entry->rtext = getShortcutString(wKeyBindings[WKBD_MAXIMIZE]);
432 entry = wMenuAddCallback(menu, _("Miniaturize"), execMenuCommand, NULL);
433 entry->rtext = getShortcutString(wKeyBindings[WKBD_MINIATURIZE]);
435 entry = wMenuAddCallback(menu, _("Shade"), execMenuCommand, NULL);
436 entry->rtext = getShortcutString(wKeyBindings[WKBD_SHADE]);
438 entry = wMenuAddCallback(menu, _("Hide"), execMenuCommand, NULL);
439 entry->rtext = getShortcutString(wKeyBindings[WKBD_HIDE]);
441 entry = wMenuAddCallback(menu, _("Resize/Move"), execMenuCommand, NULL);
442 entry->rtext = getShortcutString(wKeyBindings[WKBD_MOVERESIZE]);
444 entry = wMenuAddCallback(menu, _("Select"), execMenuCommand, NULL);
445 entry->rtext = getShortcutString(wKeyBindings[WKBD_SELECT]);
447 entry = wMenuAddCallback(menu, _("Move To"), NULL, NULL);
448 scr->workspace_submenu = makeWorkspaceMenu(scr);
449 if (scr->workspace_submenu)
450 wMenuEntrySetCascade(menu, entry, scr->workspace_submenu);
452 entry = wMenuAddCallback(menu, _("Attributes..."), execMenuCommand, NULL);
454 entry = wMenuAddCallback(menu, _("Options"), NULL, NULL);
455 wMenuEntrySetCascade(menu, entry, makeMakeShortcutMenu(scr, makeOptionsMenu(scr)));
458 entry = wMenuAddCallback(menu, _("Select Shortcut"), NULL, NULL);
459 wMenuEntrySetCascade(menu, entry, makeMakeShortcutMenu(scr));
462 entry = wMenuAddCallback(menu, _("Launch"), execMenuCommand, NULL);
463 entry->rtext = getShortcutString(wKeyBindings[WKBD_RELAUNCH]);
465 entry = wMenuAddCallback(menu, _("Close"), execMenuCommand, NULL);
466 entry->rtext = getShortcutString(wKeyBindings[WKBD_CLOSE]);
468 entry = wMenuAddCallback(menu, _("Kill"), execMenuCommand, NULL);
470 return menu;
473 void CloseWindowMenu(WScreen * scr)
475 if (scr->window_menu) {
476 if (scr->window_menu->flags.mapped)
477 wMenuUnmap(scr->window_menu);
479 if (scr->window_menu->entries[0]->clientdata) {
480 WWindow *wwin = (WWindow *) scr->window_menu->entries[0]->clientdata;
482 wwin->flags.menu_open_for_me = 0;
484 scr->window_menu->entries[0]->clientdata = NULL;
488 static void updateMenuForWindow(WMenu * menu, WWindow * wwin)
490 WApplication *wapp = wApplicationOf(wwin->main_window);
491 WScreen *scr = wwin->screen_ptr;
492 int i;
494 updateOptionsMenu(menu, wwin);
496 updateMakeShortcutMenu(menu, wwin);
498 wMenuSetEnabled(menu, MC_HIDE, wapp != NULL && !WFLAGP(wapp->main_window_desc, no_appicon));
500 wMenuSetEnabled(menu, MC_CLOSE, (wwin->protocols.DELETE_WINDOW && !WFLAGP(wwin, no_closable)));
502 if (wwin->flags.miniaturized) {
503 static char *text = NULL;
504 if (!text)
505 text = _("Deminiaturize");
507 menu->entries[MC_MINIATURIZE]->text = text;
508 } else {
509 static char *text = NULL;
510 if (!text)
511 text = _("Miniaturize");
513 menu->entries[MC_MINIATURIZE]->text = text;
516 wMenuSetEnabled(menu, MC_MINIATURIZE, !WFLAGP(wwin, no_miniaturizable));
518 if (wwin->flags.maximized) {
519 static char *text = NULL;
520 if (!text)
521 text = _("Unmaximize");
523 menu->entries[MC_MAXIMIZE]->text = text;
524 } else {
525 static char *text = NULL;
526 if (!text)
527 text = _("Maximize");
529 menu->entries[MC_MAXIMIZE]->text = text;
531 wMenuSetEnabled(menu, MC_MAXIMIZE, IS_RESIZABLE(wwin));
533 wMenuSetEnabled(menu, MC_MOVERESIZE, IS_RESIZABLE(wwin)
534 && !wwin->flags.miniaturized);
536 if (wwin->flags.shaded) {
537 static char *text = NULL;
538 if (!text)
539 text = _("Unshade");
541 menu->entries[MC_SHADE]->text = text;
542 } else {
543 static char *text = NULL;
544 if (!text)
545 text = _("Shade");
547 menu->entries[MC_SHADE]->text = text;
550 wMenuSetEnabled(menu, MC_SHADE, !WFLAGP(wwin, no_shadeable)
551 && !wwin->flags.miniaturized);
553 wMenuSetEnabled(menu, MC_DUMMY_MOVETO, !IS_OMNIPRESENT(wwin));
555 if (!wwin->flags.inspector_open) {
556 wMenuSetEnabled(menu, MC_PROPERTIES, True);
557 } else {
558 wMenuSetEnabled(menu, MC_PROPERTIES, False);
561 /* set the client data of the entries to the window */
562 for (i = 0; i < menu->entry_no; i++) {
563 menu->entries[i]->clientdata = wwin;
566 for (i = 0; i < scr->workspace_submenu->entry_no; i++) {
567 scr->workspace_submenu->entries[i]->clientdata = wwin;
568 if (i == scr->current_workspace) {
569 wMenuSetEnabled(scr->workspace_submenu, i, False);
570 } else {
571 wMenuSetEnabled(scr->workspace_submenu, i, True);
575 menu->flags.realized = 0;
576 wMenuRealize(menu);
579 void OpenWindowMenu(WWindow * wwin, int x, int y, int keyboard)
581 WMenu *menu;
582 WScreen *scr = wwin->screen_ptr;
583 WMRect rect;
585 wwin->flags.menu_open_for_me = 1;
587 if (!scr->window_menu) {
588 scr->window_menu = createWindowMenu(scr);
590 /* hack to save some memory allocation/deallocation */
591 wfree(scr->window_menu->entries[MC_MINIATURIZE]->text);
592 wfree(scr->window_menu->entries[MC_MAXIMIZE]->text);
593 wfree(scr->window_menu->entries[MC_SHADE]->text);
594 } else {
595 updateWorkspaceMenu(scr->workspace_submenu);
598 menu = scr->window_menu;
599 if (menu->flags.mapped) {
600 wMenuUnmap(menu);
601 if (menu->entries[0]->clientdata == wwin) {
602 return;
606 updateMenuForWindow(menu, wwin);
608 x -= menu->frame->core->width / 2;
609 if (x + menu->frame->core->width > wwin->frame_x + wwin->frame->core->width)
610 x = wwin->frame_x + wwin->frame->core->width - menu->frame->core->width;
611 if (x < wwin->frame_x)
612 x = wwin->frame_x;
614 rect = wGetRectForHead(menu->frame->screen_ptr,
615 wGetHeadForPointerLocation(menu->frame->screen_ptr));
616 if (x < rect.pos.x - menu->frame->core->width / 2)
617 x = rect.pos.x - menu->frame->core->width / 2;
618 if (y < rect.pos.y)
619 y = rect.pos.y;
621 if (!wwin->flags.internal_window)
622 wMenuMapAt(menu, x, y, keyboard);
625 void OpenWindowMenu2(WWindow *wwin, int x, int y, int keyboard)
627 int i;
628 WMenu *menu;
629 WScreen *scr = wwin->screen_ptr;
630 WMRect rect;
632 wwin->flags.menu_open_for_me = 1;
634 if (!scr->window_menu) {
635 scr->window_menu = createWindowMenu(scr);
637 /* hack to save some memory allocation/deallocation */
638 wfree(scr->window_menu->entries[MC_MINIATURIZE]->text);
639 wfree(scr->window_menu->entries[MC_MAXIMIZE]->text);
640 wfree(scr->window_menu->entries[MC_SHADE]->text);
641 } else {
642 updateWorkspaceMenu(scr->workspace_submenu);
645 menu = scr->window_menu;
646 if (menu->flags.mapped) {
647 wMenuUnmap(menu);
648 if (menu->entries[0]->clientdata == wwin) {
649 return;
653 updateMenuForWindow(menu, wwin);
655 for (i = 0; i < scr->workspace_submenu->entry_no; i++) {
656 scr->workspace_submenu->entries[i]->clientdata = wwin;
657 wMenuSetEnabled(scr->workspace_submenu, i, True);
660 x -= menu->frame->core->width / 2;
662 rect = wGetRectForHead(menu->frame->screen_ptr,
663 wGetHeadForPointerLocation(menu->frame->screen_ptr));
664 if (x < rect.pos.x - menu->frame->core->width / 2)
665 x = rect.pos.x - menu->frame->core->width / 2;
666 if (y < rect.pos.y)
667 y = rect.pos.y;
669 if (!wwin->flags.internal_window)
670 wMenuMapAt(menu, x, y, keyboard);
673 void OpenMiniwindowMenu(WWindow * wwin, int x, int y)
675 WMenu *menu;
676 WScreen *scr = wwin->screen_ptr;
678 wwin->flags.menu_open_for_me = 1;
680 if (!scr->window_menu) {
681 scr->window_menu = createWindowMenu(scr);
683 /* hack to save some memory allocation/deallocation */
684 wfree(scr->window_menu->entries[MC_MINIATURIZE]->text);
685 wfree(scr->window_menu->entries[MC_MAXIMIZE]->text);
686 wfree(scr->window_menu->entries[MC_SHADE]->text);
687 } else {
688 updateWorkspaceMenu(scr->workspace_submenu);
691 menu = scr->window_menu;
692 if (menu->flags.mapped) {
693 wMenuUnmap(menu);
694 if (menu->entries[0]->clientdata == wwin) {
695 return;
699 updateMenuForWindow(menu, wwin);
701 x -= menu->frame->core->width / 2;
703 wMenuMapAt(menu, x, y, False);
706 void DestroyWindowMenu(WScreen *scr)
708 if (scr->window_menu) {
709 scr->window_menu->entries[MC_MINIATURIZE]->text = NULL;
710 scr->window_menu->entries[MC_MAXIMIZE]->text = NULL;
711 scr->window_menu->entries[MC_SHADE]->text = NULL;
712 wMenuDestroy(scr->window_menu, True);
713 scr->window_menu = NULL;