16 #include <tqpalette.h> 18 #include <tdeapplication.h> 19 #include <tdeconfig.h> 20 #include <tdeglobal.h> 21 #include <tdeglobalsettings.h> 22 #include <tqtooltip.h> 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 CmdTitlebarRevWheel = config->readBoolEntry(
"CommandTitlebarReverseWheel",
false);
163 CmdWindow1 = mouseCommand(config->readEntry(
"CommandWindow1",
"Activate, raise and pass click"), false );
164 CmdWindow2 = mouseCommand(config->readEntry(
"CommandWindow2",
"Activate and pass click"), false );
165 CmdWindow3 = mouseCommand(config->readEntry(
"CommandWindow3",
"Activate and pass click"), false );
166 CmdAllModKey = (config->readEntry(
"CommandAllKey",
"Alt") ==
"Meta") ? Qt::Key_Meta : Qt::Key_Alt;
167 CmdAll1 = mouseCommand(config->readEntry(
"CommandAll1",
"Move"), false );
168 CmdAll2 = mouseCommand(config->readEntry(
"CommandAll2",
"Toggle raise and lower"), false );
169 CmdAll3 = mouseCommand(config->readEntry(
"CommandAll3",
"Resize"), false );
170 CmdAllWheel = mouseWheelCommand(config->readEntry(
"CommandAllWheel",
"Nothing"));
171 CmdAllRevWheel = config->readBoolEntry(
"CommandAllReverseWheel",
false);
174 config->setGroup(
"Notification Messages" );
175 useTranslucency = config->readBoolEntry(
"UseTranslucency",
false);
176 config->setGroup(
"Translucency");
177 translucentActiveWindows = config->readBoolEntry(
"TranslucentActiveWindows",
false);
178 activeWindowOpacity = uint((config->readNumEntry(
"ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
179 translucentInactiveWindows = config->readBoolEntry(
"TranslucentInactiveWindows",
false);
180 inactiveWindowOpacity = uint((config->readNumEntry(
"InactiveWindowOpacity", 75)/100.0)*0xFFFFFFFF);
181 translucentMovingWindows = config->readBoolEntry(
"TranslucentMovingWindows",
false);
182 movingWindowOpacity = uint((config->readNumEntry(
"MovingWindowOpacity", 50)/100.0)*0xFFFFFFFF);
183 translucentDocks = config->readBoolEntry(
"TranslucentDocks",
false);
184 dockOpacity = uint((config->readNumEntry(
"DockOpacity", 80)/100.0)*0xFFFFFFFF);
185 keepAboveAsActive = config->readBoolEntry(
"TreatKeepAboveAsActive",
true);
187 useTitleMenuSlider =
true;
188 activeWindowShadowSize = config->readNumEntry(
"ActiveWindowShadowSize", 2*100);
189 inactiveWindowShadowSize = config->readNumEntry(
"InactiveWindowShadowSize", 1*100);
190 dockShadowSize = config->readNumEntry(
"DockShadowSize", 0*100);
191 menuShadowSize = config->readNumEntry(
"MenuShadowSize", 1*100);
192 removeShadowsOnMove = config->readBoolEntry(
"RemoveShadowsOnMove",
false);
193 removeShadowsOnResize = config->readBoolEntry(
"RemoveShadowsOnResize",
false);
194 onlyDecoTranslucent = config->readBoolEntry(
"OnlyDecoTranslucent",
false);
195 resetKompmgr = config->readBoolEntry(
"ResetKompmgr",
false);
197 config->writeEntry(
"ResetKompmgr",FALSE);
200 config->setGroup(
"Style");
201 shadow_colour = config->readColorEntry(
"ShadowColour", &TQt::black);
202 shadow_docks = config->readBoolEntry(
"ShadowDocks",
false);
203 shadow_menus = config->readBoolEntry(
"ShadowMenus",
false);
204 shadow_overrides = config->readBoolEntry(
"ShadowOverrides",
false);
205 shadow_topMenus = config->readBoolEntry(
"ShadowTopMenus",
false);
206 shadow_inactive_colour = config->readColorEntry(
"InactiveShadowColour", &TQt::black);
207 shadow_inactive_enabled = config->readBoolEntry(
"InactiveShadowEnabled",
false);
208 shadow_inactive_opacity = config->readDoubleNumEntry(
"InactiveShadowOpacity", 0.70);
209 shadow_inactive_thickness = config->readNumEntry(
"InactiveShadowThickness", 5);
210 shadow_inactive_x_offset = config->readNumEntry(
"InactiveShadowXOffset", 0);
211 shadow_inactive_y_offset = config->readNumEntry(
"InactiveShadowYOffset", 5);
212 shadow_enabled = config->readBoolEntry(
"ShadowEnabled",
false);
213 shadow_opacity = config->readDoubleNumEntry(
"ShadowOpacity", 0.70);
214 shadow_thickness = config->readNumEntry(
"ShadowThickness", 10);
215 shadow_x_offset = config->readNumEntry(
"ShadowXOffset", 0);
216 shadow_y_offset = config->readNumEntry(
"ShadowYOffset", 10);
223 TDEConfig globalConfig(
"kdeglobals");
224 globalConfig.setGroup(
"KDE");
225 topmenus = globalConfig.readBoolEntry(
"macStyle",
false );
227 TDEConfig kdesktopcfg(
"kdesktoprc",
true );
228 kdesktopcfg.setGroup(
"Menubar" );
229 desktop_topmenu = kdesktopcfg.readBoolEntry(
"ShowMenubar",
false );
230 if( desktop_topmenu )
233 TQToolTip::setGloballyEnabled( d->show_tooltips );
243 Options::WindowOperation Options::windowOperation(
const TQString &name,
bool restricted )
246 return restricted ? MoveOp : UnrestrictedMoveOp;
247 else if (name ==
"Resize")
248 return restricted ? ResizeOp : UnrestrictedResizeOp;
249 else if (name ==
"Maximize")
251 else if (name ==
"Minimize")
253 else if (name ==
"Close")
255 else if (name ==
"OnAllDesktops")
256 return OnAllDesktopsOp;
257 else if (name ==
"Shade")
259 else if (name ==
"Operations")
261 else if (name ==
"Maximize (vertical only)")
263 else if (name ==
"Maximize (horizontal only)")
265 else if (name ==
"Lower")
267 else if (name ==
"Shadow")
272 Options::MouseCommand Options::mouseCommand(
const TQString &name,
bool restricted )
274 TQString lowerName = name.lower();
275 if (lowerName ==
"raise")
return MouseRaise;
276 if (lowerName ==
"lower")
return MouseLower;
277 if (lowerName ==
"operations menu")
return MouseOperationsMenu;
278 if (lowerName ==
"toggle raise and lower")
return MouseToggleRaiseAndLower;
279 if (lowerName ==
"activate and raise")
return MouseActivateAndRaise;
280 if (lowerName ==
"activate and lower")
return MouseActivateAndLower;
281 if (lowerName ==
"activate")
return MouseActivate;
282 if (lowerName ==
"activate, raise and pass click")
return MouseActivateRaiseAndPassClick;
283 if (lowerName ==
"activate and pass click")
return MouseActivateAndPassClick;
284 if (lowerName ==
"activate, raise and move")
285 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
286 if (lowerName ==
"move")
return restricted ? MouseMove : MouseUnrestrictedMove;
287 if (lowerName ==
"resize")
return restricted ? MouseResize : MouseUnrestrictedResize;
288 if (lowerName ==
"shade")
return MouseShade;
289 if (lowerName ==
"minimize")
return MouseMinimize;
290 if (lowerName ==
"nothing")
return MouseNothing;
294 Options::MouseWheelCommand Options::mouseWheelCommand(
const TQString &name)
296 TQString lowerName = name.lower();
297 if (lowerName ==
"raise/lower")
return MouseWheelRaiseLower;
298 if (lowerName ==
"shade/unshade")
return MouseWheelShadeUnshade;
299 if (lowerName ==
"maximize/restore")
return MouseWheelMaximizeRestore;
300 if (lowerName ==
"above/below")
return MouseWheelAboveBelow;
301 if (lowerName ==
"previous/next desktop")
return MouseWheelPreviousNextDesktop;
302 if (lowerName ==
"change opacity")
return MouseWheelChangeOpacity;
303 return MouseWheelNothing;
306 bool Options::showGeometryTip()
308 return show_geometry_tip;
311 TQColor &Options::shadowColour(
bool active)
313 return active ? shadow_colour : shadow_inactive_colour;
316 bool Options::shadowWindowType(NET::WindowType t)
328 retval = shadow_menus;
334 retval = shadow_docks;
337 retval = shadow_overrides;
340 retval = shadow_topMenus;
350 bool Options::shadowEnabled(
bool active)
352 return active ? shadow_enabled :
353 (shadow_enabled && shadow_inactive_enabled);
356 double Options::shadowOpacity(
bool active)
358 return active ? shadow_opacity : shadow_inactive_opacity;
361 int Options::shadowThickness(
bool active)
363 return active ? shadow_thickness : shadow_inactive_thickness;
366 int Options::shadowXOffset(
bool active)
368 return active ? shadow_x_offset : shadow_inactive_x_offset;
371 int Options::shadowYOffset(
bool active)
373 return active ? shadow_y_offset : shadow_inactive_y_offset;
376 int Options::electricBorders()
378 return electric_borders;
381 int Options::electricBorderDelay()
383 return electric_border_delay;
386 bool Options::checkIgnoreFocusStealing(
const Client* c )
388 return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
391 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com,
int delta,
bool revDir )
399 case MouseWheelRaiseLower:
400 return delta > 0 ? MouseRaise : MouseLower;
401 case MouseWheelShadeUnshade:
402 return delta > 0 ? MouseSetShade : MouseUnsetShade;
403 case MouseWheelMaximizeRestore:
404 return delta > 0 ? MouseMaximize : MouseRestore;
405 case MouseWheelAboveBelow:
406 return delta > 0 ? MouseAbove : MouseBelow;
407 case MouseWheelPreviousNextDesktop:
408 return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
409 case MouseWheelChangeOpacity:
410 return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
417 Options::MoveResizeMode Options::stringToMoveResizeMode(
const TQString& s )
419 return s ==
"Opaque" ? Opaque : Transparent;
422 const char* Options::moveResizeModeToString( MoveResizeMode mode )
424 return mode == Opaque ?
"Opaque" :
"Transparent";