2002-04-11 03:20:38 +00:00
|
|
|
// Configmenu.cc for Openbox
|
|
|
|
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
// stupid macros needed to access some functions in version 2 of the GNU C
|
|
|
|
// library
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
# define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
#include "Configmenu.h"
|
|
|
|
#include "Toolbar.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "Screen.h"
|
|
|
|
|
2002-04-14 11:37:22 +00:00
|
|
|
Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
|
|
|
{
|
2002-04-11 03:20:38 +00:00
|
|
|
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuConfigOptions,
|
|
|
|
"Config options"));
|
|
|
|
setInternalMenu();
|
|
|
|
|
|
|
|
focusmenu = new Focusmenu(this);
|
|
|
|
placementmenu = new Placementmenu(this);
|
|
|
|
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
|
|
|
|
"Focus Model"), focusmenu);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
|
|
|
|
"Window Placement"), placementmenu);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuImageDithering,
|
|
|
|
"Image Dithering"), 1);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuOpaqueMove,
|
|
|
|
"Opaque Window Moving"), 2);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFullMax,
|
|
|
|
"Full Maximization"), 3);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusNew,
|
|
|
|
"Focus New Windows"), 4);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusLast,
|
|
|
|
"Focus Last Window on Workspace"), 5);
|
2002-04-16 20:22:01 +00:00
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuHideToolbar,
|
|
|
|
"Hide toolbar"), 6);
|
2002-04-11 03:20:38 +00:00
|
|
|
update();
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
setValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configmenu::setValues() {
|
2002-04-14 11:37:22 +00:00
|
|
|
setItemSelected(2, screen.getImageControl()->doDither());
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(3, screen.opaqueMove());
|
|
|
|
setItemSelected(4, screen.fullMax());
|
|
|
|
setItemSelected(5, screen.focusNew());
|
|
|
|
setItemSelected(6, screen.focusLast());
|
2002-04-17 03:44:09 +00:00
|
|
|
setItemSelected(7, screen.hideToolbar());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
Configmenu::~Configmenu() {
|
2002-04-11 03:20:38 +00:00
|
|
|
delete focusmenu;
|
|
|
|
delete placementmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configmenu::itemSelected(int button, int index) {
|
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(item->function()) {
|
|
|
|
case 1: { // dither
|
2002-04-14 11:37:22 +00:00
|
|
|
screen.getImageControl()->
|
|
|
|
setDither((! screen.getImageControl()->doDither()));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 11:37:22 +00:00
|
|
|
setItemSelected(index, screen.getImageControl()->doDither());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2: { // opaque move
|
2002-04-17 08:30:55 +00:00
|
|
|
screen.setOpaqueMove(!screen.opaqueMove());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(index, screen.opaqueMove());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3: { // full maximization
|
2002-04-17 08:30:55 +00:00
|
|
|
screen.setFullMax(!screen.fullMax());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(index, screen.fullMax());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: { // focus new windows
|
2002-04-17 08:30:55 +00:00
|
|
|
screen.setFocusNew(!screen.focusNew());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(index, screen.focusNew());
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5: { // focus last window on workspace
|
2002-04-17 08:30:55 +00:00
|
|
|
screen.setFocusLast(!screen.focusLast());
|
|
|
|
setItemSelected(index, screen.focusLast());
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-16 20:22:01 +00:00
|
|
|
case 6:{ //toggle toolbar hide
|
2002-04-17 03:44:09 +00:00
|
|
|
screen.setHideToolbar(!screen.hideToolbar());
|
|
|
|
setItemSelected(index, screen.hideToolbar());
|
2002-04-16 20:22:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
} // switch
|
|
|
|
}
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
void Configmenu::reconfigure() {
|
|
|
|
setValues();
|
2002-04-11 03:20:38 +00:00
|
|
|
focusmenu->reconfigure();
|
|
|
|
placementmenu->reconfigure();
|
|
|
|
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) {
|
|
|
|
configmenu = cm;
|
|
|
|
|
|
|
|
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
|
|
|
|
"Focus Model"));
|
|
|
|
setInternalMenu();
|
|
|
|
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickToFocus,
|
|
|
|
"Click To Focus"), 1);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSloppyFocus,
|
|
|
|
"Sloppy Focus"), 2);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuAutoRaise,
|
|
|
|
"Auto Raise"), 3);
|
|
|
|
update();
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
setValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configmenu::Focusmenu::setValues() {
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(0, !configmenu->screen.sloppyFocus());
|
|
|
|
setItemSelected(1, configmenu->screen.sloppyFocus());
|
|
|
|
setItemEnabled(2, configmenu->screen.sloppyFocus());
|
|
|
|
setItemSelected(2, configmenu->screen.autoRaise());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
void Configmenu::Focusmenu::reconfigure() {
|
|
|
|
setValues();
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
void Configmenu::Focusmenu::itemSelected(int button, int index) {
|
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (item->function()) {
|
|
|
|
case 1: // click to focus
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setSloppyFocus(false);
|
|
|
|
configmenu->screen.setAutoRaise(false);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 13:58:17 +00:00
|
|
|
if (! configmenu->screen.getOpenbox().getFocusedWindow())
|
|
|
|
XSetInputFocus(configmenu->screen.getOpenbox().getXDisplay(),
|
2002-04-14 11:37:22 +00:00
|
|
|
configmenu->screen.getToolbar()->getWindowID(),
|
2002-04-11 03:20:38 +00:00
|
|
|
RevertToParent, CurrentTime);
|
|
|
|
else
|
2002-04-14 13:58:17 +00:00
|
|
|
XSetInputFocus(configmenu->screen.getOpenbox().getXDisplay(),
|
|
|
|
configmenu->screen.getOpenbox().
|
2002-04-11 03:20:38 +00:00
|
|
|
getFocusedWindow()->getClientWindow(),
|
|
|
|
RevertToParent, CurrentTime);
|
|
|
|
|
2002-04-14 11:37:22 +00:00
|
|
|
configmenu->screen.reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // sloppy focus
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setSloppyFocus(true);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 11:37:22 +00:00
|
|
|
configmenu->screen.reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // auto raise with sloppy focus
|
2002-04-17 08:30:55 +00:00
|
|
|
bool change = ((configmenu->screen.autoRaise()) ? false : true);
|
|
|
|
configmenu->screen.setAutoRaise(change);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(0, !configmenu->screen.sloppyFocus());
|
|
|
|
setItemSelected(1, configmenu->screen.sloppyFocus());
|
|
|
|
setItemEnabled(2, configmenu->screen.sloppyFocus());
|
|
|
|
setItemSelected(2, configmenu->screen.autoRaise());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
|
|
|
|
Basemenu(cm->screen) {
|
|
|
|
configmenu = cm;
|
|
|
|
|
|
|
|
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
|
|
|
|
"Window Placement"));
|
|
|
|
setInternalMenu();
|
2002-04-16 20:22:01 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartRows,
|
|
|
|
"Smart Placement (Rows)"),
|
|
|
|
BScreen::RowSmartPlacement);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartCols,
|
|
|
|
"Smart Placement (Columns)"),
|
|
|
|
BScreen::ColSmartPlacement);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuCascade,
|
|
|
|
"Cascade Placement"), BScreen::CascadePlacement);
|
2002-04-14 01:11:51 +00:00
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBestFit,
|
|
|
|
"Best Fit Placement"), BScreen::BestFitPlacement);
|
2002-04-11 03:20:38 +00:00
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
|
|
|
|
"Left to Right"), BScreen::LeftRight);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
|
|
|
|
"Right to Left"), BScreen::RightLeft);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuTopBottom,
|
|
|
|
"Top to Bottom"), BScreen::TopBottom);
|
|
|
|
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBottomTop,
|
|
|
|
"Bottom to Top"), BScreen::BottomTop);
|
|
|
|
update();
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
setValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Configmenu::Placementmenu::setValues() {
|
2002-04-17 08:30:55 +00:00
|
|
|
switch (configmenu->screen.placementPolicy()) {
|
2002-04-11 03:20:38 +00:00
|
|
|
case BScreen::RowSmartPlacement:
|
|
|
|
setItemSelected(0, True);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::ColSmartPlacement:
|
|
|
|
setItemSelected(1, True);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::CascadePlacement:
|
|
|
|
setItemSelected(2, True);
|
|
|
|
break;
|
2002-04-14 01:11:51 +00:00
|
|
|
|
|
|
|
case BScreen::BestFitPlacement:
|
|
|
|
setItemSelected(3, True);
|
|
|
|
break;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 08:30:55 +00:00
|
|
|
Bool rl = (configmenu->screen.rowPlacementDirection() ==
|
2002-04-11 03:20:38 +00:00
|
|
|
BScreen::LeftRight),
|
2002-04-17 08:30:55 +00:00
|
|
|
tb = (configmenu->screen.colPlacementDirection() ==
|
2002-04-11 03:20:38 +00:00
|
|
|
BScreen::TopBottom);
|
|
|
|
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(4, rl);
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(5, !rl);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(6, tb);
|
2002-04-17 08:30:55 +00:00
|
|
|
setItemSelected(7, !tb);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 23:07:11 +00:00
|
|
|
void Configmenu::Placementmenu::reconfigure() {
|
|
|
|
setValues();
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
void Configmenu::Placementmenu::itemSelected(int button, int index) {
|
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (item->function()) {
|
|
|
|
case BScreen::RowSmartPlacement:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setPlacementPolicy(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
setItemSelected(0, True);
|
|
|
|
setItemSelected(1, False);
|
|
|
|
setItemSelected(2, False);
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(3, False);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::ColSmartPlacement:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setPlacementPolicy(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
setItemSelected(0, False);
|
|
|
|
setItemSelected(1, True);
|
|
|
|
setItemSelected(2, False);
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(3, False);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::CascadePlacement:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setPlacementPolicy(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
setItemSelected(0, False);
|
|
|
|
setItemSelected(1, False);
|
|
|
|
setItemSelected(2, True);
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(3, False);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::BestFitPlacement:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setPlacementPolicy(item->function());
|
2002-04-14 01:11:51 +00:00
|
|
|
|
|
|
|
setItemSelected(0, False);
|
|
|
|
setItemSelected(1, False);
|
|
|
|
setItemSelected(2, False);
|
|
|
|
setItemSelected(3, True);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::LeftRight:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(4, True);
|
|
|
|
setItemSelected(5, False);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::RightLeft:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setRowPlacementDirection(BScreen::RightLeft);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-14 01:11:51 +00:00
|
|
|
setItemSelected(4, False);
|
|
|
|
setItemSelected(5, True);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::TopBottom:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setColPlacementDirection(BScreen::TopBottom);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
setItemSelected(5, True);
|
|
|
|
setItemSelected(6, False);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::BottomTop:
|
2002-04-17 08:30:55 +00:00
|
|
|
configmenu->screen.setColPlacementDirection(BScreen::BottomTop);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
setItemSelected(5, False);
|
|
|
|
setItemSelected(6, True);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|