16 #include <tqpalette.h>
18 #include <tdeapplication.h>
19 #include <tdeconfig.h>
20 #include <tdeglobal.h>
21 #include <tdeglobalsettings.h>
22 #include <tqtooltip.h>
28 namespace KWinInternal
34 : electric_borders( 0 ),
35 electric_border_delay(0)
37 d =
new KDecorationOptionsPrivate;
38 d->defaultKWinSettings();
47 unsigned long Options::updateSettings()
49 TDEConfig *config = TDEGlobal::config();
50 unsigned long changed = 0;
51 changed |= d->updateKWinSettings( config );
53 config->setGroup(
"Windows" );
54 moveMode = stringToMoveResizeMode( config->readEntry(
"MoveMode",
"Opaque" ));
55 resizeMode = stringToMoveResizeMode( config->readEntry(
"ResizeMode",
"Opaque" ));
56 show_geometry_tip = config->readBoolEntry(
"GeometryTip",
false);
57 tabboxOutline = config->readBoolEntry(
"TabboxOutline",
true);
61 val = config->readEntry (
"FocusPolicy",
"ClickToFocus");
62 focusPolicy = ClickToFocus;
63 if ( val ==
"FocusFollowsMouse" )
64 focusPolicy = FocusFollowsMouse;
65 else if ( val ==
"FocusUnderMouse" )
66 focusPolicy = FocusUnderMouse;
67 else if ( val ==
"FocusStrictlyUnderMouse" )
68 focusPolicy = FocusStrictlyUnderMouse;
70 val = config->readEntry (
"AltTabStyle",
"KDE");
75 separateScreenFocus = config->readBoolEntry(
"SeparateScreenFocus",
false );
76 activeMouseScreen = config->readBoolEntry(
"ActiveMouseScreen", focusPolicy != ClickToFocus );
78 rollOverDesktops = config->readBoolEntry(
"RollOverDesktops", TRUE);
82 focusStealingPreventionLevel = config->readNumEntry(
"FocusStealingPreventionLevel", 1 );
83 focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
84 if( !focusPolicyIsReasonable())
85 focusStealingPreventionLevel = 0;
87 TDEConfig *gc =
new TDEConfig(
"kdeglobals",
false,
false);
88 gc->setGroup(
"Windows");
89 xineramaEnabled = gc->readBoolEntry (
"XineramaEnabled",
true );
90 xineramaPlacementEnabled = gc->readBoolEntry (
"XineramaPlacementEnabled",
true);
91 xineramaMovementEnabled = gc->readBoolEntry (
"XineramaMovementEnabled",
true);
92 xineramaMaximizeEnabled = gc->readBoolEntry (
"XineramaMaximizeEnabled",
true);
93 xineramaFullscreenEnabled = gc->readBoolEntry (
"XineramaFullscreenEnabled",
true);
96 placement = Placement::policyFromString( config->readEntry(
"Placement"), true );
97 xineramaPlacementScreen = KCLAMP( config->readNumEntry(
"XineramaPlacementScreen", -1 ),
98 -1, tqApp->desktop()->numScreens() - 1 );
100 animateShade = config->readBoolEntry(
"AnimateShade", TRUE );
101 animateMinimize = config->readBoolEntry(
"AnimateMinimize", TRUE );
102 animateMinimizeSpeed = config->readNumEntry(
"AnimateMinimizeSpeed", 5 );
104 if( focusPolicy == ClickToFocus )
107 autoRaiseInterval = 0;
109 delayFocusInterval = 0;
113 autoRaise = config->readBoolEntry(
"AutoRaise", FALSE );
114 autoRaiseInterval = config->readNumEntry(
"AutoRaiseInterval", 0 );
115 delayFocus = config->readBoolEntry(
"DelayFocus", FALSE );
116 delayFocusInterval = config->readNumEntry(
"DelayFocusInterval", 0 );
119 shadeHover = config->readBoolEntry(
"ShadeHover", FALSE );
120 shadeHoverInterval = config->readNumEntry(
"ShadeHoverInterval", 250 );
123 clickRaise = autoRaise || config->readBoolEntry(
"ClickRaise", TRUE );
125 borderSnapZone = config->readNumEntry(
"BorderSnapZone", 10);
126 windowSnapZone = config->readNumEntry(
"WindowSnapZone", 10);
127 snapOnlyWhenOverlapping=config->readBoolEntry(
"SnapOnlyWhenOverlapping",FALSE);
128 electric_borders = config->readNumEntry(
"ElectricBorders", 0);
129 electric_border_delay = config->readNumEntry(
"ElectricBorderDelay", 150);
131 OpTitlebarDblClick = windowOperation( config->readEntry(
"TitlebarDoubleClickCommand",
"Shade"), true );
132 d->OpMaxButtonLeftClick = windowOperation( config->readEntry(
"MaximizeButtonLeftClickCommand",
"Maximize"), true );
133 d->OpMaxButtonMiddleClick = windowOperation( config->readEntry(
"MaximizeButtonMiddleClickCommand",
"Maximize (vertical only)"), true );
134 d->OpMaxButtonRightClick = windowOperation( config->readEntry(
"MaximizeButtonRightClickCommand",
"Maximize (horizontal only)"), true );
136 ignorePositionClasses = config->readListEntry(
"IgnorePositionClasses");
137 ignoreFocusStealingClasses = config->readListEntry(
"IgnoreFocusStealingClasses");
140 for( TQStringList::Iterator it = ignorePositionClasses.begin();
141 it != ignorePositionClasses.end();
143 (*it) = (*it).lower();
144 for( TQStringList::Iterator it = ignoreFocusStealingClasses.begin();
145 it != ignoreFocusStealingClasses.end();
147 (*it) = (*it).lower();
149 killPingTimeout = config->readNumEntry(
"KillPingTimeout", 5000 );
150 hideUtilityWindowsForInactive = config->readBoolEntry(
"HideUtilityWindowsForInactive",
true );
151 showDesktopIsMinimizeAll = config->readBoolEntry(
"ShowDesktopIsMinimizeAll",
false );
154 config->setGroup(
"MouseBindings");
155 CmdActiveTitlebar1 = mouseCommand(config->readEntry(
"CommandActiveTitlebar1",
"Raise"), true );
156 CmdActiveTitlebar2 = mouseCommand(config->readEntry(
"CommandActiveTitlebar2",
"Lower"), true );
157 CmdActiveTitlebar3 = mouseCommand(config->readEntry(
"CommandActiveTitlebar3",
"Operations menu"), true );
158 CmdInactiveTitlebar1 = mouseCommand(config->readEntry(
"CommandInactiveTitlebar1",
"Activate and raise"), true );
159 CmdInactiveTitlebar2 = mouseCommand(config->readEntry(
"CommandInactiveTitlebar2",
"Activate and lower"), true );
160 CmdInactiveTitlebar3 = mouseCommand(config->readEntry(
"CommandInactiveTitlebar3",
"Operations menu"), true );
161 CmdTitlebarWheel = mouseWheelCommand(config->readEntry(
"CommandTitlebarWheel",
"Nothing"));
162 CmdWindow1 = mouseCommand(config->readEntry(
"CommandWindow1",
"Activate, raise and pass click"), false );
163 CmdWindow2 = mouseCommand(config->readEntry(
"CommandWindow2",
"Activate and pass click"), false );
164 CmdWindow3 = mouseCommand(config->readEntry(
"CommandWindow3",
"Activate and pass click"), false );
165 CmdAllModKey = (config->readEntry(
"CommandAllKey",
"Alt") ==
"Meta") ? Qt::Key_Meta : Qt::Key_Alt;
166 CmdAll1 = mouseCommand(config->readEntry(
"CommandAll1",
"Move"), false );
167 CmdAll2 = mouseCommand(config->readEntry(
"CommandAll2",
"Toggle raise and lower"), false );
168 CmdAll3 = mouseCommand(config->readEntry(
"CommandAll3",
"Resize"), false );
169 CmdAllWheel = mouseWheelCommand(config->readEntry(
"CommandAllWheel",
"Nothing"));
172 config->setGroup(
"Notification Messages" );
173 useTranslucency = config->readBoolEntry(
"UseTranslucency",
false);
174 config->setGroup(
"Translucency");
175 translucentActiveWindows = config->readBoolEntry(
"TranslucentActiveWindows",
false);
176 activeWindowOpacity = uint((config->readNumEntry(
"ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
177 translucentInactiveWindows = config->readBoolEntry(
"TranslucentInactiveWindows",
false);
178 inactiveWindowOpacity = uint((config->readNumEntry(
"InactiveWindowOpacity", 75)/100.0)*0xFFFFFFFF);
179 translucentMovingWindows = config->readBoolEntry(
"TranslucentMovingWindows",
false);
180 movingWindowOpacity = uint((config->readNumEntry(
"MovingWindowOpacity", 50)/100.0)*0xFFFFFFFF);
181 translucentDocks = config->readBoolEntry(
"TranslucentDocks",
false);
182 dockOpacity = uint((config->readNumEntry(
"DockOpacity", 80)/100.0)*0xFFFFFFFF);
183 keepAboveAsActive = config->readBoolEntry(
"TreatKeepAboveAsActive",
true);
185 useTitleMenuSlider =
true;
186 activeWindowShadowSize = config->readNumEntry(
"ActiveWindowShadowSize", 2*100);
187 inactiveWindowShadowSize = config->readNumEntry(
"InactiveWindowShadowSize", 1*100);
188 dockShadowSize = config->readNumEntry(
"DockShadowSize", 0*100);
189 menuShadowSize = config->readNumEntry(
"MenuShadowSize", 1*100);
190 removeShadowsOnMove = config->readBoolEntry(
"RemoveShadowsOnMove",
false);
191 removeShadowsOnResize = config->readBoolEntry(
"RemoveShadowsOnResize",
false);
192 onlyDecoTranslucent = config->readBoolEntry(
"OnlyDecoTranslucent",
false);
193 resetKompmgr = config->readBoolEntry(
"ResetKompmgr",
false);
195 config->writeEntry(
"ResetKompmgr",FALSE);
198 config->setGroup(
"Style");
199 shadow_colour = config->readColorEntry(
"ShadowColour", &TQt::black);
200 shadow_docks = config->readBoolEntry(
"ShadowDocks",
false);
201 shadow_menus = config->readBoolEntry(
"ShadowMenus",
false);
202 shadow_overrides = config->readBoolEntry(
"ShadowOverrides",
false);
203 shadow_topMenus = config->readBoolEntry(
"ShadowTopMenus",
false);
204 shadow_inactive_colour = config->readColorEntry(
"InactiveShadowColour", &TQt::black);
205 shadow_inactive_enabled = config->readBoolEntry(
"InactiveShadowEnabled",
false);
206 shadow_inactive_opacity = config->readDoubleNumEntry(
"InactiveShadowOpacity", 0.70);
207 shadow_inactive_thickness = config->readNumEntry(
"InactiveShadowThickness", 5);
208 shadow_inactive_x_offset = config->readNumEntry(
"InactiveShadowXOffset", 0);
209 shadow_inactive_y_offset = config->readNumEntry(
"InactiveShadowYOffset", 5);
210 shadow_enabled = config->readBoolEntry(
"ShadowEnabled",
false);
211 shadow_opacity = config->readDoubleNumEntry(
"ShadowOpacity", 0.70);
212 shadow_thickness = config->readNumEntry(
"ShadowThickness", 10);
213 shadow_x_offset = config->readNumEntry(
"ShadowXOffset", 0);
214 shadow_y_offset = config->readNumEntry(
"ShadowYOffset", 10);
221 TDEConfig globalConfig(
"kdeglobals");
222 globalConfig.setGroup(
"KDE");
223 topmenus = globalConfig.readBoolEntry(
"macStyle",
false );
225 TDEConfig kdesktopcfg(
"kdesktoprc",
true );
226 kdesktopcfg.setGroup(
"Menubar" );
227 desktop_topmenu = kdesktopcfg.readBoolEntry(
"ShowMenubar",
false );
228 if( desktop_topmenu )
231 TQToolTip::setGloballyEnabled( d->show_tooltips );
241 Options::WindowOperation Options::windowOperation(
const TQString &name,
bool restricted )
244 return restricted ? MoveOp : UnrestrictedMoveOp;
245 else if (name ==
"Resize")
246 return restricted ? ResizeOp : UnrestrictedResizeOp;
247 else if (name ==
"Maximize")
249 else if (name ==
"Minimize")
251 else if (name ==
"Close")
253 else if (name ==
"OnAllDesktops")
254 return OnAllDesktopsOp;
255 else if (name ==
"Shade")
257 else if (name ==
"Operations")
259 else if (name ==
"Maximize (vertical only)")
261 else if (name ==
"Maximize (horizontal only)")
263 else if (name ==
"Lower")
265 else if (name ==
"Shadow")
270 Options::MouseCommand Options::mouseCommand(
const TQString &name,
bool restricted )
272 TQString lowerName = name.lower();
273 if (lowerName ==
"raise")
return MouseRaise;
274 if (lowerName ==
"lower")
return MouseLower;
275 if (lowerName ==
"operations menu")
return MouseOperationsMenu;
276 if (lowerName ==
"toggle raise and lower")
return MouseToggleRaiseAndLower;
277 if (lowerName ==
"activate and raise")
return MouseActivateAndRaise;
278 if (lowerName ==
"activate and lower")
return MouseActivateAndLower;
279 if (lowerName ==
"activate")
return MouseActivate;
280 if (lowerName ==
"activate, raise and pass click")
return MouseActivateRaiseAndPassClick;
281 if (lowerName ==
"activate and pass click")
return MouseActivateAndPassClick;
282 if (lowerName ==
"activate, raise and move")
283 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
284 if (lowerName ==
"move")
return restricted ? MouseMove : MouseUnrestrictedMove;
285 if (lowerName ==
"resize")
return restricted ? MouseResize : MouseUnrestrictedResize;
286 if (lowerName ==
"shade")
return MouseShade;
287 if (lowerName ==
"minimize")
return MouseMinimize;
288 if (lowerName ==
"nothing")
return MouseNothing;
292 Options::MouseWheelCommand Options::mouseWheelCommand(
const TQString &name)
294 TQString lowerName = name.lower();
295 if (lowerName ==
"raise/lower")
return MouseWheelRaiseLower;
296 if (lowerName ==
"shade/unshade")
return MouseWheelShadeUnshade;
297 if (lowerName ==
"maximize/restore")
return MouseWheelMaximizeRestore;
298 if (lowerName ==
"above/below")
return MouseWheelAboveBelow;
299 if (lowerName ==
"previous/next desktop")
return MouseWheelPreviousNextDesktop;
300 if (lowerName ==
"change opacity")
return MouseWheelChangeOpacity;
301 return MouseWheelNothing;
304 bool Options::showGeometryTip()
306 return show_geometry_tip;
309 TQColor &Options::shadowColour(
bool active)
311 return active ? shadow_colour : shadow_inactive_colour;
314 bool Options::shadowWindowType(NET::WindowType t)
326 retval = shadow_menus;
332 retval = shadow_docks;
335 retval = shadow_overrides;
338 retval = shadow_topMenus;
348 bool Options::shadowEnabled(
bool active)
350 return active ? shadow_enabled :
351 (shadow_enabled && shadow_inactive_enabled);
354 double Options::shadowOpacity(
bool active)
356 return active ? shadow_opacity : shadow_inactive_opacity;
359 int Options::shadowThickness(
bool active)
361 return active ? shadow_thickness : shadow_inactive_thickness;
364 int Options::shadowXOffset(
bool active)
366 return active ? shadow_x_offset : shadow_inactive_x_offset;
369 int Options::shadowYOffset(
bool active)
371 return active ? shadow_y_offset : shadow_inactive_y_offset;
374 int Options::electricBorders()
376 return electric_borders;
379 int Options::electricBorderDelay()
381 return electric_border_delay;
384 bool Options::checkIgnoreFocusStealing(
const Client* c )
386 return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
389 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com,
int delta )
393 case MouseWheelRaiseLower:
394 return delta > 0 ? MouseRaise : MouseLower;
395 case MouseWheelShadeUnshade:
396 return delta > 0 ? MouseSetShade : MouseUnsetShade;
397 case MouseWheelMaximizeRestore:
398 return delta > 0 ? MouseMaximize : MouseRestore;
399 case MouseWheelAboveBelow:
400 return delta > 0 ? MouseAbove : MouseBelow;
401 case MouseWheelPreviousNextDesktop:
402 return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
403 case MouseWheelChangeOpacity:
404 return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
411 Options::MoveResizeMode Options::stringToMoveResizeMode(
const TQString& s )
413 return s ==
"Opaque" ? Opaque : Transparent;
416 const char* Options::moveResizeModeToString( MoveResizeMode mode )
418 return mode == Opaque ?
"Opaque" :
"Transparent";