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 : active_borders( 0 ),
35 active_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 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);
63 val = config->readEntry (
"FocusPolicy",
"ClickToFocus");
64 focusPolicy = ClickToFocus;
65 if ( val ==
"FocusFollowsMouse" )
66 focusPolicy = FocusFollowsMouse;
67 else if ( val ==
"FocusUnderMouse" )
68 focusPolicy = FocusUnderMouse;
69 else if ( val ==
"FocusStrictlyUnderMouse" )
70 focusPolicy = FocusStrictlyUnderMouse;
72 val = config->readEntry (
"AltTabStyle",
"KDE");
77 separateScreenFocus = config->readBoolEntry(
"SeparateScreenFocus",
false );
78 activeMouseScreen = config->readBoolEntry(
"ActiveMouseScreen", focusPolicy != ClickToFocus );
80 rollOverDesktops = config->readBoolEntry(
"RollOverDesktops", TRUE);
84 focusStealingPreventionLevel = config->readNumEntry(
"FocusStealingPreventionLevel", 1 );
85 focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
86 if( !focusPolicyIsReasonable())
87 focusStealingPreventionLevel = 0;
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);
98 placement = Placement::policyFromString( config->readEntry(
"Placement"),
true );
99 xineramaPlacementScreen = KCLAMP( config->readNumEntry(
"XineramaPlacementScreen", -1 ),
100 -1, tqApp->desktop()->numScreens() - 1 );
102 animateShade = config->readBoolEntry(
"AnimateShade", TRUE );
103 animateMinimize = config->readBoolEntry(
"AnimateMinimize", TRUE );
104 animateMinimizeSpeed = config->readNumEntry(
"AnimateMinimizeSpeed", 5 );
106 if( focusPolicy == ClickToFocus )
109 autoRaiseInterval = 0;
111 delayFocusInterval = 0;
115 autoRaise = config->readBoolEntry(
"AutoRaise", FALSE );
116 autoRaiseInterval = config->readNumEntry(
"AutoRaiseInterval", 0 );
117 delayFocus = config->readBoolEntry(
"DelayFocus", FALSE );
118 delayFocusInterval = config->readNumEntry(
"DelayFocusInterval", 0 );
121 shadeHover = config->readBoolEntry(
"ShadeHover", FALSE );
122 shadeHoverInterval = config->readNumEntry(
"ShadeHoverInterval", 250 );
125 clickRaise = autoRaise || config->readBoolEntry(
"ClickRaise", TRUE );
127 borderSnapZone = config->readNumEntry(
"BorderSnapZone", 10);
128 windowSnapZone = config->readNumEntry(
"WindowSnapZone", 10);
129 snapOnlyWhenOverlapping=config->readBoolEntry(
"SnapOnlyWhenOverlapping",FALSE);
132 active_borders = config->readNumEntry(
"ActiveBorders", -1);
133 if (active_borders == -1) {
134 active_borders = config->readNumEntry(
"ElectricBorders", 0);
136 active_border_delay = config->readNumEntry(
"ActiveBorderDelay", -1);
137 if (active_border_delay == -1) {
138 active_border_delay = config->readNumEntry(
"ElectricBorderDelay", 150);
140 active_border_distance = config->readNumEntry(
"ActiveBorderDistance", 10);
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 );
147 ignorePositionClasses = config->readListEntry(
"IgnorePositionClasses");
148 ignoreFocusStealingClasses = config->readListEntry(
"IgnoreFocusStealingClasses");
151 for( TQStringList::Iterator it = ignorePositionClasses.begin();
152 it != ignorePositionClasses.end();
154 (*it) = (*it).lower();
155 for( TQStringList::Iterator it = ignoreFocusStealingClasses.begin();
156 it != ignoreFocusStealingClasses.end();
158 (*it) = (*it).lower();
160 killPingTimeout = config->readNumEntry(
"KillPingTimeout", 5000 );
161 hideUtilityWindowsForInactive = config->readBoolEntry(
"HideUtilityWindowsForInactive",
true );
162 showDesktopIsMinimizeAll = config->readBoolEntry(
"ShowDesktopIsMinimizeAll",
false );
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);
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);
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);
208 config->writeEntry(
"ResetKompmgr",FALSE);
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);
234 TDEConfig globalConfig(
"kdeglobals");
235 globalConfig.setGroup(
"KDE");
236 topmenus = globalConfig.readBoolEntry(
"macStyle",
false );
238 TDEConfig kdesktopcfg(
"kdesktoprc",
true );
239 kdesktopcfg.setGroup(
"Menubar" );
240 desktop_topmenu = kdesktopcfg.readBoolEntry(
"ShowMenubar",
false );
241 if( desktop_topmenu )
244 TQToolTip::setGloballyEnabled( d->show_tooltips );
254 Options::WindowOperation Options::windowOperation(
const TQString &name,
bool restricted )
257 return restricted ? MoveOp : UnrestrictedMoveOp;
258 else if (name ==
"Resize")
259 return restricted ? ResizeOp : UnrestrictedResizeOp;
260 else if (name ==
"Maximize")
262 else if (name ==
"Minimize")
264 else if (name ==
"Close")
266 else if (name ==
"OnAllDesktops")
267 return OnAllDesktopsOp;
268 else if (name ==
"Shade")
270 else if (name ==
"Operations")
272 else if (name ==
"Maximize (vertical only)")
274 else if (name ==
"Maximize (horizontal only)")
276 else if (name ==
"Lower")
278 else if (name ==
"Shadow")
283 Options::MouseCommand Options::mouseCommand(
const TQString &name,
bool restricted )
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;
305 Options::MouseWheelCommand Options::mouseWheelCommand(
const TQString &name)
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;
317 bool Options::showGeometryTip()
319 return show_geometry_tip;
322 bool Options::resetMaximizedWindowGeometry()
324 return reset_maximized_window_geometry;
327 TQColor &Options::shadowColour(
bool active)
329 return active ? shadow_colour : shadow_inactive_colour;
332 bool Options::shadowWindowType(NET::WindowType t)
344 retval = shadow_menus;
350 retval = shadow_docks;
353 retval = shadow_overrides;
356 retval = shadow_topMenus;
366 bool Options::shadowEnabled(
bool active)
368 return active ? shadow_enabled :
369 (shadow_enabled && shadow_inactive_enabled);
372 double Options::shadowOpacity(
bool active)
374 return active ? shadow_opacity : shadow_inactive_opacity;
377 int Options::shadowThickness(
bool active)
379 return active ? shadow_thickness : shadow_inactive_thickness;
382 int Options::shadowXOffset(
bool active)
384 return active ? shadow_x_offset : shadow_inactive_x_offset;
387 int Options::shadowYOffset(
bool active)
389 return active ? shadow_y_offset : shadow_inactive_y_offset;
392 int Options::activeBorders()
394 return active_borders;
397 int Options::activeBorderDelay()
399 return active_border_delay;
402 int Options::borderActivationDistance()
404 return active_border_distance;
407 bool Options::checkIgnoreFocusStealing(
const Client* c )
409 return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
412 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com,
int delta,
bool revDir )
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;
438 Options::MoveResizeMode Options::stringToMoveResizeMode(
const TQString& s )
440 return s ==
"Opaque" ? Opaque : Transparent;
443 const char* Options::moveResizeModeToString( MoveResizeMode mode )
445 return mode == Opaque ?
"Opaque" :
"Transparent";