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);
41 windowsnapmenu
= new WindowToWindowSnapmenu(this);
42 edgesnapmenu
= new WindowToEdgeSnapmenu(this);
44 xineramamenu
= new Xineramamenu(this);
47 insert(i18n(ConfigmenuSet
, ConfigmenuFocusModel
,
48 "Focus Model"), focusmenu
);
49 insert(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
,
50 "Window Placement"), placementmenu
);
51 insert(i18n(ConfigmenuSet
, ConfigmenuWindowToWindowSnap
,
52 "Window-To-Window Snapping"), windowsnapmenu
);
53 insert(i18n(ConfigmenuSet
, ConfigmenuWindowToEdgeSnap
,
54 "Window-To-Edge Snapping"), edgesnapmenu
);
56 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaSupport
,
57 "XineramaSupport"), xineramamenu
);
59 insert(i18n(ConfigmenuSet
, ConfigmenuImageDithering
,
60 "Image Dithering"), 1);
61 insert(i18n(ConfigmenuSet
, ConfigmenuOpaqueMove
,
62 "Opaque Window Moving"), 2);
63 insert(i18n(ConfigmenuSet
, ConfigmenuWorkspaceWarping
,
64 "Workspace Warping"), 3);
65 insert(i18n(ConfigmenuSet
, ConfigmenuFullMax
,
66 "Full Maximization"), 4);
67 insert(i18n(ConfigmenuSet
, ConfigmenuFocusNew
,
68 "Focus New Windows"), 5);
69 insert(i18n(ConfigmenuSet
, ConfigmenuFocusLast
,
70 "Focus Last Window on Workspace"), 6);
71 insert(i18n(ConfigmenuSet
, ConfigmenuDisableBindings
,
72 "Disable Mouse with Scroll Lock"), 7);
73 insert(i18n(ConfigmenuSet
, ConfigmenuHideToolbar
,
80 void Configmenu::setValues(void) {
85 setItemSelected(index
++, getScreen()->doImageDither());
86 setItemSelected(index
++, getScreen()->doOpaqueMove());
87 setItemSelected(index
++, getScreen()->doWorkspaceWarping());
88 setItemSelected(index
++, getScreen()->doFullMax());
89 setItemSelected(index
++, getScreen()->doFocusNew());
90 setItemSelected(index
++, getScreen()->doFocusLast());
91 setItemSelected(index
++, getScreen()->allowScrollLock());
92 setItemSelected(index
++, getScreen()->doHideToolbar());
96 Configmenu::~Configmenu(void) {
99 delete windowsnapmenu
;
107 void Configmenu::itemSelected(int button
, unsigned int index
) {
111 BasemenuItem
*item
= find(index
);
113 if (! item
->function())
116 switch(item
->function()) {
118 getScreen()->saveImageDither(! getScreen()->doImageDither());
119 setItemSelected(index
, getScreen()->doImageDither());
122 case 2: // opaque move
123 getScreen()->saveOpaqueMove(! getScreen()->doOpaqueMove());
124 setItemSelected(index
, getScreen()->doOpaqueMove());
127 case 3: // workspace wrapping
128 getScreen()->saveWorkspaceWarping(! getScreen()->doWorkspaceWarping());
129 setItemSelected(index
, getScreen()->doWorkspaceWarping());
132 case 4: // full maximization
133 getScreen()->saveFullMax(! getScreen()->doFullMax());
134 setItemSelected(index
, getScreen()->doFullMax());
137 case 5: // focus new windows
138 getScreen()->saveFocusNew(! getScreen()->doFocusNew());
139 setItemSelected(index
, getScreen()->doFocusNew());
142 case 6: // focus last window on workspace
143 getScreen()->saveFocusLast(! getScreen()->doFocusLast());
144 setItemSelected(index
, getScreen()->doFocusLast());
147 case 7: // disable mouse bindings with Scroll Lock
148 getScreen()->saveAllowScrollLock(! getScreen()->allowScrollLock());
149 setItemSelected(index
, getScreen()->allowScrollLock());
150 getScreen()->reconfigure();
153 case 8: // hide toolbar
154 getScreen()->saveHideToolbar(! getScreen()->doHideToolbar());
155 setItemSelected(index
, getScreen()->doHideToolbar());
161 void Configmenu::reconfigure(void) {
163 focusmenu
->reconfigure();
164 placementmenu
->reconfigure();
165 windowsnapmenu
->reconfigure();
166 edgesnapmenu
->reconfigure();
168 xineramamenu
->reconfigure();
171 Basemenu::reconfigure();
175 Configmenu::Focusmenu::Focusmenu(Configmenu
*cm
) : Basemenu(cm
->getScreen()) {
176 setLabel(i18n(ConfigmenuSet
, ConfigmenuFocusModel
, "Focus Model"));
179 insert(i18n(ConfigmenuSet
, ConfigmenuClickToFocus
, "Click To Focus"), 1);
180 insert(i18n(ConfigmenuSet
, ConfigmenuSloppyFocus
, "Sloppy Focus"), 2);
181 insert(i18n(ConfigmenuSet
, ConfigmenuAutoRaise
, "Auto Raise"), 3);
182 insert(i18n(ConfigmenuSet
, ConfigmenuClickRaise
, "Click Raise"), 4);
188 void Configmenu::Focusmenu::setValues(void) {
189 setItemSelected(0, ! getScreen()->isSloppyFocus());
190 setItemSelected(1, getScreen()->isSloppyFocus());
191 setItemEnabled(2, getScreen()->isSloppyFocus());
192 setItemSelected(2, getScreen()->doAutoRaise());
193 setItemEnabled(3, getScreen()->isSloppyFocus());
194 setItemSelected(3, getScreen()->doClickRaise());
198 void Configmenu::Focusmenu::reconfigure(void) {
200 Basemenu::reconfigure();
204 void Configmenu::Focusmenu::itemSelected(int button
, unsigned int index
) {
208 BasemenuItem
*item
= find(index
);
210 if (! item
->function())
213 switch (item
->function()) {
214 case 1: // click to focus
215 getScreen()->toggleFocusModel(BScreen::ClickToFocus
);
218 case 2: // sloppy focus
219 getScreen()->toggleFocusModel(BScreen::SloppyFocus
);
222 case 3: // auto raise with sloppy focus
223 getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
226 case 4: // click raise with sloppy focus
227 getScreen()->saveClickRaise(! getScreen()->doClickRaise());
228 // make sure the appropriate mouse buttons are grabbed on the windows
229 getScreen()->toggleFocusModel(BScreen::SloppyFocus
);
236 Configmenu::Placementmenu::Placementmenu(Configmenu
*cm
):
237 Basemenu(cm
->getScreen()) {
238 setLabel(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
, "Window Placement"));
241 insert(i18n(ConfigmenuSet
, ConfigmenuSmartRows
, "Smart Placement (Rows)"),
242 BScreen::RowSmartPlacement
);
243 insert(i18n(ConfigmenuSet
, ConfigmenuSmartCols
, "Smart Placement (Columns)"),
244 BScreen::ColSmartPlacement
);
245 insert(i18n(ConfigmenuSet
, ConfigmenuCascade
, "Cascade Placement"),
246 BScreen::CascadePlacement
);
247 insert(i18n(ConfigmenuSet
, ConfigmenuUnderMouse
, "Under Mouse Placement"),
248 BScreen::UnderMousePlacement
);
249 insert(i18n(ConfigmenuSet
, ConfigmenuClickMouse
, "Click Mouse Placement"),
250 BScreen::ClickMousePlacement
);
251 insert(i18n(ConfigmenuSet
, ConfigmenuLeftRight
, "Left to Right"),
253 insert(i18n(ConfigmenuSet
, ConfigmenuRightLeft
, "Right to Left"),
255 insert(i18n(ConfigmenuSet
, ConfigmenuTopBottom
, "Top to Bottom"),
257 insert(i18n(ConfigmenuSet
, ConfigmenuBottomTop
, "Bottom to Top"),
259 insert(i18n(ConfigmenuSet
, ConfigmenuIgnoreShaded
, "Ignore Shaded Windows"),
260 BScreen::IgnoreShaded
);
261 insert(i18n(ConfigmenuSet
, ConfigmenuIgnoreMax
,
262 "Ignore Full-Maximized Windows"),
263 BScreen::IgnoreMaximized
);
269 void Configmenu::Placementmenu::setValues(void) {
270 int placement
= getScreen()->getPlacementPolicy();
272 setItemSelected(0, placement
== BScreen::RowSmartPlacement
);
273 setItemSelected(1, placement
== BScreen::ColSmartPlacement
);
274 setItemSelected(2, placement
== BScreen::CascadePlacement
);
275 setItemSelected(3, placement
== BScreen::UnderMousePlacement
);
276 setItemSelected(4, placement
== BScreen::ClickMousePlacement
);
278 bool rl
= (getScreen()->getRowPlacementDirection() == BScreen::LeftRight
),
279 tb
= (getScreen()->getColPlacementDirection() == BScreen::TopBottom
),
280 e
= (placement
== BScreen::RowSmartPlacement
||
281 placement
== BScreen::ColSmartPlacement
);
283 setItemSelected(5, rl
);
284 setItemSelected(6, ! rl
);
285 setItemEnabled(5, e
);
286 setItemEnabled(6, e
);
288 setItemSelected(7, tb
);
289 setItemSelected(8, ! tb
);
290 setItemEnabled(7, e
);
291 setItemEnabled(8, e
);
293 setItemSelected(9, getScreen()->getPlaceIgnoreShaded());
294 setItemSelected(10, getScreen()->getPlaceIgnoreMaximized());
295 setItemEnabled(9, e
);
296 setItemEnabled(10, e
);
300 void Configmenu::Placementmenu::reconfigure(void) {
302 Basemenu::reconfigure();
306 void Configmenu::Placementmenu::itemSelected(int button
, unsigned int index
) {
310 BasemenuItem
*item
= find(index
);
312 if (! item
->function())
315 switch (item
->function()) {
316 case BScreen::RowSmartPlacement
:
317 getScreen()->savePlacementPolicy(item
->function());
320 case BScreen::ColSmartPlacement
:
321 getScreen()->savePlacementPolicy(item
->function());
324 case BScreen::CascadePlacement
:
325 getScreen()->savePlacementPolicy(item
->function());
328 case BScreen::UnderMousePlacement
:
329 getScreen()->savePlacementPolicy(item
->function());
332 case BScreen::ClickMousePlacement
:
333 getScreen()->savePlacementPolicy(item
->function());
336 case BScreen::LeftRight
:
337 getScreen()->saveRowPlacementDirection(BScreen::LeftRight
);
340 case BScreen::RightLeft
:
341 getScreen()->saveRowPlacementDirection(BScreen::RightLeft
);
344 case BScreen::TopBottom
:
345 getScreen()->saveColPlacementDirection(BScreen::TopBottom
);
348 case BScreen::BottomTop
:
349 getScreen()->saveColPlacementDirection(BScreen::BottomTop
);
352 case BScreen::IgnoreShaded
:
353 getScreen()->savePlaceIgnoreShaded(! getScreen()->getPlaceIgnoreShaded());
356 case BScreen::IgnoreMaximized
:
358 savePlaceIgnoreMaximized(! getScreen()->getPlaceIgnoreMaximized());
365 Configmenu::WindowToWindowSnapmenu::WindowToWindowSnapmenu(Configmenu
*cm
) :
366 Basemenu(cm
->getScreen()) {
367 setLabel(i18n(ConfigmenuSet
, ConfigmenuWindowToWindowSnap
,
368 "Window-To-Window Snapping"));
371 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoSnapNo
, "No Snapping"), 1);
372 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoSnap
, "Edge Snapping"), 2);
373 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoResistance
,
374 "Edge Resistance"), 3);
375 insert(i18n(ConfigmenuSet
, ConfigmenuWindowCornerSnap
,
376 "Window Corner Snapping"), 4);
382 void Configmenu::WindowToWindowSnapmenu::setValues(void) {
383 setItemSelected(0, (getScreen()->getWindowToWindowSnap() ==
384 BScreen::WindowNoSnap
));
385 setItemSelected(1, (getScreen()->getWindowToWindowSnap() ==
386 BScreen::WindowSnap
));
387 setItemSelected(2, (getScreen()->getWindowToWindowSnap() ==
388 BScreen::WindowResistance
));
390 setItemEnabled(3, getScreen()->getWindowToWindowSnap());
391 setItemSelected(3, getScreen()->getWindowCornerSnap());
395 void Configmenu::WindowToWindowSnapmenu::reconfigure(void) {
397 Basemenu::reconfigure();
401 void Configmenu::WindowToWindowSnapmenu::itemSelected(int button
, unsigned int index
) {
405 BasemenuItem
*item
= find(index
);
407 if (! item
->function())
410 switch (item
->function()) {
412 getScreen()->saveWindowToWindowSnap(BScreen::WindowNoSnap
);
415 case 2: // edge snapping
416 getScreen()->saveWindowToWindowSnap(BScreen::WindowSnap
);
419 case 3: // edge resistance
420 getScreen()->saveWindowToWindowSnap(BScreen::WindowResistance
);
423 case 4: // window corner snapping
424 getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap());
432 Configmenu::WindowToEdgeSnapmenu::WindowToEdgeSnapmenu(Configmenu
*cm
) :
433 Basemenu(cm
->getScreen()) {
434 setLabel(i18n(ConfigmenuSet
, ConfigmenuWindowToEdgeSnap
,
435 "Window-To-Edge Snapping"));
438 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoSnapNo
, "No Snapping"), 1);
439 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoSnap
, "Edge Snapping"), 2);
440 insert(i18n(ConfigmenuSet
, ConfigmenuWindowDoResistance
,
441 "Edge Resistance"), 3);
447 void Configmenu::WindowToEdgeSnapmenu::setValues(void) {
448 setItemSelected(0, (getScreen()->getWindowToEdgeSnap() ==
449 BScreen::WindowNoSnap
));
450 setItemSelected(1, (getScreen()->getWindowToEdgeSnap() ==
451 BScreen::WindowSnap
));
452 setItemSelected(2, (getScreen()->getWindowToEdgeSnap() ==
453 BScreen::WindowResistance
));
457 void Configmenu::WindowToEdgeSnapmenu::reconfigure(void) {
459 Basemenu::reconfigure();
463 void Configmenu::WindowToEdgeSnapmenu::itemSelected(int button
, unsigned int index
) {
467 BasemenuItem
*item
= find(index
);
469 if (! item
->function())
472 switch (item
->function()) {
474 getScreen()->saveWindowToEdgeSnap(BScreen::WindowNoSnap
);
477 case 2: // edge snapping
478 getScreen()->saveWindowToEdgeSnap(BScreen::WindowSnap
);
481 case 3: // edge resistance
482 getScreen()->saveWindowToEdgeSnap(BScreen::WindowResistance
);
490 Configmenu::Xineramamenu::Xineramamenu(Configmenu
*cm
):
491 Basemenu(cm
->getScreen()) {
492 setLabel(i18n(ConfigmenuSet
, ConfigmenuXineramaSupport
, "Xinerama Support"));
495 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaPlacement
, "Window Placement"),
497 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaMaximizing
, "Window Maximizing"),
499 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaSnapping
, "Window Snapping"),
507 void Configmenu::Xineramamenu::setValues(void) {
508 setItemSelected(0, getScreen()->getBlackbox()->doXineramaPlacement());
509 setItemSelected(1, getScreen()->getBlackbox()->doXineramaMaximizing());
510 setItemSelected(2, getScreen()->getBlackbox()->doXineramaSnapping());
514 void Configmenu::Xineramamenu::reconfigure(void) {
516 Basemenu::reconfigure();
520 void Configmenu::Xineramamenu::itemSelected(int button
, unsigned int index
) {
524 BasemenuItem
*item
= find(index
);
526 if (! item
->function())
529 Blackbox
*bb
= getScreen()->getBlackbox();
531 switch (item
->function()) {
532 case 1: // window placement
533 bb
->saveXineramaPlacement(! bb
->doXineramaPlacement());
534 setItemSelected(0, bb
->doXineramaPlacement());
537 case 2: // window maximizing
538 bb
->saveXineramaMaximizing(! bb
->doXineramaMaximizing());
539 setItemSelected(1, bb
->doXineramaMaximizing());
542 case 3: // window snapping
543 bb
->saveXineramaSnapping(! bb
->doXineramaSnapping());
544 setItemSelected(2, bb
->doXineramaSnapping());