]>
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
) {
93 BasemenuItem
*item
= find(index
);
96 switch (item
->function()) {
97 case BScreen::WindowShade
:
101 case BScreen::WindowIconify
:
105 case BScreen::WindowMaximize
:
106 window
->maximize(button
);
109 case BScreen::WindowClose
:
113 case BScreen::WindowRaise
: {
114 Workspace
*wkspc
= getScreen()->getWorkspace(window
->getWorkspaceNumber());
115 wkspc
->raiseWindow(window
);
119 case BScreen::WindowLower
: {
120 Workspace
*wkspc
= getScreen()->getWorkspace(window
->getWorkspaceNumber());
121 wkspc
->lowerWindow(window
);
125 case BScreen::WindowStick
:
129 case BScreen::WindowKill
:
130 XKillClient(getScreen()->getBaseDisplay()->getXDisplay(),
131 window
->getClientWindow());
137 void Windowmenu::reconfigure(void) {
138 setItemEnabled(1, window
->hasTitlebar());
139 setItemEnabled(2, window
->isIconifiable());
140 setItemEnabled(3, window
->isMaximizable());
141 setItemEnabled(8, window
->isClosable());
143 sendToMenu
->reconfigure();
145 Basemenu::reconfigure();
149 Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu
*w
)
150 : Basemenu(w
->getScreen()) {
154 setTitleVisibility(False
);
161 void Windowmenu::SendtoWorkspacemenu::itemSelected(int button
,
162 unsigned int index
) {
163 if (button
> 2) return;
165 if (index
<= getScreen()->getWorkspaceCount()) {
166 if (index
== getScreen()->getCurrentWorkspaceID()) return;
167 if (window
->isStuck()) window
->stick();
169 if (button
== 1) window
->withdraw();
170 getScreen()->reassociateWindow(window
, index
, True
);
171 if (button
== 2) getScreen()->changeWorkspaceID(index
);
177 void Windowmenu::SendtoWorkspacemenu::update(void) {
178 unsigned int i
, r
= getCount(),
179 workspace_count
= getScreen()->getWorkspaceCount();
180 if (r
> workspace_count
) {
181 for (i
= r
; i
< workspace_count
; ++i
)
186 for (i
= 0; i
< workspace_count
; ++i
) {
187 if (r
< workspace_count
) {
188 insert(getScreen()->getWorkspace(i
)->getName());
191 changeItemLabel(i
, getScreen()->getWorkspace(i
)->getName());
199 void Windowmenu::SendtoWorkspacemenu::show(void) {
This page took 0.046091 seconds and 4 git commands to generate.