• 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 onlyDecoTranslucent = config->readBoolEntry("OnlyDecoTranslucent",false);
206 resetKompmgr = config->readBoolEntry("ResetKompmgr", false);
207 if (resetKompmgr)
208 config->writeEntry("ResetKompmgr",FALSE);
209
210 // window drop shadows
211 config->setGroup("Style");
212 shadow_colour = config->readColorEntry("ShadowColour", &TQt::black);
213 shadow_docks = config->readBoolEntry("ShadowDocks", false);
214 shadow_menus = config->readBoolEntry("ShadowMenus", false);
215 shadow_overrides = config->readBoolEntry("ShadowOverrides", false);
216 shadow_topMenus = config->readBoolEntry("ShadowTopMenus", false);
217 shadow_inactive_colour = config->readColorEntry("InactiveShadowColour", &TQt::black);
218 shadow_inactive_enabled = config->readBoolEntry("InactiveShadowEnabled", false);
219 shadow_inactive_opacity = config->readDoubleNumEntry("InactiveShadowOpacity", 0.70);
220 shadow_inactive_thickness = config->readNumEntry("InactiveShadowThickness", 5);
221 shadow_inactive_x_offset = config->readNumEntry("InactiveShadowXOffset", 0);
222 shadow_inactive_y_offset = config->readNumEntry("InactiveShadowYOffset", 5);
223 shadow_enabled = config->readBoolEntry("ShadowEnabled", false);
224 shadow_opacity = config->readDoubleNumEntry("ShadowOpacity", 0.70);
225 shadow_thickness = config->readNumEntry("ShadowThickness", 10);
226 shadow_x_offset = config->readNumEntry("ShadowXOffset", 0);
227 shadow_y_offset = config->readNumEntry("ShadowYOffset", 10);
228
229
230 // Read button tooltip animation effect from kdeglobals
231 // Since we want to allow users to enable window decoration tooltips
232 // and not tdestyle tooltips and vise-versa, we don't read the
233 // "EffectNoTooltip" setting from kdeglobals.
234 TDEConfig globalConfig("kdeglobals");
235 globalConfig.setGroup("KDE");
236 topmenus = globalConfig.readBoolEntry( "macStyle", false );
237
238 TDEConfig kdesktopcfg( "kdesktoprc", true );
239 kdesktopcfg.setGroup( "Menubar" );
240 desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
241 if( desktop_topmenu )
242 topmenus = true;
243
244 TQToolTip::setGloballyEnabled( d->show_tooltips );
245
246 return changed;
247 }
248
249
250// restricted should be true for operations that the user may not be able to repeat
251// if the window is moved out of the workspace (e.g. if the user moves a window
252// by the titlebar, and moves it too high beneath Kicker at the top edge, they
253// may not be able to move it back, unless they know about Alt+LMB)
254Options::WindowOperation Options::windowOperation(const TQString &name, bool restricted )
255 {
256 if (name == "Move")
257 return restricted ? MoveOp : UnrestrictedMoveOp;
258 else if (name == "Resize")
259 return restricted ? ResizeOp : UnrestrictedResizeOp;
260 else if (name == "Maximize")
261 return MaximizeOp;
262 else if (name == "Minimize")
263 return MinimizeOp;
264 else if (name == "Close")
265 return CloseOp;
266 else if (name == "OnAllDesktops")
267 return OnAllDesktopsOp;
268 else if (name == "Shade")
269 return ShadeOp;
270 else if (name == "Operations")
271 return OperationsOp;
272 else if (name == "Maximize (vertical only)")
273 return VMaximizeOp;
274 else if (name == "Maximize (horizontal only)")
275 return HMaximizeOp;
276 else if (name == "Lower")
277 return LowerOp;
278 else if (name == "Shadow")
279 return ShadowOp;
280 return NoOp;
281 }
282
283Options::MouseCommand Options::mouseCommand(const TQString &name, bool restricted )
284 {
285 TQString lowerName = name.lower();
286 if (lowerName == "raise") return MouseRaise;
287 if (lowerName == "lower") return MouseLower;
288 if (lowerName == "operations menu") return MouseOperationsMenu;
289 if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
290 if (lowerName == "activate and raise") return MouseActivateAndRaise;
291 if (lowerName == "activate and lower") return MouseActivateAndLower;
292 if (lowerName == "activate") return MouseActivate;
293 if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
294 if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
295 if (lowerName == "activate, raise and move")
296 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
297 if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
298 if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
299 if (lowerName == "shade") return MouseShade;
300 if (lowerName == "minimize") return MouseMinimize;
301 if (lowerName == "nothing") return MouseNothing;
302 return MouseNothing;
303 }
304
305Options::MouseWheelCommand Options::mouseWheelCommand(const TQString &name)
306 {
307 TQString lowerName = name.lower();
308 if (lowerName == "raise/lower") return MouseWheelRaiseLower;
309 if (lowerName == "shade/unshade") return MouseWheelShadeUnshade;
310 if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore;
311 if (lowerName == "above/below") return MouseWheelAboveBelow;
312 if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop;
313 if (lowerName == "change opacity") return MouseWheelChangeOpacity;
314 return MouseWheelNothing;
315 }
316
317bool Options::showGeometryTip()
318 {
319 return show_geometry_tip;
320 }
321
322bool Options::resetMaximizedWindowGeometry()
323 {
324 return reset_maximized_window_geometry;
325 }
326
327TQColor &Options::shadowColour(bool active)
328 {
329 return active ? shadow_colour : shadow_inactive_colour;
330 }
331
332bool Options::shadowWindowType(NET::WindowType t)
333 {
334 bool retval;
335
336 switch (t)
337 {
338 case NET::Dialog:
339 case NET::Normal:
340 retval = true;
341 break;
342 case NET::Desktop:
343 case NET::Menu:
344 retval = shadow_menus;
345 break;
346 case NET::Toolbar:
347 retval = false;
348 break;
349 case NET::Dock:
350 retval = shadow_docks;
351 break;
352 case NET::Override:
353 retval = shadow_overrides;
354 break;
355 case NET::TopMenu:
356 retval = shadow_topMenus;
357 break;
358 default:
359 retval = false;
360 break;
361 }
362
363 return retval;
364 }
365
366bool Options::shadowEnabled(bool active)
367 {
368 return active ? shadow_enabled :
369 (shadow_enabled && shadow_inactive_enabled);
370 }
371
372double Options::shadowOpacity(bool active)
373 {
374 return active ? shadow_opacity : shadow_inactive_opacity;
375 }
376
377int Options::shadowThickness(bool active)
378 {
379 return active ? shadow_thickness : shadow_inactive_thickness;
380 }
381
382int Options::shadowXOffset(bool active)
383 {
384 return active ? shadow_x_offset : shadow_inactive_x_offset;
385 }
386
387int Options::shadowYOffset(bool active)
388 {
389 return active ? shadow_y_offset : shadow_inactive_y_offset;
390 }
391
392int Options::activeBorders()
393 {
394 return active_borders;
395 }
396
397int Options::activeBorderDelay()
398 {
399 return active_border_delay;
400 }
401
402int Options::borderActivationDistance()
403 {
404 return active_border_distance;
405 }
406
407bool Options::checkIgnoreFocusStealing( const Client* c )
408 {
409 return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
410 }
411
412Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta, bool revDir )
413 {
414 if (revDir)
415 {
416 delta = -delta;
417 }
418 switch( com )
419 {
420 case MouseWheelRaiseLower:
421 return delta > 0 ? MouseRaise : MouseLower;
422 case MouseWheelShadeUnshade:
423 return delta > 0 ? MouseSetShade : MouseUnsetShade;
424 case MouseWheelMaximizeRestore:
425 return delta > 0 ? MouseMaximize : MouseRestore;
426 case MouseWheelAboveBelow:
427 return delta > 0 ? MouseAbove : MouseBelow;
428 case MouseWheelPreviousNextDesktop:
429 return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
430 case MouseWheelChangeOpacity:
431 return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
432 default:
433 return MouseNothing;
434 }
435 }
436#endif
437
438Options::MoveResizeMode Options::stringToMoveResizeMode( const TQString& s )
439 {
440 return s == "Opaque" ? Opaque : Transparent;
441 }
442
443const char* Options::moveResizeModeToString( MoveResizeMode mode )
444 {
445 return mode == Opaque ? "Opaque" : "Transparent";
446 }
447
448} // 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.