summaryrefslogtreecommitdiffstats
path: root/kcontrol/randr
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-09 16:39:31 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-09 16:39:31 -0600
commite88baf8334b8ff7ce92e555cbaffee949672d4b8 (patch)
treecaac57be5b2bb29eef81ffb58341829e2571ebb3 /kcontrol/randr
parent477e956a04dfb244814f274e98a8d6f4beb84f3f (diff)
downloadtdebase-e88baf8334b8ff7ce92e555cbaffee949672d4b8.tar.gz
tdebase-e88baf8334b8ff7ce92e555cbaffee949672d4b8.zip
Automatically deactivate disconnected display devices
Notify user on display add/remove/change Add advanced display configuration option to krandr menu Add option to autohide kicker panels on inactive Xinerama screens and enable by default Update hwmanager treeview on device change
Diffstat (limited to 'kcontrol/randr')
-rw-r--r--kcontrol/randr/krandrtray.cpp118
-rw-r--r--kcontrol/randr/krandrtray.h5
2 files changed, 83 insertions, 40 deletions
diff --git a/kcontrol/randr/krandrtray.cpp b/kcontrol/randr/krandrtray.cpp
index c3ba773ea..3cfe4cdda 100644
--- a/kcontrol/randr/krandrtray.cpp
+++ b/kcontrol/randr/krandrtray.cpp
@@ -88,6 +88,9 @@ KRandRSystemTray::KRandRSystemTray(TQWidget* parent, const char *name)
if (cur_profile != "") {
applyIccConfiguration(cur_profile, NULL);
}
+
+ TDEHardwareDevices *hwdevices = KGlobal::hardwareDevices();
+ connect(hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(deviceChanged(TDEGenericDevice*)));
}
/*!
@@ -133,27 +136,73 @@ void KRandRSystemTray::mousePressEvent(TQMouseEvent* e)
KSystemTray::mousePressEvent(e);
}
-void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
+void KRandRSystemTray::reloadDisplayConfiguration()
{
- //int lastIndex = 0;
-
// Reload the randr configuration...
XRROutputInfo *output_info;
char *output_name;
RROutput output_id;
int i;
- int lastIndex = 0;
+ int activeOutputs = 0;
int screenDeactivated = 0;
if (isValid() == true) {
randr_screen_info = read_screen_info(randr_display);
+ // Count outputs in the active state
+ activeOutputs = 0;
for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs
if (!randr_screen_info->outputs[i]->cur_crtc) {
continue;
}
+ // Look for CONNECTED outputs
+ if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
+ continue;
+ }
+
+ activeOutputs++;
+ }
+
+ if (activeOutputs < 1) {
+ // Houston, we have a problem!
+ // There are no active displays!
+ // Activate the first connected display we come across...
+ for (i = 0; i < randr_screen_info->n_output; i++) {
+ output_info = randr_screen_info->outputs[i]->info;
+ // Look for OFF outputs
+ if (randr_screen_info->outputs[i]->cur_crtc) {
+ continue;
+ }
+ // Look for CONNECTED outputs
+ if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
+ continue;
+ }
+
+ // Activate this output
+ randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc;
+ randr_screen_info->cur_output = randr_screen_info->outputs[i];
+ randr_screen_info->cur_output->auto_set = 1;
+ randr_screen_info->cur_output->off_set = 0;
+ output_auto (randr_screen_info, randr_screen_info->cur_output);
+ i=main_low_apply(randr_screen_info);
+
+ if (randr_screen_info->outputs[i]->cur_crtc) {
+ // Output successfully activated!
+ set_primary_output(randr_screen_info, randr_screen_info->cur_output->id);
+ break;
+ }
+ }
+ }
+
+ for (i = 0; i < randr_screen_info->n_output; i++) {
+ output_info = randr_screen_info->outputs[i]->info;
+ // Look for ON outputs
+ if (!randr_screen_info->outputs[i]->cur_crtc) {
+ continue;
+ }
+ // Look for DISCONNECTED outputs
if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) {
continue;
}
@@ -176,19 +225,17 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
findPrimaryDisplay();
refresh();
- // HACK
- // This is needed because Qt does not properly generate screen
- // resize events when switching screens, so KDE gets stuck in the old resolution
- // This only seems to happen with more than one screen, so check for that condition...
- if (kapp->desktop()->numScreens() > 1) {
- currentScreen()->proposeSize(GetHackResolutionParameter());
- currentScreen()->applyProposed();
- }
-
currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed();
}
}
+}
+
+void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
+{
+ int lastIndex = 0;
+
+ reloadDisplayConfiguration();
menu->clear();
menu->setCheckable(true);
@@ -236,8 +283,8 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
menu->insertTitle(SmallIcon("randr"), i18n("Global Configuation"));
- KAction *actColors = new KAction( i18n( "Configure Color Profiles..." ),
- SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotColorConfig() ),
+ KAction *actColors = new KAction( i18n( "Configure Displays..." ),
+ SmallIconSet( "configure" ), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT( slotDisplayConfig() ),
actionCollection() );
actColors->plug( menu );
@@ -469,12 +516,12 @@ void KRandRSystemTray::slotPrefs()
kcm->exec();
}
-void KRandRSystemTray::slotColorConfig()
+void KRandRSystemTray::slotDisplayConfig()
{
KCMultiDialog *kcm = new KCMultiDialog( KDialogBase::Plain, i18n( "Configure" ), this );
- kcm->addModule( "iccconfig" );
- kcm->setPlainCaption( i18n( "Configure Display Color Profiles" ) );
+ kcm->addModule( "displayconfig" );
+ kcm->setPlainCaption( i18n( "Configure Displays" ) );
kcm->exec();
}
@@ -596,6 +643,9 @@ void KRandRSystemTray::slotCycleDisplays()
i=main_low_apply(randr_screen_info);
if (randr_screen_info->outputs[current_on_index]->cur_crtc) {
+ // Output successfully activated!
+ set_primary_output(randr_screen_info, randr_screen_info->cur_output->id);
+
if (prev_on_index != -1) {
if (randr_screen_info->outputs[prev_on_index]->cur_crtc != NULL) {
if (RR_Disconnected != randr_screen_info->outputs[prev_on_index]->info->connection) {
@@ -635,16 +685,6 @@ void KRandRSystemTray::slotCycleDisplays()
findPrimaryDisplay();
refresh();
- // HACK
- // This is needed because Qt does not properly generate screen
- // resize events when switching screens, so KDE gets stuck in the old resolution
- // This only seems to happen with more than one screen, so check for that condition...
- if (kapp->desktop()->numScreens() > 1) {
-// currentScreen()->proposeSize(GetHackResolutionParameter());
-// currentScreen()->applyProposed();
- kapp->desktop()->emitResizedSignal(currentScreenIndex());
- }
-
currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed();
}
@@ -781,9 +821,7 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
{
XRROutputInfo *output_info;
char *output_name;
- RROutput output_id;
int i;
- Status s;
int num_outputs_on;
num_outputs_on = 0;
@@ -825,15 +863,6 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
findPrimaryDisplay();
refresh();
- // HACK
- // This is needed because Qt does not properly generate screen
- // resize events when switching screens, so KDE gets stuck in the old resolution
- // This only seems to happen with more than one screen, so check for that condition...
- if (kapp->desktop()->numScreens() > 1) {
- currentScreen()->proposeSize(GetHackResolutionParameter());
- currentScreen()->applyProposed();
- }
-
currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed();
}
@@ -842,3 +871,14 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
}
}
}
+
+void KRandRSystemTray::deviceChanged (TDEGenericDevice* device) {
+ if (device->type() == TDEGenericDeviceType::Monitor) {
+ KRandrPassivePopup::message(
+ i18n("New display output options are available!"),
+ i18n("A screen has been added, removed, or changed"), SmallIcon("window_fullscreen"),
+ this, "ScreenChangeNotification");
+
+ reloadDisplayConfiguration();
+ }
+} \ No newline at end of file
diff --git a/kcontrol/randr/krandrtray.h b/kcontrol/randr/krandrtray.h
index f0d8d7367..60d966a15 100644
--- a/kcontrol/randr/krandrtray.h
+++ b/kcontrol/randr/krandrtray.h
@@ -25,6 +25,7 @@
#include <kglobalaccel.h>
#include <libkrandr/libkrandr.h>
+#include <tdehardwaredevices.h>
class KHelpMenu;
class KPopupMenu;
@@ -50,7 +51,7 @@ protected slots:
void slotOrientationChanged(int parameter);
void slotRefreshRateChanged(int parameter);
void slotPrefs();
- void slotColorConfig();
+ void slotDisplayConfig();
void slotSKeys();
void slotSettingsChanged(int category);
void slotCycleDisplays();
@@ -67,6 +68,7 @@ private:
int GetDefaultResolutionParameter();
int GetHackResolutionParameter();
void findPrimaryDisplay();
+ void reloadDisplayConfiguration();
bool m_popupUp;
KHelpMenu* m_help;
@@ -85,6 +87,7 @@ private:
private slots:
void _quit();
+ void deviceChanged (TDEGenericDevice*);
};
#endif