• 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 
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 
8 You can Freely distribute this program under the GNU General Public
9 License. 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 
28 namespace KWinInternal
29 {
30 
31 #ifndef KCMRULES
32 
33 Options::Options()
34  : electric_borders( 0 ),
35  electric_border_delay(0)
36  {
37  d = new KDecorationOptionsPrivate;
38  d->defaultKWinSettings();
39  updateSettings();
40  }
41 
42 Options::~Options()
43  {
44  delete d;
45  }
46 
47 unsigned 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  show_geometry_tip = config->readBoolEntry("GeometryTip", false);
57  tabboxOutline = config->readBoolEntry("TabboxOutline", true);
58 
59  TQString val;
60 
61  val = config->readEntry ("FocusPolicy", "ClickToFocus");
62  focusPolicy = ClickToFocus; // what a default :-)
63  if ( val == "FocusFollowsMouse" )
64  focusPolicy = FocusFollowsMouse;
65  else if ( val == "FocusUnderMouse" )
66  focusPolicy = FocusUnderMouse;
67  else if ( val == "FocusStrictlyUnderMouse" )
68  focusPolicy = FocusStrictlyUnderMouse;
69 
70  val = config->readEntry ("AltTabStyle", "KDE");
71  altTabStyle = KDE; // what a default :-)
72  if ( val == "CDE" )
73  altTabStyle = CDE;
74 
75  separateScreenFocus = config->readBoolEntry( "SeparateScreenFocus", false );
76  activeMouseScreen = config->readBoolEntry( "ActiveMouseScreen", focusPolicy != ClickToFocus );
77 
78  rollOverDesktops = config->readBoolEntry("RollOverDesktops", TRUE);
79 
80 // focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 2 );
81  // TODO use low level for now
82  focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 1 );
83  focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
84  if( !focusPolicyIsReasonable()) // #48786, comments #7 and later
85  focusStealingPreventionLevel = 0;
86 
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);
94  delete gc;
95 
96  placement = Placement::policyFromString( config->readEntry("Placement"), true );
97  xineramaPlacementScreen = KCLAMP( config->readNumEntry( "XineramaPlacementScreen", -1 ),
98  -1, tqApp->desktop()->numScreens() - 1 );
99 
100  animateShade = config->readBoolEntry("AnimateShade", TRUE );
101  animateMinimize = config->readBoolEntry("AnimateMinimize", TRUE );
102  animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
103 
104  if( focusPolicy == ClickToFocus )
105  {
106  autoRaise = false;
107  autoRaiseInterval = 0;
108  delayFocus = false;
109  delayFocusInterval = 0;
110  }
111  else
112  {
113  autoRaise = config->readBoolEntry("AutoRaise", FALSE );
114  autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
115  delayFocus = config->readBoolEntry("DelayFocus", FALSE );
116  delayFocusInterval = config->readNumEntry("DelayFocusInterval", 0 );
117  }
118 
119  shadeHover = config->readBoolEntry("ShadeHover", FALSE );
120  shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
121 
122  // important: autoRaise implies ClickRaise
123  clickRaise = autoRaise || config->readBoolEntry("ClickRaise", TRUE );
124 
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);
130 
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 );
135 
136  ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
137  ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
138  // Qt3.2 and older had resource class all lowercase, but Qt3.3 has it capitalized
139  // therefore Client::resourceClass() forces lowercase, force here lowercase as well
140  for( TQStringList::Iterator it = ignorePositionClasses.begin();
141  it != ignorePositionClasses.end();
142  ++it )
143  (*it) = (*it).lower();
144  for( TQStringList::Iterator it = ignoreFocusStealingClasses.begin();
145  it != ignoreFocusStealingClasses.end();
146  ++it )
147  (*it) = (*it).lower();
148 
149  killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
150  hideUtilityWindowsForInactive = config->readBoolEntry( "HideUtilityWindowsForInactive", true );
151  showDesktopIsMinimizeAll = config->readBoolEntry( "ShowDesktopIsMinimizeAll", false );
152 
153  // Mouse bindings
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);
172 
173  //translucency settings
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);
186  //TODO: remove this variable
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);
196  if (resetKompmgr)
197  config->writeEntry("ResetKompmgr",FALSE);
198 
199  // window drop shadows
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);
217 
218 
219  // Read button tooltip animation effect from kdeglobals
220  // Since we want to allow users to enable window decoration tooltips
221  // and not tdestyle tooltips and vise-versa, we don't read the
222  // "EffectNoTooltip" setting from kdeglobals.
223  TDEConfig globalConfig("kdeglobals");
224  globalConfig.setGroup("KDE");
225  topmenus = globalConfig.readBoolEntry( "macStyle", false );
226 
227  TDEConfig kdesktopcfg( "kdesktoprc", true );
228  kdesktopcfg.setGroup( "Menubar" );
229  desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
230  if( desktop_topmenu )
231  topmenus = true;
232 
233  TQToolTip::setGloballyEnabled( d->show_tooltips );
234 
235  return changed;
236  }
237 
238 
239 // restricted should be true for operations that the user may not be able to repeat
240 // if the window is moved out of the workspace (e.g. if the user moves a window
241 // by the titlebar, and moves it too high beneath Kicker at the top edge, they
242 // may not be able to move it back, unless they know about Alt+LMB)
243 Options::WindowOperation Options::windowOperation(const TQString &name, bool restricted )
244  {
245  if (name == "Move")
246  return restricted ? MoveOp : UnrestrictedMoveOp;
247  else if (name == "Resize")
248  return restricted ? ResizeOp : UnrestrictedResizeOp;
249  else if (name == "Maximize")
250  return MaximizeOp;
251  else if (name == "Minimize")
252  return MinimizeOp;
253  else if (name == "Close")
254  return CloseOp;
255  else if (name == "OnAllDesktops")
256  return OnAllDesktopsOp;
257  else if (name == "Shade")
258  return ShadeOp;
259  else if (name == "Operations")
260  return OperationsOp;
261  else if (name == "Maximize (vertical only)")
262  return VMaximizeOp;
263  else if (name == "Maximize (horizontal only)")
264  return HMaximizeOp;
265  else if (name == "Lower")
266  return LowerOp;
267  else if (name == "Shadow")
268  return ShadowOp;
269  return NoOp;
270  }
271 
272 Options::MouseCommand Options::mouseCommand(const TQString &name, bool restricted )
273  {
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;
291  return MouseNothing;
292  }
293 
294 Options::MouseWheelCommand Options::mouseWheelCommand(const TQString &name)
295  {
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;
304  }
305 
306 bool Options::showGeometryTip()
307  {
308  return show_geometry_tip;
309  }
310 
311 TQColor &Options::shadowColour(bool active)
312  {
313  return active ? shadow_colour : shadow_inactive_colour;
314  }
315 
316 bool Options::shadowWindowType(NET::WindowType t)
317  {
318  bool retval;
319 
320  switch (t)
321  {
322  case NET::Dialog:
323  case NET::Normal:
324  retval = true;
325  break;
326  case NET::Desktop:
327  case NET::Menu:
328  retval = shadow_menus;
329  break;
330  case NET::Toolbar:
331  retval = false;
332  break;
333  case NET::Dock:
334  retval = shadow_docks;
335  break;
336  case NET::Override:
337  retval = shadow_overrides;
338  break;
339  case NET::TopMenu:
340  retval = shadow_topMenus;
341  break;
342  default:
343  retval = false;
344  break;
345  }
346 
347  return retval;
348  }
349 
350 bool Options::shadowEnabled(bool active)
351  {
352  return active ? shadow_enabled :
353  (shadow_enabled && shadow_inactive_enabled);
354  }
355 
356 double Options::shadowOpacity(bool active)
357  {
358  return active ? shadow_opacity : shadow_inactive_opacity;
359  }
360 
361 int Options::shadowThickness(bool active)
362  {
363  return active ? shadow_thickness : shadow_inactive_thickness;
364  }
365 
366 int Options::shadowXOffset(bool active)
367  {
368  return active ? shadow_x_offset : shadow_inactive_x_offset;
369  }
370 
371 int Options::shadowYOffset(bool active)
372  {
373  return active ? shadow_y_offset : shadow_inactive_y_offset;
374  }
375 
376 int Options::electricBorders()
377  {
378  return electric_borders;
379  }
380 
381 int Options::electricBorderDelay()
382  {
383  return electric_border_delay;
384  }
385 
386 bool Options::checkIgnoreFocusStealing( const Client* c )
387  {
388  return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
389  }
390 
391 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta, bool revDir )
392  {
393  if (revDir)
394  {
395  delta = -delta;
396  }
397  switch( com )
398  {
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;
411  default:
412  return MouseNothing;
413  }
414  }
415 #endif
416 
417 Options::MoveResizeMode Options::stringToMoveResizeMode( const TQString& s )
418  {
419  return s == "Opaque" ? Opaque : Transparent;
420  }
421 
422 const char* Options::moveResizeModeToString( MoveResizeMode mode )
423  {
424  return mode == Opaque ? "Opaque" : "Transparent";
425  }
426 
427 } // namespace
KWinInternal::Client::Client
Client(Workspace *ws)
Definition: client.cpp:89
KWinInternal
Definition: activation.cpp:34

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.8.13
This website is maintained by Timothy Pearson.