openbox/src/Configmenu.cc

496 lines
15 KiB
C++
Raw Normal View History

// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// Configmenu.cc for Blackbox - An X11 Window Manager
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
2002-04-11 03:20:38 +00:00
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H
#include "i18n.hh"
#include "Configmenu.hh"
#include "Image.hh"
#include "Toolbar.hh"
#include "Window.hh"
#include "Screen.hh"
2002-04-11 03:20:38 +00:00
Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config options"));
2002-04-11 03:20:38 +00:00
setInternalMenu();
focusmenu = new Focusmenu(this);
placementmenu = new Placementmenu(this);
2002-07-22 08:09:34 +00:00
#ifdef XINERAMA
xineramamenu = new Xineramamenu(this);
#endif // XINERAMA
2002-04-11 03:20:38 +00:00
insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
"Focus Model"), focusmenu);
insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
"Window Placement"), placementmenu);
2002-07-22 08:09:34 +00:00
#ifdef XINERAMA
insert(i18n(ConfigmenuSet, ConfigmenuXineramaSupport,
"XineramaSupport"), xineramamenu);
#endif // XINERAMA
insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
"Image Dithering"), 1);
insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove,
"Opaque Window Moving"), 2);
insert(i18n(ConfigmenuSet, ConfigmenuFullMax,
"Full Maximization"), 3);
insert(i18n(ConfigmenuSet, ConfigmenuFocusNew,
"Focus New Windows"), 4);
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
"Focus Last Window on Workspace"), 5);
insert(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap,
"Window-To-Window Snapping"), 6);
insert(i18n(ConfigmenuSet, ConfigmenuWindowCornerSnap,
"Window Corner Snapping"), 7);
insert(i18n(ConfigmenuSet, ConfigmenuDisableBindings,
"Disable Mouse with Scroll Lock"), 8);
2002-05-27 05:06:04 +00:00
insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar,
"Hide Toolbar"), 9);
2002-04-11 03:20:38 +00:00
update();
setValues();
}
2002-04-11 03:20:38 +00:00
void Configmenu::setValues(void) {
2002-07-22 08:09:34 +00:00
setItemSelected(3, getScreen()->doImageDither());
setItemSelected(4, getScreen()->doOpaqueMove());
setItemSelected(5, getScreen()->doFullMax());
setItemSelected(6, getScreen()->doFocusNew());
setItemSelected(7, getScreen()->doFocusLast());
setItemSelected(8, getScreen()->getWindowToWindowSnap());
setItemSelected(9, getScreen()->getWindowCornerSnap());
setItemEnabled(9, getScreen()->getWindowToWindowSnap());
2002-07-22 08:09:34 +00:00
setItemSelected(10, getScreen()->allowScrollLock());
setItemSelected(11, getScreen()->doHideToolbar());
2002-04-11 03:20:38 +00:00
}
Configmenu::~Configmenu(void) {
2002-04-11 03:20:38 +00:00
delete focusmenu;
delete placementmenu;
2002-07-22 08:09:34 +00:00
#ifdef XINERAMA
delete xineramamenu;
#endif // XINERAMA
2002-04-11 03:20:38 +00:00
}
void Configmenu::itemSelected(int button, unsigned int index) {
2002-04-11 03:20:38 +00:00
if (button != 1)
return;
BasemenuItem *item = find(index);
if (! item->function())
2002-04-11 03:20:38 +00:00
return;
switch(item->function()) {
case 1: // dither
getScreen()->saveImageDither(! getScreen()->doImageDither());
setItemSelected(index, getScreen()->doImageDither());
2002-04-11 03:20:38 +00:00
break;
case 2: // opaque move
getScreen()->saveOpaqueMove(! getScreen()->doOpaqueMove());
setItemSelected(index, getScreen()->doOpaqueMove());
2002-04-11 03:20:38 +00:00
break;
case 3: // full maximization
getScreen()->saveFullMax(! getScreen()->doFullMax());
setItemSelected(index, getScreen()->doFullMax());
2002-04-11 03:20:38 +00:00
break;
case 4: // focus new windows
getScreen()->saveFocusNew(! getScreen()->doFocusNew());
setItemSelected(index, getScreen()->doFocusNew());
2002-04-11 03:20:38 +00:00
break;
case 5: // focus last window on workspace
getScreen()->saveFocusLast(! getScreen()->doFocusLast());
setItemSelected(index, getScreen()->doFocusLast());
break;
2002-05-27 05:06:04 +00:00
case 6: // window-to-window snapping
getScreen()->saveWindowToWindowSnap(! getScreen()->getWindowToWindowSnap());
setItemSelected(index, getScreen()->getWindowToWindowSnap());
setItemEnabled(index + 1, getScreen()->getWindowToWindowSnap());
break;
case 7: // window corner snapping
getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap());
setItemSelected(index, getScreen()->getWindowCornerSnap());
break;
case 8: // disable mouse bindings with Scroll Lock
getScreen()->saveAllowScrollLock(! getScreen()->allowScrollLock());
setItemSelected(index, getScreen()->allowScrollLock());
getScreen()->reconfigure();
break;
case 9: // hide toolbar
getScreen()->saveHideToolbar(! getScreen()->doHideToolbar());
2002-05-27 05:06:04 +00:00
setItemSelected(index, getScreen()->doHideToolbar());
break;
}
2002-04-11 03:20:38 +00:00
}
void Configmenu::reconfigure(void) {
setValues();
2002-04-11 03:20:38 +00:00
focusmenu->reconfigure();
placementmenu->reconfigure();
2002-07-22 08:44:20 +00:00
#ifdef XINERAMA
2002-07-22 08:09:34 +00:00
xineramamenu->reconfigure();
2002-07-22 08:44:20 +00:00
#endif // XINERAMA
2002-04-11 03:20:38 +00:00
Basemenu::reconfigure();
}
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel, "Focus Model"));
2002-04-11 03:20:38 +00:00
setInternalMenu();
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus, "Click To Focus"), 1);
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus, "Sloppy Focus"), 2);
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3);
insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4);
2002-04-11 03:20:38 +00:00
update();
setValues();
}
2002-04-11 03:20:38 +00:00
void Configmenu::Focusmenu::setValues(void) {
setItemSelected(0, ! getScreen()->isSloppyFocus());
setItemSelected(1, getScreen()->isSloppyFocus());
setItemEnabled(2, getScreen()->isSloppyFocus());
setItemSelected(2, getScreen()->doAutoRaise());
setItemEnabled(3, getScreen()->isSloppyFocus());
setItemSelected(3, getScreen()->doClickRaise());
}
2002-04-11 03:20:38 +00:00
void Configmenu::Focusmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
2002-04-11 03:20:38 +00:00
if (button != 1)
return;
BasemenuItem *item = find(index);
if (! item->function())
2002-04-11 03:20:38 +00:00
return;
switch (item->function()) {
case 1: // click to focus
getScreen()->toggleFocusModel(BScreen::ClickToFocus);
2002-04-11 03:20:38 +00:00
break;
case 2: // sloppy focus
getScreen()->toggleFocusModel(BScreen::SloppyFocus);
2002-04-11 03:20:38 +00:00
break;
case 3: // auto raise with sloppy focus
getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
break;
case 4: // click raise with sloppy focus
getScreen()->saveClickRaise(! getScreen()->doClickRaise());
// make sure the appropriate mouse buttons are grabbed on the windows
getScreen()->toggleFocusModel(BScreen::SloppyFocus);
2002-04-11 03:20:38 +00:00
break;
}
setValues();
2002-04-11 03:20:38 +00:00
}
Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
Basemenu(cm->getScreen()) {
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement"));
2002-04-11 03:20:38 +00:00
setInternalMenu();
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows, "Smart Placement (Rows)"),
BScreen::RowSmartPlacement);
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols, "Smart Placement (Columns)"),
BScreen::ColSmartPlacement);
insert(i18n(ConfigmenuSet, ConfigmenuCascade, "Cascade Placement"),
BScreen::CascadePlacement);
insert(i18n(ConfigmenuSet, ConfigmenuUnderMouse, "Under Mouse Placement"),
BScreen::UnderMousePlacement);
2002-07-16 05:00:09 +00:00
insert(i18n(ConfigmenuSet, ConfigmenuClickMouse, "Click Mouse Placement"),
BScreen::ClickMousePlacement);
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight, "Left to Right"),
BScreen::LeftRight);
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft, "Right to Left"),
BScreen::RightLeft);
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom, "Top to Bottom"),
BScreen::TopBottom);
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"),
BScreen::BottomTop);
2002-07-18 05:30:48 +00:00
insert(i18n(ConfigmenuSet, ConfigmenuIgnoreShaded, "Ignore Shaded Windows"),
BScreen::IgnoreShaded);
insert(i18n(ConfigmenuSet, ConfigmenuIgnoreMax,
2002-07-18 05:30:48 +00:00
"Ignore Full-Maximized Windows"),
BScreen::IgnoreMaximized);
2002-04-11 03:20:38 +00:00
update();
setValues();
}
2002-04-11 03:20:38 +00:00
void Configmenu::Placementmenu::setValues(void) {
int placement = getScreen()->getPlacementPolicy();
setItemSelected(0, placement == BScreen::RowSmartPlacement);
setItemSelected(1, placement == BScreen::ColSmartPlacement);
setItemSelected(2, placement == BScreen::CascadePlacement);
setItemSelected(3, placement == BScreen::UnderMousePlacement);
2002-07-16 05:00:09 +00:00
setItemSelected(4, placement == BScreen::ClickMousePlacement);
2002-04-28 00:11:19 +00:00
bool rl = (getScreen()->getRowPlacementDirection() == BScreen::LeftRight),
tb = (getScreen()->getColPlacementDirection() == BScreen::TopBottom),
e = placement != BScreen::UnderMousePlacement;
2002-07-16 05:00:09 +00:00
setItemSelected(5, rl);
setItemSelected(6, ! rl);
setItemEnabled(5, e);
setItemEnabled(6, e);
2002-07-16 05:00:09 +00:00
setItemSelected(7, tb);
setItemSelected(8, ! tb);
setItemEnabled(7, e);
2002-07-16 05:00:09 +00:00
setItemEnabled(8, e);
2002-07-16 05:00:09 +00:00
setItemSelected(9, getScreen()->getPlaceIgnoreShaded());
setItemSelected(10, getScreen()->getPlaceIgnoreMaximized());
}
void Configmenu::Placementmenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
2002-04-11 03:20:38 +00:00
if (button != 1)
return;
BasemenuItem *item = find(index);
if (! item->function())
2002-04-11 03:20:38 +00:00
return;
switch (item->function()) {
case BScreen::RowSmartPlacement:
getScreen()->savePlacementPolicy(item->function());
setItemSelected(0, true);
setItemSelected(1, false);
setItemSelected(2, false);
setItemSelected(3, false);
2002-07-16 05:00:09 +00:00
setItemSelected(4, false);
setItemEnabled(5, true);
setItemEnabled(6, true);
setItemEnabled(7, true);
2002-07-16 05:00:09 +00:00
setItemEnabled(8, true);
2002-04-11 03:20:38 +00:00
break;
case BScreen::ColSmartPlacement:
getScreen()->savePlacementPolicy(item->function());
2002-04-11 03:20:38 +00:00
setItemSelected(0, false);
setItemSelected(1, true);
setItemSelected(2, false);
setItemSelected(3, false);
2002-07-16 05:00:09 +00:00
setItemSelected(4, false);
setItemEnabled(5, true);
setItemEnabled(6, true);
setItemEnabled(7, true);
2002-07-16 05:00:09 +00:00
setItemEnabled(8, true);
2002-04-28 00:11:19 +00:00
break;
case BScreen::CascadePlacement:
getScreen()->savePlacementPolicy(item->function());
setItemSelected(0, false);
setItemSelected(1, false);
setItemSelected(2, true);
setItemSelected(3, false);
2002-07-16 05:00:09 +00:00
setItemSelected(4, false);
setItemEnabled(5, true);
setItemEnabled(6, true);
setItemEnabled(7, true);
2002-07-16 05:00:09 +00:00
setItemEnabled(8, true);
break;
case BScreen::UnderMousePlacement:
getScreen()->savePlacementPolicy(item->function());
setItemSelected(0, false);
setItemSelected(1, false);
setItemSelected(2, false);
setItemSelected(3, true);
2002-07-16 05:00:09 +00:00
setItemSelected(4, false);
setItemEnabled(5, false);
setItemEnabled(6, false);
setItemEnabled(7, false);
2002-07-16 05:00:09 +00:00
setItemEnabled(8, false);
break;
case BScreen::ClickMousePlacement:
getScreen()->savePlacementPolicy(item->function());
setItemSelected(0, false);
setItemSelected(1, false);
setItemSelected(2, false);
setItemSelected(3, false);
setItemSelected(4, true);
setItemEnabled(5, false);
setItemEnabled(6, false);
setItemEnabled(7, false);
setItemEnabled(8, false);
2002-04-11 03:20:38 +00:00
break;
2002-04-11 03:20:38 +00:00
case BScreen::LeftRight:
getScreen()->saveRowPlacementDirection(BScreen::LeftRight);
2002-07-16 05:00:09 +00:00
setItemSelected(5, true);
setItemSelected(6, false);
2002-04-11 03:20:38 +00:00
break;
case BScreen::RightLeft:
getScreen()->saveRowPlacementDirection(BScreen::RightLeft);
2002-07-16 05:00:09 +00:00
setItemSelected(5, false);
setItemSelected(6, true);
2002-04-11 03:20:38 +00:00
break;
case BScreen::TopBottom:
getScreen()->saveColPlacementDirection(BScreen::TopBottom);
2002-07-16 05:00:09 +00:00
setItemSelected(7, true);
setItemSelected(8, false);
2002-04-11 03:20:38 +00:00
break;
case BScreen::BottomTop:
getScreen()->saveColPlacementDirection(BScreen::BottomTop);
2002-07-16 05:00:09 +00:00
setItemSelected(7, false);
setItemSelected(8, true);
break;
case BScreen::IgnoreShaded:
getScreen()->savePlaceIgnoreShaded(! getScreen()->getPlaceIgnoreShaded());
2002-07-16 05:00:09 +00:00
setItemSelected(9, getScreen()->getPlaceIgnoreShaded());
break;
case BScreen::IgnoreMaximized:
getScreen()->
savePlaceIgnoreMaximized(! getScreen()->getPlaceIgnoreMaximized());
2002-07-16 05:00:09 +00:00
setItemSelected(10, getScreen()->getPlaceIgnoreMaximized());
2002-04-11 03:20:38 +00:00
break;
}
}
2002-07-22 08:09:34 +00:00
#ifdef XINERAMA
Configmenu::Xineramamenu::Xineramamenu(Configmenu *cm):
Basemenu(cm->getScreen()) {
setLabel(i18n(ConfigmenuSet, ConfigmenuXineramaSupport, "Xinerama Support"));
setInternalMenu();
insert(i18n(ConfigmenuSet, ConfigmenuXineramaPlacement, "Window Placement"),
1);
insert(i18n(ConfigmenuSet, ConfigmenuXineramaMaximizing, "Window Maximizing"),
2);
insert(i18n(ConfigmenuSet, ConfigmenuXineramaSnapping, "Window Snapping"),
3);
update();
setValues();
}
void Configmenu::Xineramamenu::setValues(void) {
setItemSelected(0, getScreen()->getBlackbox()->doXineramaPlacement());
setItemSelected(1, getScreen()->getBlackbox()->doXineramaMaximizing());
setItemSelected(2, getScreen()->getBlackbox()->doXineramaSnapping());
}
void Configmenu::Xineramamenu::reconfigure(void) {
setValues();
Basemenu::reconfigure();
}
void Configmenu::Xineramamenu::itemSelected(int button, unsigned int index) {
if (button != 1)
return;
BasemenuItem *item = find(index);
if (! item->function())
return;
Blackbox *bb = getScreen()->getBlackbox();
switch (item->function()) {
case 1: // window placement
bb->saveXineramaPlacement(! bb->doXineramaPlacement());
setItemSelected(0, bb->doXineramaPlacement());
break;
case 2: // window maximizing
bb->saveXineramaMaximizing(! bb->doXineramaMaximizing());
setItemSelected(1, bb->doXineramaMaximizing());
break;
case 3: // window snapping
bb->saveXineramaSnapping(! bb->doXineramaSnapping());
setItemSelected(2, bb->doXineramaSnapping());
break;
}
}
#endif // XINERAMA