1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Configmenu.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
29 #include "Configmenu.hh"
35 Configmenu::Configmenu(BScreen
*scr
) : Basemenu(scr
) {
36 setLabel(i18n(ConfigmenuSet
, ConfigmenuConfigOptions
, "Config options"));
39 focusmenu
= new Focusmenu(this);
40 placementmenu
= new Placementmenu(this);
42 insert(i18n(ConfigmenuSet
, ConfigmenuFocusModel
,
43 "Focus Model"), focusmenu
);
44 insert(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
,
45 "Window Placement"), placementmenu
);
46 insert(i18n(ConfigmenuSet
, ConfigmenuImageDithering
,
47 "Image Dithering"), 1);
48 insert(i18n(ConfigmenuSet
, ConfigmenuOpaqueMove
,
49 "Opaque Window Moving"), 2);
50 insert(i18n(ConfigmenuSet
, ConfigmenuFullMax
,
51 "Full Maximization"), 3);
52 insert(i18n(ConfigmenuSet
, ConfigmenuFocusNew
,
53 "Focus New Windows"), 4);
54 insert(i18n(ConfigmenuSet
, ConfigmenuFocusLast
,
55 "Focus Last Window on Workspace"), 5);
58 setItemSelected(2, getScreen()->getImageControl()->doDither());
59 setItemSelected(3, getScreen()->doOpaqueMove());
60 setItemSelected(4, getScreen()->doFullMax());
61 setItemSelected(5, getScreen()->doFocusNew());
62 setItemSelected(6, getScreen()->doFocusLast());
65 Configmenu::~Configmenu(void) {
70 void Configmenu::itemSelected(int button
, unsigned int index
) {
74 BasemenuItem
*item
= find(index
);
76 if (!item
->function())
79 switch(item
->function()) {
81 getScreen()->getImageControl()->
82 setDither((! getScreen()->getImageControl()->doDither()));
84 setItemSelected(index
, getScreen()->getImageControl()->doDither());
89 case 2: { // opaque move
90 getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove()));
92 setItemSelected(index
, getScreen()->doOpaqueMove());
97 case 3: { // full maximization
98 getScreen()->saveFullMax((! getScreen()->doFullMax()));
100 setItemSelected(index
, getScreen()->doFullMax());
104 case 4: { // focus new windows
105 getScreen()->saveFocusNew((! getScreen()->doFocusNew()));
107 setItemSelected(index
, getScreen()->doFocusNew());
111 case 5: { // focus last window on workspace
112 getScreen()->saveFocusLast((! getScreen()->doFocusLast()));
113 setItemSelected(index
, getScreen()->doFocusLast());
120 void Configmenu::reconfigure(void) {
121 focusmenu
->reconfigure();
122 placementmenu
->reconfigure();
124 Basemenu::reconfigure();
128 Configmenu::Focusmenu::Focusmenu(Configmenu
*cm
) : Basemenu(cm
->getScreen()) {
129 setLabel(i18n(ConfigmenuSet
, ConfigmenuFocusModel
, "Focus Model"));
132 insert(i18n(ConfigmenuSet
, ConfigmenuClickToFocus
, "Click To Focus"), 1);
133 insert(i18n(ConfigmenuSet
, ConfigmenuSloppyFocus
, "Sloppy Focus"), 2);
134 insert(i18n(ConfigmenuSet
, ConfigmenuAutoRaise
, "Auto Raise"), 3);
135 insert(i18n(ConfigmenuSet
, ConfigmenuClickRaise
, "Click Raise"), 4);
138 setItemSelected(0, (! getScreen()->isSloppyFocus()));
139 setItemSelected(1, getScreen()->isSloppyFocus());
140 setItemEnabled(2, getScreen()->isSloppyFocus());
141 setItemSelected(2, getScreen()->doAutoRaise());
142 setItemEnabled(3, getScreen()->isSloppyFocus());
143 setItemSelected(3, getScreen()->doClickRaise());
147 void Configmenu::Focusmenu::itemSelected(int button
, unsigned int index
) {
151 BasemenuItem
*item
= find(index
);
153 if (!item
->function())
156 switch (item
->function()) {
157 case 1: // click to focus
158 getScreen()->toggleFocusModel(BScreen::ClickToFocus
);
161 case 2: // sloppy focus
162 getScreen()->toggleFocusModel(BScreen::SloppyFocus
);
165 case 3: // auto raise with sloppy focus
166 getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
169 case 4: // click raise with sloppy focus
170 getScreen()->saveClickRaise(! getScreen()->doClickRaise());
171 getScreen()->updateFocusModel();
175 setItemSelected(0, (! getScreen()->isSloppyFocus()));
176 setItemSelected(1, getScreen()->isSloppyFocus());
177 setItemEnabled(2, getScreen()->isSloppyFocus());
178 setItemSelected(2, getScreen()->doAutoRaise());
179 setItemEnabled(3, getScreen()->isSloppyFocus());
180 setItemSelected(3, getScreen()->doClickRaise());
184 Configmenu::Placementmenu::Placementmenu(Configmenu
*cm
):
185 Basemenu(cm
->getScreen()) {
186 setLabel(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
, "Window Placement"));
189 insert(i18n(ConfigmenuSet
, ConfigmenuSmartRows
, "Smart Placement (Rows)"),
190 BScreen::RowSmartPlacement
);
191 insert(i18n(ConfigmenuSet
, ConfigmenuSmartCols
, "Smart Placement (Columns)"),
192 BScreen::ColSmartPlacement
);
193 insert(i18n(ConfigmenuSet
, ConfigmenuCascade
, "Cascade Placement"),
194 BScreen::CascadePlacement
);
195 insert(i18n(ConfigmenuSet
, ConfigmenuLeftRight
, "Left to Right"),
197 insert(i18n(ConfigmenuSet
, ConfigmenuRightLeft
, "Right to Left"),
199 insert(i18n(ConfigmenuSet
, ConfigmenuTopBottom
, "Top to Bottom"),
201 insert(i18n(ConfigmenuSet
, ConfigmenuBottomTop
, "Bottom to Top"),
205 switch (getScreen()->getPlacementPolicy()) {
206 case BScreen::RowSmartPlacement
:
207 setItemSelected(0, True
);
210 case BScreen::ColSmartPlacement
:
211 setItemSelected(1, True
);
214 case BScreen::CascadePlacement
:
215 setItemSelected(2, True
);
219 bool rl
= (getScreen()->getRowPlacementDirection() ==
221 tb
= (getScreen()->getColPlacementDirection() ==
224 setItemSelected(3, rl
);
225 setItemSelected(4, ! rl
);
227 setItemSelected(5, tb
);
228 setItemSelected(6, ! tb
);
232 void Configmenu::Placementmenu::itemSelected(int button
, unsigned int index
) {
236 BasemenuItem
*item
= find(index
);
238 if (!item
->function())
241 switch (item
->function()) {
242 case BScreen::RowSmartPlacement
:
243 getScreen()->savePlacementPolicy(item
->function());
245 setItemSelected(0, True
);
246 setItemSelected(1, False
);
247 setItemSelected(2, False
);
251 case BScreen::ColSmartPlacement
:
252 getScreen()->savePlacementPolicy(item
->function());
254 setItemSelected(0, False
);
255 setItemSelected(1, True
);
256 setItemSelected(2, False
);
260 case BScreen::CascadePlacement
:
261 getScreen()->savePlacementPolicy(item
->function());
263 setItemSelected(0, False
);
264 setItemSelected(1, False
);
265 setItemSelected(2, True
);
269 case BScreen::LeftRight
:
270 getScreen()->saveRowPlacementDirection(BScreen::LeftRight
);
272 setItemSelected(3, True
);
273 setItemSelected(4, False
);
277 case BScreen::RightLeft
:
278 getScreen()->saveRowPlacementDirection(BScreen::RightLeft
);
280 setItemSelected(3, False
);
281 setItemSelected(4, True
);
285 case BScreen::TopBottom
:
286 getScreen()->saveColPlacementDirection(BScreen::TopBottom
);
288 setItemSelected(5, True
);
289 setItemSelected(6, False
);
293 case BScreen::BottomTop
:
294 getScreen()->saveColPlacementDirection(BScreen::BottomTop
);
296 setItemSelected(5, False
);
297 setItemSelected(6, True
);