1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* IceWM
*
* Copyright (C) 1997-2001 Marko Macek
*/
#include "config.h"
#ifdef CONFIG_WINMENU
#include "wmaction.h"
#include "ylib.h"
#include "ymenu.h"
#include "ymenuitem.h"
#include "yaction.h"
#include "sysdep.h"
#include "prefs.h"
#include "yicon.h"
#include "wmmgr.h"
#include "wmframe.h"
#include "wmwinmenu.h"
#include "intl.h"
class ActivateWindowMenuItem: public YMenuItem, public YAction {
public:
ActivateWindowMenuItem(YFrameWindow *frame):
YMenuItem(frame->getTitle(), -1, null, this, 0),
fFrame(frame)
{
#ifndef LITE
if (fFrame->clientIcon() != null)
setIcon(fFrame->clientIcon());
#endif
}
virtual void actionPerformed(YActionListener * /*listener*/, YAction * /*action*/, unsigned int modifiers) {
YFrameWindow *f = manager->topLayer();
while (f) {
if ((void *)f == fFrame) {
if (modifiers & ShiftMask)
f->wmOccupyOnlyWorkspace(manager->activeWorkspace());
manager->activate(f, true);
return ;
}
f = f->nextLayer();
}
}
private:
YFrameWindow *fFrame;
};
YMenu *YWindowManager::createWindowMenu(YMenu *menu, long workspace) {
if (!menu)
menu = new YMenu();
int level, levelCount, windowLevel, layerCount;
YFrameWindow *frame;
bool needSeparator = false;
/// !!! fix performance (smarter update, on change only)
for (int layer = 0 ; layer < WinLayerCount; layer++) {
layerCount = 0;
if (top(layer) == 0)
continue;
for (level = 0; level < 4; level++) {
levelCount = 0;
for (frame = top(layer); frame; frame = frame->next()) {
if (!frame->client()->adopted())
continue;
if (!frame->visibleOn(workspace))
continue;
#ifndef NO_WINDOW_OPTIONS
if (frame->frameOptions() & YFrameWindow::foIgnoreWinList)
continue;
#endif
if (workspace != activeWorkspace() &&
frame->visibleOn(activeWorkspace()))
continue;
windowLevel = 0;
if (frame->isHidden())
windowLevel = 3;
else if (frame->isMinimized())
windowLevel = 2;
else if (frame->isRollup())
windowLevel = 1;
if (level != windowLevel)
continue;
if ((levelCount == 0 && level > 0) ||
((layerCount == 0 && layer > 0) && needSeparator))
menu->addSeparator();
menu->add(new ActivateWindowMenuItem(frame));
levelCount++;
layerCount++;
needSeparator = true;
}
}
}
return menu;
}
WindowListMenu::WindowListMenu(IApp *app, YWindow *parent): YMenu(parent) {
this->app = app;
}
void WindowListMenu::updatePopup() {
removeAll();
manager->createWindowMenu(this, manager->activeWorkspace()); // !!! fix
bool first = true;
for (long d = 0; d < manager->workspaceCount(); d++) {
if (d == manager->activeWorkspace())
continue;
if (first) {
addSeparator();
first = false;
}
char s[50];
sprintf(s, _("%lu. Workspace %-.32s"), (unsigned long)(d + 1),
manager->workspaceName(d));
YMenu *sub = 0;
if (manager->windowCount(d) > 0) // !!! do lazy create menu instead
sub = manager->createWindowMenu(0, d);
addItem(s, (d < 10) ? 0 : -1, workspaceActionActivate[d], sub);
}
#ifdef CONFIG_WINLIST
addSeparator();
addItem(_("_Window list"), -2, KEY_NAME(gKeySysWindowList), actionWindowList);
#endif
}
#endif
|