]> Dogcows Code - chaz/openbox/blob - src/Configmenu.cc
- raise the window during maximization if the user clicked the maximize button, but...
[chaz/openbox] / src / Configmenu.cc
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)
5 //
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:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
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.
23
24 #ifdef HAVE_CONFIG_H
25 # include "../config.h"
26 #endif // HAVE_CONFIG_H
27
28 #include "i18n.hh"
29 #include "Configmenu.hh"
30 #include "Image.hh"
31 #include "Toolbar.hh"
32 #include "Window.hh"
33 #include "Screen.hh"
34
35 Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
36 setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config options"));
37 setInternalMenu();
38
39 focusmenu = new Focusmenu(this);
40 placementmenu = new Placementmenu(this);
41
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);
56 update();
57
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());
63 }
64
65 Configmenu::~Configmenu(void) {
66 delete focusmenu;
67 delete placementmenu;
68 }
69
70 void Configmenu::itemSelected(int button, unsigned int index) {
71 if (button != 1)
72 return;
73
74 BasemenuItem *item = find(index);
75
76 if (!item->function())
77 return;
78
79 switch(item->function()) {
80 case 1: { // dither
81 getScreen()->getImageControl()->
82 setDither((! getScreen()->getImageControl()->doDither()));
83
84 setItemSelected(index, getScreen()->getImageControl()->doDither());
85
86 break;
87 }
88
89 case 2: { // opaque move
90 getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove()));
91
92 setItemSelected(index, getScreen()->doOpaqueMove());
93
94 break;
95 }
96
97 case 3: { // full maximization
98 getScreen()->saveFullMax((! getScreen()->doFullMax()));
99
100 setItemSelected(index, getScreen()->doFullMax());
101
102 break;
103 }
104 case 4: { // focus new windows
105 getScreen()->saveFocusNew((! getScreen()->doFocusNew()));
106
107 setItemSelected(index, getScreen()->doFocusNew());
108 break;
109 }
110
111 case 5: { // focus last window on workspace
112 getScreen()->saveFocusLast((! getScreen()->doFocusLast()));
113 setItemSelected(index, getScreen()->doFocusLast());
114 break;
115 }
116 } // switch
117 }
118
119
120 void Configmenu::reconfigure(void) {
121 focusmenu->reconfigure();
122 placementmenu->reconfigure();
123
124 Basemenu::reconfigure();
125 }
126
127
128 Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
129 setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel, "Focus Model"));
130 setInternalMenu();
131
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);
136 update();
137
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());
144 }
145
146
147 void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
148 if (button != 1)
149 return;
150
151 BasemenuItem *item = find(index);
152
153 if (!item->function())
154 return;
155
156 switch (item->function()) {
157 case 1: // click to focus
158 getScreen()->toggleFocusModel(BScreen::ClickToFocus);
159 break;
160
161 case 2: // sloppy focus
162 getScreen()->toggleFocusModel(BScreen::SloppyFocus);
163 break;
164
165 case 3: // auto raise with sloppy focus
166 getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
167 break;
168
169 case 4: // click raise with sloppy focus
170 getScreen()->saveClickRaise(! getScreen()->doClickRaise());
171 getScreen()->updateFocusModel();
172 break;
173 }
174
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());
181 }
182
183
184 Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
185 Basemenu(cm->getScreen()) {
186 setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement"));
187 setInternalMenu();
188
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"),
196 BScreen::LeftRight);
197 insert(i18n(ConfigmenuSet, ConfigmenuRightLeft, "Right to Left"),
198 BScreen::RightLeft);
199 insert(i18n(ConfigmenuSet, ConfigmenuTopBottom, "Top to Bottom"),
200 BScreen::TopBottom);
201 insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"),
202 BScreen::BottomTop);
203 update();
204
205 switch (getScreen()->getPlacementPolicy()) {
206 case BScreen::RowSmartPlacement:
207 setItemSelected(0, True);
208 break;
209
210 case BScreen::ColSmartPlacement:
211 setItemSelected(1, True);
212 break;
213
214 case BScreen::CascadePlacement:
215 setItemSelected(2, True);
216 break;
217 }
218
219 bool rl = (getScreen()->getRowPlacementDirection() ==
220 BScreen::LeftRight),
221 tb = (getScreen()->getColPlacementDirection() ==
222 BScreen::TopBottom);
223
224 setItemSelected(3, rl);
225 setItemSelected(4, ! rl);
226
227 setItemSelected(5, tb);
228 setItemSelected(6, ! tb);
229 }
230
231
232 void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
233 if (button != 1)
234 return;
235
236 BasemenuItem *item = find(index);
237
238 if (!item->function())
239 return;
240
241 switch (item->function()) {
242 case BScreen::RowSmartPlacement:
243 getScreen()->savePlacementPolicy(item->function());
244
245 setItemSelected(0, True);
246 setItemSelected(1, False);
247 setItemSelected(2, False);
248
249 break;
250
251 case BScreen::ColSmartPlacement:
252 getScreen()->savePlacementPolicy(item->function());
253
254 setItemSelected(0, False);
255 setItemSelected(1, True);
256 setItemSelected(2, False);
257
258 break;
259
260 case BScreen::CascadePlacement:
261 getScreen()->savePlacementPolicy(item->function());
262
263 setItemSelected(0, False);
264 setItemSelected(1, False);
265 setItemSelected(2, True);
266
267 break;
268
269 case BScreen::LeftRight:
270 getScreen()->saveRowPlacementDirection(BScreen::LeftRight);
271
272 setItemSelected(3, True);
273 setItemSelected(4, False);
274
275 break;
276
277 case BScreen::RightLeft:
278 getScreen()->saveRowPlacementDirection(BScreen::RightLeft);
279
280 setItemSelected(3, False);
281 setItemSelected(4, True);
282
283 break;
284
285 case BScreen::TopBottom:
286 getScreen()->saveColPlacementDirection(BScreen::TopBottom);
287
288 setItemSelected(5, True);
289 setItemSelected(6, False);
290
291 break;
292
293 case BScreen::BottomTop:
294 getScreen()->saveColPlacementDirection(BScreen::BottomTop);
295
296 setItemSelected(5, False);
297 setItemSelected(6, True);
298
299 break;
300 }
301 }
This page took 0.051828 seconds and 4 git commands to generate.