• 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  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"));
170 
171  //translucency settings
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);
184  //TODO: remove this variable
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);
194  if (resetKompmgr)
195  config->writeEntry("ResetKompmgr",FALSE);
196 
197  // window drop shadows
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);
215 
216 
217  // Read button tooltip animation effect from kdeglobals
218  // Since we want to allow users to enable window decoration tooltips
219  // and not tdestyle tooltips and vise-versa, we don't read the
220  // "EffectNoTooltip" setting from kdeglobals.
221  TDEConfig globalConfig("kdeglobals");
222  globalConfig.setGroup("KDE");
223  topmenus = globalConfig.readBoolEntry( "macStyle", false );
224 
225  TDEConfig kdesktopcfg( "kdesktoprc", true );
226  kdesktopcfg.setGroup( "Menubar" );
227  desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
228  if( desktop_topmenu )
229  topmenus = true;
230 
231  TQToolTip::setGloballyEnabled( d->show_tooltips );
232 
233  return changed;
234  }
235 
236 
237 // restricted should be true for operations that the user may not be able to repeat
238 // if the window is moved out of the workspace (e.g. if the user moves a window
239 // by the titlebar, and moves it too high beneath Kicker at the top edge, they
240 // may not be able to move it back, unless they know about Alt+LMB)
241 Options::WindowOperation Options::windowOperation(const TQString &name, bool restricted )
242  {
243  if (name == "Move")
244  return restricted ? MoveOp : UnrestrictedMoveOp;
245  else if (name == "Resize")
246  return restricted ? ResizeOp : UnrestrictedResizeOp;
247  else if (name == "Maximize")
248  return MaximizeOp;
249  else if (name == "Minimize")
250  return MinimizeOp;
251  else if (name == "Close")
252  return CloseOp;
253  else if (name == "OnAllDesktops")
254  return OnAllDesktopsOp;
255  else if (name == "Shade")
256  return ShadeOp;
257  else if (name == "Operations")
258  return OperationsOp;
259  else if (name == "Maximize (vertical only)")
260  return VMaximizeOp;
261  else if (name == "Maximize (horizontal only)")
262  return HMaximizeOp;
263  else if (name == "Lower")
264  return LowerOp;
265  else if (name == "Shadow")
266  return ShadowOp;
267  return NoOp;
268  }
269 
270 Options::MouseCommand Options::mouseCommand(const TQString &name, bool restricted )
271  {
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;
289  return MouseNothing;
290  }
291 
292 Options::MouseWheelCommand Options::mouseWheelCommand(const TQString &name)
293  {
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;
302  }
303 
304 bool Options::showGeometryTip()
305  {
306  return show_geometry_tip;
307  }
308 
309 TQColor &Options::shadowColour(bool active)
310  {
311  return active ? shadow_colour : shadow_inactive_colour;
312  }
313 
314 bool Options::shadowWindowType(NET::WindowType t)
315  {
316  bool retval;
317 
318  switch (t)
319  {
320  case NET::Dialog:
321  case NET::Normal:
322  retval = true;
323  break;
324  case NET::Desktop:
325  case NET::Menu:
326  retval = shadow_menus;
327  break;
328  case NET::Toolbar:
329  retval = false;
330  break;
331  case NET::Dock:
332  retval = shadow_docks;
333  break;
334  case NET::Override:
335  retval = shadow_overrides;
336  break;
337  case NET::TopMenu:
338  retval = shadow_topMenus;
339  break;
340  default:
341  retval = false;
342  break;
343  }
344 
345  return retval;
346  }
347 
348 bool Options::shadowEnabled(bool active)
349  {
350  return active ? shadow_enabled :
351  (shadow_enabled && shadow_inactive_enabled);
352  }
353 
354 double Options::shadowOpacity(bool active)
355  {
356  return active ? shadow_opacity : shadow_inactive_opacity;
357  }
358 
359 int Options::shadowThickness(bool active)
360  {
361  return active ? shadow_thickness : shadow_inactive_thickness;
362  }
363 
364 int Options::shadowXOffset(bool active)
365  {
366  return active ? shadow_x_offset : shadow_inactive_x_offset;
367  }
368 
369 int Options::shadowYOffset(bool active)
370  {
371  return active ? shadow_y_offset : shadow_inactive_y_offset;
372  }
373 
374 int Options::electricBorders()
375  {
376  return electric_borders;
377  }
378 
379 int Options::electricBorderDelay()
380  {
381  return electric_border_delay;
382  }
383 
384 bool Options::checkIgnoreFocusStealing( const Client* c )
385  {
386  return ignoreFocusStealingClasses.contains(TQString::fromLatin1(c->resourceClass()));
387  }
388 
389 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta )
390  {
391  switch( com )
392  {
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;
405  default:
406  return MouseNothing;
407  }
408  }
409 #endif
410 
411 Options::MoveResizeMode Options::stringToMoveResizeMode( const TQString& s )
412  {
413  return s == "Opaque" ? Opaque : Transparent;
414  }
415 
416 const char* Options::moveResizeModeToString( MoveResizeMode mode )
417  {
418  return mode == Opaque ? "Opaque" : "Transparent";
419  }
420 
421 } // 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.8.1.2
This website is maintained by Timothy Pearson.