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 xineramamenu
= new Xineramamenu(this);
45 insert(i18n(ConfigmenuSet
, ConfigmenuFocusModel
,
46 "Focus Model"), focusmenu
);
47 insert(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
,
48 "Window Placement"), placementmenu
);
50 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaSupport
,
51 "XineramaSupport"), xineramamenu
);
53 insert(i18n(ConfigmenuSet
, ConfigmenuImageDithering
,
54 "Image Dithering"), 1);
55 insert(i18n(ConfigmenuSet
, ConfigmenuOpaqueMove
,
56 "Opaque Window Moving"), 2);
57 insert(i18n(ConfigmenuSet
, ConfigmenuFullMax
,
58 "Full Maximization"), 3);
59 insert(i18n(ConfigmenuSet
, ConfigmenuFocusNew
,
60 "Focus New Windows"), 4);
61 insert(i18n(ConfigmenuSet
, ConfigmenuFocusLast
,
62 "Focus Last Window on Workspace"), 5);
63 insert(i18n(ConfigmenuSet
, ConfigmenuWindowToWindowSnap
,
64 "Window-To-Window Snapping"), 6);
65 insert(i18n(ConfigmenuSet
, ConfigmenuWindowCornerSnap
,
66 "Window Corner Snapping"), 7);
67 insert(i18n(ConfigmenuSet
, ConfigmenuDisableBindings
,
68 "Disable Mouse with Scroll Lock"), 8);
69 insert(i18n(ConfigmenuSet
, ConfigmenuHideToolbar
,
76 void Configmenu::setValues(void) {
81 setItemSelected(index
++, getScreen()->doImageDither());
82 setItemSelected(index
++, getScreen()->doOpaqueMove());
83 setItemSelected(index
++, getScreen()->doFullMax());
84 setItemSelected(index
++, getScreen()->doFocusNew());
85 setItemSelected(index
++, getScreen()->doFocusLast());
86 setItemSelected(index
++, getScreen()->getWindowToWindowSnap());
88 setItemSelected(index
, getScreen()->getWindowCornerSnap());
89 setItemEnabled(index
++, getScreen()->getWindowToWindowSnap());
91 setItemSelected(index
++, getScreen()->allowScrollLock());
92 setItemSelected(index
++, getScreen()->doHideToolbar());
96 Configmenu::~Configmenu(void) {
105 void Configmenu::itemSelected(int button
, unsigned int index
) {
109 BasemenuItem
*item
= find(index
);
111 if (! item
->function())
114 switch(item
->function()) {
116 getScreen()->saveImageDither(! getScreen()->doImageDither());
117 setItemSelected(index
, getScreen()->doImageDither());
120 case 2: // opaque move
121 getScreen()->saveOpaqueMove(! getScreen()->doOpaqueMove());
122 setItemSelected(index
, getScreen()->doOpaqueMove());
125 case 3: // full maximization
126 getScreen()->saveFullMax(! getScreen()->doFullMax());
127 setItemSelected(index
, getScreen()->doFullMax());
130 case 4: // focus new windows
131 getScreen()->saveFocusNew(! getScreen()->doFocusNew());
132 setItemSelected(index
, getScreen()->doFocusNew());
135 case 5: // focus last window on workspace
136 getScreen()->saveFocusLast(! getScreen()->doFocusLast());
137 setItemSelected(index
, getScreen()->doFocusLast());
140 case 6: // window-to-window snapping
141 getScreen()->saveWindowToWindowSnap(! getScreen()->getWindowToWindowSnap());
142 setItemSelected(index
, getScreen()->getWindowToWindowSnap());
143 setItemEnabled(index
+ 1, getScreen()->getWindowToWindowSnap());
146 case 7: // window corner snapping
147 getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap());
148 setItemSelected(index
, getScreen()->getWindowCornerSnap());
151 case 8: // disable mouse bindings with Scroll Lock
152 getScreen()->saveAllowScrollLock(! getScreen()->allowScrollLock());
153 setItemSelected(index
, getScreen()->allowScrollLock());
154 getScreen()->reconfigure();
157 case 9: // hide toolbar
158 getScreen()->saveHideToolbar(! getScreen()->doHideToolbar());
159 setItemSelected(index
, getScreen()->doHideToolbar());
165 void Configmenu::reconfigure(void) {
167 focusmenu
->reconfigure();
168 placementmenu
->reconfigure();
170 xineramamenu
->reconfigure();
173 Basemenu::reconfigure();
177 Configmenu::Focusmenu::Focusmenu(Configmenu
*cm
) : Basemenu(cm
->getScreen()) {
178 setLabel(i18n(ConfigmenuSet
, ConfigmenuFocusModel
, "Focus Model"));
181 insert(i18n(ConfigmenuSet
, ConfigmenuClickToFocus
, "Click To Focus"), 1);
182 insert(i18n(ConfigmenuSet
, ConfigmenuSloppyFocus
, "Sloppy Focus"), 2);
183 insert(i18n(ConfigmenuSet
, ConfigmenuAutoRaise
, "Auto Raise"), 3);
184 insert(i18n(ConfigmenuSet
, ConfigmenuClickRaise
, "Click Raise"), 4);
190 void Configmenu::Focusmenu::setValues(void) {
191 setItemSelected(0, ! getScreen()->isSloppyFocus());
192 setItemSelected(1, getScreen()->isSloppyFocus());
193 setItemEnabled(2, getScreen()->isSloppyFocus());
194 setItemSelected(2, getScreen()->doAutoRaise());
195 setItemEnabled(3, getScreen()->isSloppyFocus());
196 setItemSelected(3, getScreen()->doClickRaise());
200 void Configmenu::Focusmenu::reconfigure(void) {
202 Basemenu::reconfigure();
206 void Configmenu::Focusmenu::itemSelected(int button
, unsigned int index
) {
210 BasemenuItem
*item
= find(index
);
212 if (! item
->function())
215 switch (item
->function()) {
216 case 1: // click to focus
217 getScreen()->toggleFocusModel(BScreen::ClickToFocus
);
220 case 2: // sloppy focus
221 getScreen()->toggleFocusModel(BScreen::SloppyFocus
);
224 case 3: // auto raise with sloppy focus
225 getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
228 case 4: // click raise with sloppy focus
229 getScreen()->saveClickRaise(! getScreen()->doClickRaise());
230 // make sure the appropriate mouse buttons are grabbed on the windows
231 getScreen()->toggleFocusModel(BScreen::SloppyFocus
);
238 Configmenu::Placementmenu::Placementmenu(Configmenu
*cm
):
239 Basemenu(cm
->getScreen()) {
240 setLabel(i18n(ConfigmenuSet
, ConfigmenuWindowPlacement
, "Window Placement"));
243 insert(i18n(ConfigmenuSet
, ConfigmenuSmartRows
, "Smart Placement (Rows)"),
244 BScreen::RowSmartPlacement
);
245 insert(i18n(ConfigmenuSet
, ConfigmenuSmartCols
, "Smart Placement (Columns)"),
246 BScreen::ColSmartPlacement
);
247 insert(i18n(ConfigmenuSet
, ConfigmenuCascade
, "Cascade Placement"),
248 BScreen::CascadePlacement
);
249 insert(i18n(ConfigmenuSet
, ConfigmenuUnderMouse
, "Under Mouse Placement"),
250 BScreen::UnderMousePlacement
);
251 insert(i18n(ConfigmenuSet
, ConfigmenuClickMouse
, "Click Mouse Placement"),
252 BScreen::ClickMousePlacement
);
253 insert(i18n(ConfigmenuSet
, ConfigmenuLeftRight
, "Left to Right"),
255 insert(i18n(ConfigmenuSet
, ConfigmenuRightLeft
, "Right to Left"),
257 insert(i18n(ConfigmenuSet
, ConfigmenuTopBottom
, "Top to Bottom"),
259 insert(i18n(ConfigmenuSet
, ConfigmenuBottomTop
, "Bottom to Top"),
261 insert(i18n(ConfigmenuSet
, ConfigmenuIgnoreShaded
, "Ignore Shaded Windows"),
262 BScreen::IgnoreShaded
);
263 insert(i18n(ConfigmenuSet
, ConfigmenuIgnoreMax
,
264 "Ignore Full-Maximized Windows"),
265 BScreen::IgnoreMaximized
);
271 void Configmenu::Placementmenu::setValues(void) {
272 int placement
= getScreen()->getPlacementPolicy();
274 setItemSelected(0, placement
== BScreen::RowSmartPlacement
);
275 setItemSelected(1, placement
== BScreen::ColSmartPlacement
);
276 setItemSelected(2, placement
== BScreen::CascadePlacement
);
277 setItemSelected(3, placement
== BScreen::UnderMousePlacement
);
278 setItemSelected(4, placement
== BScreen::ClickMousePlacement
);
280 bool rl
= (getScreen()->getRowPlacementDirection() == BScreen::LeftRight
),
281 tb
= (getScreen()->getColPlacementDirection() == BScreen::TopBottom
),
282 e
= placement
!= BScreen::UnderMousePlacement
;
284 setItemSelected(5, rl
);
285 setItemSelected(6, ! rl
);
286 setItemEnabled(5, e
);
287 setItemEnabled(6, e
);
289 setItemSelected(7, tb
);
290 setItemSelected(8, ! tb
);
291 setItemEnabled(7, e
);
292 setItemEnabled(8, e
);
294 setItemSelected(9, getScreen()->getPlaceIgnoreShaded());
295 setItemSelected(10, getScreen()->getPlaceIgnoreMaximized());
299 void Configmenu::Placementmenu::reconfigure(void) {
301 Basemenu::reconfigure();
305 void Configmenu::Placementmenu::itemSelected(int button
, unsigned int index
) {
309 BasemenuItem
*item
= find(index
);
311 if (! item
->function())
314 switch (item
->function()) {
315 case BScreen::RowSmartPlacement
:
316 getScreen()->savePlacementPolicy(item
->function());
318 setItemSelected(0, true);
319 setItemSelected(1, false);
320 setItemSelected(2, false);
321 setItemSelected(3, false);
322 setItemSelected(4, false);
323 setItemEnabled(5, true);
324 setItemEnabled(6, true);
325 setItemEnabled(7, true);
326 setItemEnabled(8, true);
330 case BScreen::ColSmartPlacement
:
331 getScreen()->savePlacementPolicy(item
->function());
333 setItemSelected(0, false);
334 setItemSelected(1, true);
335 setItemSelected(2, false);
336 setItemSelected(3, false);
337 setItemSelected(4, false);
338 setItemEnabled(5, true);
339 setItemEnabled(6, true);
340 setItemEnabled(7, true);
341 setItemEnabled(8, true);
345 case BScreen::CascadePlacement
:
346 getScreen()->savePlacementPolicy(item
->function());
348 setItemSelected(0, false);
349 setItemSelected(1, false);
350 setItemSelected(2, true);
351 setItemSelected(3, false);
352 setItemSelected(4, false);
353 setItemEnabled(5, true);
354 setItemEnabled(6, true);
355 setItemEnabled(7, true);
356 setItemEnabled(8, true);
360 case BScreen::UnderMousePlacement
:
361 getScreen()->savePlacementPolicy(item
->function());
363 setItemSelected(0, false);
364 setItemSelected(1, false);
365 setItemSelected(2, false);
366 setItemSelected(3, true);
367 setItemSelected(4, false);
368 setItemEnabled(5, false);
369 setItemEnabled(6, false);
370 setItemEnabled(7, false);
371 setItemEnabled(8, false);
375 case BScreen::ClickMousePlacement
:
376 getScreen()->savePlacementPolicy(item
->function());
378 setItemSelected(0, false);
379 setItemSelected(1, false);
380 setItemSelected(2, false);
381 setItemSelected(3, false);
382 setItemSelected(4, true);
383 setItemEnabled(5, false);
384 setItemEnabled(6, false);
385 setItemEnabled(7, false);
386 setItemEnabled(8, false);
390 case BScreen::LeftRight
:
391 getScreen()->saveRowPlacementDirection(BScreen::LeftRight
);
393 setItemSelected(5, true);
394 setItemSelected(6, false);
398 case BScreen::RightLeft
:
399 getScreen()->saveRowPlacementDirection(BScreen::RightLeft
);
401 setItemSelected(5, false);
402 setItemSelected(6, true);
406 case BScreen::TopBottom
:
407 getScreen()->saveColPlacementDirection(BScreen::TopBottom
);
409 setItemSelected(7, true);
410 setItemSelected(8, false);
414 case BScreen::BottomTop
:
415 getScreen()->saveColPlacementDirection(BScreen::BottomTop
);
417 setItemSelected(7, false);
418 setItemSelected(8, true);
422 case BScreen::IgnoreShaded
:
423 getScreen()->savePlaceIgnoreShaded(! getScreen()->getPlaceIgnoreShaded());
425 setItemSelected(9, getScreen()->getPlaceIgnoreShaded());
429 case BScreen::IgnoreMaximized
:
431 savePlaceIgnoreMaximized(! getScreen()->getPlaceIgnoreMaximized());
433 setItemSelected(10, getScreen()->getPlaceIgnoreMaximized());
441 Configmenu::Xineramamenu::Xineramamenu(Configmenu
*cm
):
442 Basemenu(cm
->getScreen()) {
443 setLabel(i18n(ConfigmenuSet
, ConfigmenuXineramaSupport
, "Xinerama Support"));
446 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaPlacement
, "Window Placement"),
448 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaMaximizing
, "Window Maximizing"),
450 insert(i18n(ConfigmenuSet
, ConfigmenuXineramaSnapping
, "Window Snapping"),
458 void Configmenu::Xineramamenu::setValues(void) {
459 setItemSelected(0, getScreen()->getBlackbox()->doXineramaPlacement());
460 setItemSelected(1, getScreen()->getBlackbox()->doXineramaMaximizing());
461 setItemSelected(2, getScreen()->getBlackbox()->doXineramaSnapping());
465 void Configmenu::Xineramamenu::reconfigure(void) {
467 Basemenu::reconfigure();
471 void Configmenu::Xineramamenu::itemSelected(int button
, unsigned int index
) {
475 BasemenuItem
*item
= find(index
);
477 if (! item
->function())
480 Blackbox
*bb
= getScreen()->getBlackbox();
482 switch (item
->function()) {
483 case 1: // window placement
484 bb
->saveXineramaPlacement(! bb
->doXineramaPlacement());
485 setItemSelected(0, bb
->doXineramaPlacement());
488 case 2: // window maximizing
489 bb
->saveXineramaMaximizing(! bb
->doXineramaMaximizing());
490 setItemSelected(1, bb
->doXineramaMaximizing());
493 case 3: // window snapping
494 bb
->saveXineramaSnapping(! bb
->doXineramaSnapping());
495 setItemSelected(2, bb
->doXineramaSnapping());