• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin
 

twin

  • twin
options.cpp
1/*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7
8You can Freely distribute this program under the GNU General Public
9License. See the file "COPYING" for the exact licensing terms.
10******************************************************************/
11
12#include "options.h"
13
14#ifndef KCMRULES
15
16#include <tqpalette.h>
17#include <tqpixmap.h>
18#include <tdeapplication.h>
19#include <tdeconfig.h>
20#include <tdeglobal.h>
21#include <tdeglobalsettings.h>
22#include <tqtooltip.h>
23
24#include "client.h"
25
26#endif
27
28namespace KWinInternal
29{
30
31#ifndef KCMRULES
32
33Options::Options()
34 : active_borders( 0 ),
35 active_border_delay(0)
36 {
37 d = new KDecorationOptionsPrivate;
38 d->defaultKWinSettings();
39 updateSettings();
40 }
41
42Options::~Options()
43 {
44 delete d;
45 }
46
47unsigned long Options::updateSettings()
48 {
49 TDEConfig *config = TDEGlobal::config();
50 unsigned long changed = 0;
51 changed |= d->updateKWinSettings( config ); // read decoration settings
52
53 config->setGroup( "Windows" );
54 moveMode = stringToMoveResizeMode(config->readEntry("MoveMode", "Opaque"));
55 resizeMode = stringToMoveResizeMode(config->readEntry("ResizeMode", "Opaque"));
56 tilingMode = stringToMoveResizeMode(config->readEntry("TilingMode", "Opaque"));
57 show_geometry_tip = config->readBoolEntry("GeometryTip", false);
58 reset_maximized_window_geometry = config->readBoolEntry("ResetMaximizedWindowGeometry", false);
59 tabboxOutline = config->readBoolEntry("TabboxOutline", true);
60
61 TQString val;
62
63 val = config->readEntry ("FocusPolicy", "ClickToFocus");
64 focusPolicy = ClickToFocus; // what a default :-)
65 if ( val == "FocusFollowsMouse" )
66 focusPolicy = FocusFollowsMouse;
67 else if ( val == "FocusUnderMouse" )
68 focusPolicy = FocusUnderMouse;
69 else if ( val == "FocusStrictlyUnderMouse" )
70 focusPolicy = FocusStrictlyUnderMouse;
71
72 val = config->readEntry ("AltTabStyle", "KDE");
73 altTabStyle = KDE; // what a default :-)
74 if ( val == "CDE" )
75 altTabStyle = CDE;
76
77 separateScreenFocus = config->readBoolEntry( "SeparateScreenFocus", false );
78 activeMouseScreen = config->readBoolEntry( "ActiveMouseScreen", focusPolicy != ClickToFocus );
79
80 rollOverDesktops = config->readBoolEntry("RollOverDesktops", true);
81
82// focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 2 );
83 // TODO use low level for now
84 focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 1 );
85 focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
86 if( !focusPolicyIsReasonable()) // #48786, comments #7 and later
87 focusStealingPreventionLevel = 0;
88
89 TDEConfig *gc = new TDEConfig("kdeglobals", false, false);
90 gc->setGroup("Windows");
91 xineramaEnabled = gc->readBoolEntry ("XineramaEnabled", true );
92 xineramaPlacementEnabled = gc->readBoolEntry ("XineramaPlacementEnabled", true);
93 xineramaMovementEnabled = gc->readBoolEntry ("XineramaMovementEnabled", true);
94 xineramaMaximizeEnabled = gc->readBoolEntry ("XineramaMaximizeEnabled", true);
95 xineramaFullscreenEnabled = gc->readBoolEntry ("XineramaFullscreenEnabled", true);
96 delete gc;
97
98 placement = Placement::policyFromString( config->readEntry("Placement"), true );
99 xineramaPlacementScreen = KCLAMP( config->readNumEntry( "XineramaPlacementScreen", -1 ),
100 -1, tqApp->desktop()->numScreens() - 1 );
101
102 animateShade = config->readBoolEntry("AnimateShade", true );
103 animateMinimize = config->readBoolEntry("AnimateMinimize", true );
104 animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
105
106 if( focusPolicy == ClickToFocus )
107 {
108 autoRaise = false;
109 autoRaiseInterval = 0;
110 delayFocus = false;
111 delayFocusInterval = 0;
112 }
113 else
114 {
115 autoRaise = config->readBoolEntry("AutoRaise", false );
116 autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
117 delayFocus = config->readBoolEntry("DelayFocus", false );
118 delayFocusInterval = config->readNumEntry("DelayFocusInterval", 0 );
119 }
120
121 shadeHover = config->readBoolEntry("ShadeHover", false );
122 shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
123
124 // important: autoRaise implies ClickRaise
125 clickRaise = autoRaise || config->readBoolEntry("ClickRaise", true );
126
127 borderSnapZone = config->readNumEntry("BorderSnapZone", 10);
128 windowSnapZone = config->readNumEntry("WindowSnapZone", 10);
129 snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",false);
130
131 // active borders: compatibility with old option names (Electric*)
132 active_borders = config->readNumEntry("ActiveBorders", -1);
133 if (active_borders == -1) {
134 active_borders = config->readNumEntry("ElectricBorders", 0);
135 }
136 active_border_delay = config->readNumEntry("ActiveBorderDelay", -1);
137 if (active_border_delay == -1) {
138 active_border_delay = config->readNumEntry("ElectricBorderDelay", 150);
139 }
140 active_border_distance = config->readNumEntry("ActiveBorderDistance", 10);
141
142 OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade"), true );
143 d->OpMaxButtonLeftClick = windowOperation( config->readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true );
144 d->OpMaxButtonMiddleClick = windowOperation( config->readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true );
145 d->OpMaxButtonRightClick = windowOperation( config->readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true );
146
147 ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
148 ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
149 // Qt3.2 and older had resource class all lowercase, but Qt3.3 has it capitalized
150 // therefore Client::resourceClass() forces lowercase, force here lowercase as well
151 for( TQStringList::Iterator it = ignorePositionClasses.begin();
152 it != ignorePositionClasses.end();
153 ++it )
154 (*it) = (*it).lower();
155 for( TQStringList::Iterator it = ignoreFocusStealingClasses.begin();
156 it != ignoreFocusStealingClasses.end();
157 ++it )
158 (*it) = (*it).lower();
159
160 killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
161 hideUtilityWindowsForInactive = config->readBoolEntry( "HideUtilityWindowsForInactive", true );
162 showDesktopIsMinimizeAll = config->readBoolEntry( "ShowDesktopIsMinimizeAll", false );
163
164 // Mouse bindings
165 config->setGroup( "MouseBindings");
166 CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
167 CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
168 CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
169 CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
170 CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
171 CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
172 CmdTitlebarWheel = mouseWheelCommand(config->readEntry("CommandTitlebarWheel","Nothing"));
173 CmdTitlebarRevWheel = config->readBoolEntry("CommandTitlebarReverseWheel", false);
174 CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false );
175 CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false );
176 CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false );
177 CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? TQt::Key_Meta : TQt::Key_Alt;
178 CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
179 CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
180 CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
181 CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
182 CmdAllRevWheel = config->readBoolEntry("CommandAllReverseWheel", false);
183
184 //translucency settings
185 config->setGroup( "Notification Messages" );
186 useTranslucency = config->readBoolEntry("UseTranslucency", false);
187 config->setGroup( "Translucency");
188 translucentActiveWindows = config->readBoolEntry("TranslucentActiveWindows", false);
189 activeWindowOpacity = uint((config->readNumEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
190 translucentInactiveWindows = config->readBoolEntry("TranslucentInactiveWindows", false);
191 inactiveWindowOpacity = uint((config->readNumEntry("InactiveWindowOpacity", 75)/100.0)*0xFFFFFFFF);
192 translucentMovingWindows = config->readBoolEntry("TranslucentMovingWindows", false);
193 movingWindowOpacity = uint((config->readNumEntry("MovingWindowOpacity", 50)/100.0)*0xFFFFFFFF);
194 translucentDocks = config->readBoolEntry("TranslucentDocks", false);
195 dockOpacity = uint((config->readNumEntry("DockOpacity", 80)/100.0)*0xFFFFFFFF);
196 keepAboveAsActive = config->readBoolEntry("TreatKeepAboveAsActive", true);
197 //TODO: remove this variable
198 useTitleMenuSlider = true;
199 activeWindowShadowSize = config->readNumEntry("ActiveWindowShadowSize", 2*100);
200 inactiveWindowShadowSize = config->readNumEntry("InactiveWindowShadowSize", 1*100);
201 dockShadowSize = config->readNumEntry("DockShadowSize", 0*100);
202 menuShadowSize = config->readNumEntry("MenuShadowSize", 1*100);
203 removeShadowsOnMove = config->readBoolEntry("RemoveShadowsOnMove", false);
204 removeShadowsOnResize = config->readBoolEntry("RemoveShadowsOnResize", false);
205 resetKompmgr = config->readBoolEntry("ResetKompmgr", false);
206 if (resetKompmgr)
207 config->writeEntry("ResetKompmgr",false);
208
209 // window drop shadows
210 config->setGroup("Style");
211 shadow_colour = config->readColorEntry("ShadowColour", &TQt::black);
212 shadow_docks = config->readBoolEntry("ShadowDocks", false);
213 shadow_menus = config->readBoolEntry("ShadowMenus", false);
214 shadow_overrides = config->readBoolEntry("ShadowOverrides", false);
215 shadow_topMenus = config->readBoolEntry("ShadowTopMenus", false);
216 shadow_inactive_colour = config->readColorEntry("InactiveShadowColour", &TQt::black);
217 shadow_inactive_enabled = config->readBoolEntry("InactiveShadowEnabled", false);
218 shadow_inactive_opacity = config->readDoubleNumEntry("InactiveShadowOpacity", 0.70);
219 shadow_inactive_thickness = config->readNumEntry("InactiveShadowThickness", 5);
220 shadow_inactive_x_offset = config->readNumEntry("InactiveShadowXOffset", 0);
221 shadow_inactive_y_offset = config->readNumEntry("InactiveShadowYOffset", 5);
222 shadow_enabled = config->readBoolEntry("ShadowEnabled", false);
223 shadow_opacity = config->readDoubleNumEntry("ShadowOpacity", 0.70);
224 shadow_thickness = config->readNumEntry("ShadowThickness", 10);
225 shadow_x_offset = config->readNumEntry("ShadowXOffset", 0);
226 shadow_y_offset = config->readNumEntry("ShadowYOffset", 10);
227
228
229 // Read button tooltip animation effect from kdeglobals
230 // Since we want to allow users to enable window decoration tooltips
231 // and not tdestyle tooltips and vise-versa, we don't read the
232 // "EffectNoTooltip" setting from kdeglobals.
233 TDEConfig globalConfig("kdeglobals");
234 globalConfig.setGroup("KDE");
235 topmenus = globalConfig.readBoolEntry( "macStyle", false );
236
237 TDEConfig kdesktopcfg( "kdesktoprc", true );
238 kdesktopcfg.setGroup( "Menubar" );
239 desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
240 if( desktop_topmenu )
241 topmenus = true;
242
243 TQToolTip::setGloballyEnabled( d->show_tooltips );
244
245 return changed;
246 }
247
248
249// restricted should be true for operations that the user may not be able to repeat
250// if the window is moved out of the workspace (e.g. if the user moves a window
251// by the titlebar, and moves it too high beneath Kicker at the top edge, they
252// may not be able to move it back, unless they know about Alt+LMB)
253Options::WindowOperation Options::windowOperation(const TQString &name, bool restricted )
254 {
255 if (name == "Move")
256 return restricted ? MoveOp : UnrestrictedMoveOp;
257 else if (name == "Resize")
258 return restricted ? ResizeOp : UnrestrictedResizeOp;
259 else if (name == "Maximize")
260 return MaximizeOp;
261 else if (name == "Minimize")
262 return MinimizeOp;
263 else if (name == "Close")
264 return CloseOp;
265 else if (name == "OnAllDesktops")
266 return OnAllDesktopsOp;
267 else if (name == "Shade")
268 return ShadeOp;
269 else if (name == "Operations")
270 return OperationsOp;
271 else if (name == "Maximize (vertical only)")
272 return VMaximizeOp;
273 else if (name == "Maximize (horizontal only)")
274 return HMaximizeOp;
275 else if (name == "Lower")
276 return LowerOp;
277 else if (name == "Shadow")
278 return ShadowOp;
279 return NoOp;
280 }
281
282Options::MouseCommand Options::mouseCommand(const TQString &name, bool restricted )
283 {
284 TQString lowerName = name.lower();
285 if (lowerName == "raise") return MouseRaise;
286 if (lowerName == "lower") return MouseLower;
287 if (lowerName == "operations menu") return MouseOperationsMenu;
288 if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
289 if (lowerName == "activate and raise") return MouseActivateAndRaise;
290 if (lowerName == "activate and lower") return MouseActivateAndLower;
291 if (lowerName == "activate") return MouseActivate;
292 if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
293 if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
294 if (lowerName == "activate, raise and move")
295 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
296 if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
297 if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
298 if (lowerName == "shade") return MouseShade;
299 if (lowerName == "minimize") return MouseMinimize;
300 if (lowerName == "nothing") return MouseNothing;
301 return MouseNothing;
302 }
303
304Options::MouseWheelCommand Options::mouseWheelCommand(const TQString &name)
305 {
306 TQString lowerName = name.lower();
307 if (lowerName == "raise/lower") return MouseWheelRaiseLower;
308 if (lowerName == "shade/unshade") return MouseWheelShadeUnshade;
309 if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore;
310 if (lowerName == "above/below") return MouseWheelAboveBelow;
311 if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop;
312 if (lowerName == "change opacity") return MouseWheelChangeOpacity;
313 return MouseWheelNothing;
314 }
315
316bool Options::showGeometryTip()
317 {
318 return show_geometry_tip;
319 }
320
321bool Options::resetMaximizedWindowGeometry()
322 {
323 return reset_maximized_window_geometry;
324 }
325
326TQColor &Options::shadowColour(bool active)
327 {
328 return active ? shadow_colour : shadow_inactive_colour;
329 }
330
331bool Options::shadowWindowType(NET::WindowType t)
332 {
333 bool retval;
334
335 switch (t)
336 {
337 case NET::Dialog:
338 case NET::Normal:
339 retval = true;
340 break;
341 case NET::Desktop:
342 case NET::Menu:
343 retval = shadow_menus;
344 break;
345 case NET::Toolbar:
346 retval = false;
347 break;
348 case NET::Dock:
349 retval = shadow_docks;
350 break;
351 case NET::Override:
352 retval = shadow_overrides;
353 break;
354 case NET::TopMenu:
355 retval = shadow_topMenus;
356 break;
357 default:
358 retval = false;
359 break;
360 }
361
362 return retval;
363 }
364
365bool Options::shadowEnabled(bool active)
366 {
367 return active ? shadow_enabled :
368 (shadow_enabled && shadow_inactive_enabled);
369 }
370
371double Options::shadowOpacity(bool active)
372 {
373 return active ? shadow_opacity : shadow_inactive_opacity;
374 }
375
376int Options::shadowThickness(bool active)
377 {
378 return active ? shadow_thickness : shadow_inactive_thickness;
379 }
380
381int Options::shadowXOffset(bool active)
382 {
383 return active ? shadow_x_offset : shadow_inactive_x_offset;
384 }
385
386int Options::shadowYOffset(bool active)
387 {
388 return active ? shadow_y_offset : shadow_inactive_y_offset;
389 }
390
391int Options::activeBorders()
392 {
393 return active_borders;
394 }
395
396int Options::activeBorderDelay()
397 {
398 return active_border_delay;
399 }
400
401int Options::borderActivationDistance()
402 {
403 return active_border_distance;
404 }
405
406bool Options::checkIgnoreFocusStealing( const Client* c )
407 {
408 return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
409 }
410
411Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta, bool revDir )
412 {
413 if (revDir)
414 {
415 delta = -delta;
416 }
417 switch( com )
418 {
419 case MouseWheelRaiseLower:
420 return delta > 0 ? MouseRaise : MouseLower;
421 case MouseWheelShadeUnshade:
422 return delta > 0 ? MouseSetShade : MouseUnsetShade;
423 case MouseWheelMaximizeRestore:
424 return delta > 0 ? MouseMaximize : MouseRestore;
425 case MouseWheelAboveBelow:
426 return delta > 0 ? MouseAbove : MouseBelow;
427 case MouseWheelPreviousNextDesktop:
428 return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
429 case MouseWheelChangeOpacity:
430 return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
431 default:
432 return MouseNothing;
433 }
434 }
435#endif
436
437Options::MoveResizeMode Options::stringToMoveResizeMode( const TQString& s )
438 {
439 return s == "Opaque" ? Opaque : Transparent;
440 }
441
442const char* Options::moveResizeModeToString( MoveResizeMode mode )
443 {
444 return mode == Opaque ? "Opaque" : "Transparent";
445 }
446
447} // namespace

twin

Skip menu "twin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

twin

Skip menu "twin"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin by doxygen 1.9.4
This website is maintained by Timothy Pearson.