diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-20 20:43:38 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-20 20:43:38 +0000 |
commit | 42dfcbcc0fe6019d32cd5680a86e2831fe9b6974 (patch) | |
tree | 81f15764d81efcdcb0ec9edeeaf534ce2ecc0d48 /krandr | |
parent | e7c20618e624eb27aa17abcdc471f3711e94b914 (diff) | |
download | tdelibs-42dfcbcc0fe6019d32cd5680a86e2831fe9b6974.tar.gz tdelibs-42dfcbcc0fe6019d32cd5680a86e2831fe9b6974.zip |
KRandRTray fixes; minor compilation repairs
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1152360 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krandr')
-rw-r--r-- | krandr/libkrandr.cc | 9 | ||||
-rw-r--r-- | krandr/lowlevel_randr.c | 4 | ||||
-rw-r--r-- | krandr/randr.cpp | 14 |
3 files changed, 27 insertions, 0 deletions
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); |