add more spacing
[personal-kdebase.git] / workspace / kcontrol / randr / randrdisplay.h
blob218cd384687e097d87bd48071c40c7ded54b1939
1 /*
2 * Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
3 * Copyright (c) 2002,2003 Hamish Rodda <rodda@kde.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __RANDRDISPLAY_H__
21 #define __RANDRDISPLAY_H__
23 #include <QWidget>
24 #include <KConfig>
25 #include "randr.h"
27 #include <X11/Xlib.h>
29 class RandRDisplay
31 public:
32 RandRDisplay();
33 ~RandRDisplay();
35 bool isValid() const;
36 const QString& errorCode() const;
37 const QString& version() const;
39 int eventBase() const;
40 int errorBase() const;
42 int screenIndexOfWidget(QWidget* widget);
44 int numScreens() const;
45 LegacyRandRScreen* legacyScreen(int index);
46 LegacyRandRScreen* currentLegacyScreen();
47 #ifdef HAS_RANDR_1_2
48 RandRScreen* screen(int index);
49 RandRScreen* currentScreen();
50 #endif
51 void setCurrentScreen(int index);
52 int currentScreenIndex() const;
54 bool needsRefresh() const;
55 void refresh();
57 /**
58 * Loads saved settings.
60 * @param config the KConfig object to load from
61 * @param loadScreens whether to call LegacyRandRScreen::load() for each screen
62 * @retuns true if the settings should be applied on KDE startup.
64 bool loadDisplay(KConfig& config, bool loadScreens = true);
65 void saveDisplay(KConfig& config, bool applyOnStartup, bool syncTrayApp);
67 static bool applyOnStartup(KConfig& config);
68 static bool syncTrayApp(KConfig& config);
70 void applyProposed(bool confirm = true);
72 bool canHandle(const XEvent *e) const;
73 void handleEvent(XEvent *e);
75 private:
76 Display *m_dpy;
77 int m_numScreens;
78 int m_currentScreenIndex;
79 LegacyScreenList m_legacyScreens;
80 #ifdef HAS_RANDR_1_2
81 ScreenList m_screens;
82 #endif
84 bool m_valid;
85 QString m_errorCode;
86 QString m_version;
88 int m_eventBase;
89 int m_errorBase;
92 #endif