From 42dfcbcc0fe6019d32cd5680a86e2831fe9b6974 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 20 Jul 2010 20:43:38 +0000 Subject: [PATCH] KRandRTray fixes; minor compilation repairs git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1152360 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdeui/kdialog.h | 5 ++--- kdeui/kpanelapplet.h | 6 +++--- kdeui/kpanelextension.h | 7 +++---- kio/kio/thumbcreator.h | 4 +++- kjs/ustring.h | 1 + krandr/libkrandr.cc | 9 +++++++++ krandr/lowlevel_randr.c | 4 ++++ krandr/randr.cpp | 14 ++++++++++++++ 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/kdeui/kdialog.h b/kdeui/kdialog.h index c012a7266..78e26187d 100644 --- a/kdeui/kdialog.h +++ b/kdeui/kdialog.h @@ -21,12 +21,11 @@ #ifndef _KDIALOG_H_ #define _KDIALOG_H_ -class QLayoutItem; - #include - #include +class QLayoutItem; + /** * Dialog with extended non-modal support and methods for %KDE standard * compliance. diff --git a/kdeui/kpanelapplet.h b/kdeui/kpanelapplet.h index fa0d3adbb..a43e598f2 100644 --- a/kdeui/kpanelapplet.h +++ b/kdeui/kpanelapplet.h @@ -24,12 +24,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __kpanelapplet_h__ #define __kpanelapplet_h__ -class KConfig; -class QPopupMenu; - #include #include +class KConfig; +class QPopupMenu; + /** * @short %KDE Panel Applet class * diff --git a/kdeui/kpanelextension.h b/kdeui/kpanelextension.h index 2ff1a5133..59a9e0aef 100644 --- a/kdeui/kpanelextension.h +++ b/kdeui/kpanelextension.h @@ -24,14 +24,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __kpanelextension_h__ #define __kpanelextension_h__ +#include +#include + class QPopupMenu; class KConfig; class KPanelExtensionPrivate; -#include - -#include - /** * @short %KDE Panel Extension class * diff --git a/kio/kio/thumbcreator.h b/kio/kio/thumbcreator.h index ca8e92f83..4612a0916 100644 --- a/kio/kio/thumbcreator.h +++ b/kio/kio/thumbcreator.h @@ -20,10 +20,12 @@ #ifndef _THUMBCREATOR_H_ #define _THUMBCREATOR_H_ +#include + class QString; class QImage; /** - * This is the baseclass for "thumbnail-plugins" in KDE. Using the class + * This is the baseclass for "thumbnail-plugins" in KDE. Using the class * KIO::PreviewJob allows you to generate small images (thumbnails) * for any kind of file, where a "ThumbCreator" is available. Have a look * at kdebase/kioslave/thumbnail/ for existing ThumbCreators. diff --git a/kjs/ustring.h b/kjs/ustring.h index 2cdd2db78..34ab975e3 100644 --- a/kjs/ustring.h +++ b/kjs/ustring.h @@ -24,6 +24,7 @@ #ifndef _KJS_USTRING_H_ #define _KJS_USTRING_H_ +#include #include "global.h" /** diff --git a/krandr/libkrandr.cc b/krandr/libkrandr.cc index db40743a4..f2080f287 100644 --- a/krandr/libkrandr.cc +++ b/krandr/libkrandr.cc @@ -90,6 +90,9 @@ QString KRandrSimpleAPI::applyIccFile(QString screenName, QString fileName) { screenNumber = -1; randr_display = XOpenDisplay(NULL); randr_screen_info = read_screen_info(randr_display); + if (randr_screen_info == NULL) { + return ""; + } j=0; for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; @@ -151,6 +154,9 @@ QString KRandrSimpleAPI::applyIccFile(QString screenName, QString fileName) { screenNumber = -1; randr_display = XOpenDisplay(NULL); randr_screen_info = read_screen_info(randr_display); + if (randr_screen_info == NULL) { + return ""; + } j=0; for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; @@ -216,6 +222,9 @@ QString KRandrSimpleAPI::applyIccConfiguration(QString profileName, QString kde_ if (isValid() == true) { randr_display = XOpenDisplay(NULL); randr_screen_info = read_screen_info(randr_display); + if (randr_screen_info == NULL) { + return ""; + } for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; errorstr = applyIccFile(output_info->name, getIccFileName(profileName, output_info->name, kde_confdir)); diff --git a/krandr/lowlevel_randr.c b/krandr/lowlevel_randr.c index 5326f0334..251d3bef5 100644 --- a/krandr/lowlevel_randr.c +++ b/krandr/lowlevel_randr.c @@ -384,6 +384,10 @@ struct ScreenInfo* internal_read_screen_info (Display *display) sr = XRRGetScreenResources (display, root_window); + if (sr == NULL) { + return NULL; + } + screen_info = malloc (sizeof (struct ScreenInfo)); screen_info->dpy = display; screen_info->window = root_window; diff --git a/krandr/randr.cpp b/krandr/randr.cpp index 63c5c0450..d56b37481 100644 --- a/krandr/randr.cpp +++ b/krandr/randr.cpp @@ -562,6 +562,20 @@ RandRDisplay::RandRDisplay() return; } + // Sometimes the extension is available but does not return any screens (!) + // Check for that case + Display *randr_display = XOpenDisplay(NULL); + int screen_num; + Window root_window; + + screen_num = DefaultScreen (randr_display); + root_window = RootWindow (randr_display, screen_num); + if (XRRGetScreenResources (randr_display, root_window) == NULL) { + m_errorCode = i18n("No screens detected"); + m_valid = false; + return; + } + int major_version, minor_version; XRRQueryVersion(qt_xdisplay(), &major_version, &minor_version);