]>
Dogcows Code - chaz/openbox/blob - src/Windowmenu.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2 // Windowmenu.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
25 # include "../config.h"
26 #endif // HAVE_CONFIG_H
31 #endif // HAVE_STRING_H
35 #include "blackbox.hh"
38 #include "Windowmenu.hh"
39 #include "Workspace.hh"
42 Windowmenu::Windowmenu(BlackboxWindow
*win
) : Basemenu(win
->getScreen()) {
45 setTitleVisibility(False
);
49 sendToMenu
= new SendtoWorkspacemenu(this);
50 insert(i18n(WindowmenuSet
, WindowmenuSendTo
, "Send To ..."),
52 insert(i18n(WindowmenuSet
, WindowmenuShade
, "Shade"),
53 BScreen::WindowShade
);
54 insert(i18n(WindowmenuSet
, WindowmenuIconify
, "Iconify"),
55 BScreen::WindowIconify
);
56 insert(i18n(WindowmenuSet
, WindowmenuMaximize
, "Maximize"),
57 BScreen::WindowMaximize
);
58 insert(i18n(WindowmenuSet
, WindowmenuRaise
,"Raise"),
59 BScreen::WindowRaise
);
60 insert(i18n(WindowmenuSet
, WindowmenuLower
, "Lower"),
61 BScreen::WindowLower
);
62 insert(i18n(WindowmenuSet
, WindowmenuStick
, "Stick"),
63 BScreen::WindowStick
);
64 insert(i18n(WindowmenuSet
, WindowmenuKillClient
, "Kill Client"),
66 insert(i18n(WindowmenuSet
, WindowmenuClose
, "Close"),
67 BScreen::WindowClose
);
71 setItemEnabled(1, window
->hasTitlebar());
72 setItemEnabled(2, window
->isIconifiable());
73 setItemEnabled(3, window
->isMaximizable());
74 setItemEnabled(8, window
->isClosable());
78 Windowmenu::~Windowmenu(void) {
83 void Windowmenu::show(void) {
84 if (isItemEnabled(1)) setItemSelected(1, window
->isShaded());
85 if (isItemEnabled(3)) setItemSelected(3, window
->isMaximized());
86 if (isItemEnabled(6)) setItemSelected(6, window
->isStuck());
92 void Windowmenu::itemSelected(int button
, unsigned int index
) {
96 BasemenuItem
*item
= find(index
);
99 switch (item
->function()) {
100 case BScreen::WindowShade
:
104 case BScreen::WindowIconify
:
108 case BScreen::WindowMaximize
:
109 window
->maximize(1); // full maximize
112 case BScreen::WindowClose
:
116 case BScreen::WindowRaise
: {
117 Workspace
*wkspc
= getScreen()->getWorkspace(window
->getWorkspaceNumber());
118 wkspc
->raiseWindow(window
);
122 case BScreen::WindowLower
: {
123 Workspace
*wkspc
= getScreen()->getWorkspace(window
->getWorkspaceNumber());
124 wkspc
->lowerWindow(window
);
128 case BScreen::WindowStick
:
132 case BScreen::WindowKill
:
133 XKillClient(getScreen()->getBaseDisplay()->getXDisplay(),
134 window
->getClientWindow());
140 void Windowmenu::reconfigure(void) {
141 setItemEnabled(1, window
->hasTitlebar());
142 setItemEnabled(2, window
->isIconifiable());
143 setItemEnabled(3, window
->isMaximizable());
144 setItemEnabled(8, window
->isClosable());
146 sendToMenu
->reconfigure();
148 Basemenu::reconfigure();
152 Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu
*w
)
153 : Basemenu(w
->getScreen()) {
157 setTitleVisibility(False
);
164 void Windowmenu::SendtoWorkspacemenu::itemSelected(int button
,
165 unsigned int index
) {
166 if (button
> 2) return;
168 if (index
<= getScreen()->getWorkspaceCount()) {
169 if (index
== getScreen()->getCurrentWorkspaceID()) return;
170 if (window
->isStuck()) window
->stick();
172 if (button
== 1) window
->withdraw();
173 getScreen()->reassociateWindow(window
, index
, True
);
174 if (button
== 2) getScreen()->changeWorkspaceID(index
);
180 void Windowmenu::SendtoWorkspacemenu::update(void) {
181 unsigned int i
, r
= getCount(),
182 workspace_count
= getScreen()->getWorkspaceCount();
183 if (r
> workspace_count
) {
184 for (i
= r
; i
< workspace_count
; ++i
)
189 for (i
= 0; i
< workspace_count
; ++i
) {
190 if (r
< workspace_count
) {
191 insert(getScreen()->getWorkspace(i
)->getName());
194 changeItemLabel(i
, getScreen()->getWorkspace(i
)->getName());
195 setItemEnabled(i
, i
!= getScreen()->getCurrentWorkspaceID());
203 void Windowmenu::SendtoWorkspacemenu::show(void) {
This page took 0.043743 seconds and 4 git commands to generate.