From b63fc7fc7586d2af5d45554f30e99b17d9c578e6 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 4 Oct 2011 01:32:07 +0000 Subject: Fix krandr setting multiple displays as primary Fix krandr silently failing to apply settings when underlying hardware does not support the requests git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1257190 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- krandr/libkrandr.cc | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'krandr') diff --git a/krandr/libkrandr.cc b/krandr/libkrandr.cc index 182ca7dcf..74e4184a7 100644 --- a/krandr/libkrandr.cc +++ b/krandr/libkrandr.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -50,6 +51,25 @@ unsigned int reverse_bits(register unsigned int x) return((x >> 16) | (x << 16)); } +// This routine returns the output of an arbitrary Bash command +TQString exec(const char * cmd) { + TQString bashcommand = cmd; + bashcommand = bashcommand.replace("\"", "\\\""); + bashcommand = TQString("/bin/bash -c \"%1\" 2>&1").tqarg(bashcommand); + FILE* pipe = popen(bashcommand.ascii(), "r"); + if (!pipe) return "ERROR"; + char buffer[128]; + TQString result = ""; + while(!feof(pipe)) { + if(fgets(buffer, 128, pipe) != NULL) { + result += buffer; + } + } + pclose(pipe); + result.remove(result.length(), 1); + return result; +} + TQString capitalizeString(TQString in) { return in.left(1).upper() + in.right(in.length()-1); } @@ -606,7 +626,15 @@ bool KRandrSimpleAPI::applySystemwideDisplayConfiguration(TQPtrList s } } + bool found_first_primary_monitor = false; + for (i=0;iis_primary) { + if (!found_first_primary_monitor) { + found_first_primary_monitor = true; + } + else { + screendata->is_primary = false; + } + } + } + for (i=0;iis_primary) { @@ -1083,6 +1124,8 @@ TQPtrList KRandrSimpleAPI::readCurrentDisplayConfiguration() { else screendata->is_primary = true; screendata->is_extended = screen_active; + if (!screendata->is_extended) + screendata->is_primary = false; // Get this screen's absolute position screendata->absolute_x_position = 0; -- cgit v1.2.1