From 5669b778e5426a75b50fcd63deaba022c25ab5bc Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 28 Apr 2010 23:48:46 +0000 Subject: Major enhancements to desktop screen switching--now switches screens in half the time needed before! git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1120367 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcontrol/randr/krandrtray.cpp | 69 +++++++++++++++++++-------------- kicker/kicker/core/extensionmanager.cpp | 2 +- kwin/geometry.cpp | 38 +++++++++++++----- 3 files changed, 68 insertions(+), 41 deletions(-) diff --git a/kcontrol/randr/krandrtray.cpp b/kcontrol/randr/krandrtray.cpp index 508c4a6ae..18d14bdc6 100644 --- a/kcontrol/randr/krandrtray.cpp +++ b/kcontrol/randr/krandrtray.cpp @@ -117,10 +117,10 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu) if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; - + // Deactivate this display to avoid a crash! randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; randr_screen_info->cur_output = randr_screen_info->outputs[i]; @@ -128,10 +128,10 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu) randr_screen_info->cur_output->off_set = 1; output_off(randr_screen_info, randr_screen_info->cur_output); main_low_apply(randr_screen_info); - + screenDeactivated = 1; } - + if (screenDeactivated == 1) { findPrimaryDisplay(); refresh(); @@ -139,8 +139,11 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu) // HACK // This is needed because Qt does not properly generate screen // resize events when switching screens, so KDE gets stuck in the old resolution - currentScreen()->proposeSize(GetHackResolutionParameter()); - currentScreen()->applyProposed(); + // 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(); @@ -443,7 +446,7 @@ void KRandRSystemTray::slotCycleDisplays() if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; current_on_index = i; @@ -462,7 +465,7 @@ void KRandRSystemTray::slotCycleDisplays() if (randr_screen_info->outputs[i]->cur_crtc) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; if (i > max_index) { @@ -480,7 +483,7 @@ void KRandRSystemTray::slotCycleDisplays() if (randr_screen_info->outputs[i]->cur_crtc) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; if (i > max_index) { @@ -539,10 +542,10 @@ void KRandRSystemTray::slotCycleDisplays() if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; - + // Deactivate this display to avoid a crash! randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; randr_screen_info->cur_output = randr_screen_info->outputs[i]; @@ -558,8 +561,11 @@ void KRandRSystemTray::slotCycleDisplays() // HACK // This is needed because Qt does not properly generate screen // resize events when switching screens, so KDE gets stuck in the old resolution - currentScreen()->proposeSize(GetHackResolutionParameter()); - currentScreen()->applyProposed(); + // 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(); @@ -590,7 +596,7 @@ void KRandRSystemTray::findPrimaryDisplay() if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; //printf("ACTIVE CHECK: Found output %s\n\r", output_name); @@ -611,7 +617,7 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) if (isValid() == true) { menu->insertTitle(SmallIcon("kcmkwm"), i18n("Output Port")); - + for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; // Look for ON outputs @@ -621,19 +627,19 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; //printf("ON: Found output %s\n\r", output_name); - + lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name)); menu->setItemChecked(lastIndex, true); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->setItemParameter(lastIndex, i); - + connected_displays++; } - + for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; // Look for CONNECTED outputs.... @@ -644,19 +650,19 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) if (randr_screen_info->outputs[i]->cur_crtc) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; //printf("CONNECTED, NOT ON: Found output %s\n\r", output_name); - + lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name)); menu->setItemChecked(lastIndex, false); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->setItemParameter(lastIndex, i); - + connected_displays++; } - + for (i = 0; i < randr_screen_info->n_output; i++) { output_info = randr_screen_info->outputs[i]->info; // Look for ALL outputs that are not connected.... @@ -667,18 +673,18 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu) if (randr_screen_info->outputs[i]->cur_crtc) { continue; } - + output_name = output_info->name; output_id = randr_screen_info->outputs[i]->id; //printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name); - + lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name)); menu->setItemChecked(lastIndex, false); menu->setItemEnabled(lastIndex, false); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->setItemParameter(lastIndex, i); } - + lastIndex = menu->insertItem(SmallIcon("forward"), i18n("Next available output")); if (connected_displays < 2) { menu->setItemEnabled(lastIndex, false); @@ -703,7 +709,7 @@ void KRandRSystemTray::slotOutputChanged(int parameter) if (!randr_screen_info->outputs[i]->cur_crtc) { continue; } - + num_outputs_on++; } @@ -738,8 +744,11 @@ void KRandRSystemTray::slotOutputChanged(int parameter) // HACK // This is needed because Qt does not properly generate screen // resize events when switching screens, so KDE gets stuck in the old resolution - currentScreen()->proposeSize(GetHackResolutionParameter()); - currentScreen()->applyProposed(); + // 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(); @@ -748,4 +757,4 @@ void KRandRSystemTray::slotOutputChanged(int parameter) KMessageBox::sorry(my_parent, i18n("You are attempting to deactivate the only active output

You must keep at least one display output active at all times!"), i18n("Invalid Operation Requested")); } } -} \ No newline at end of file +} diff --git a/kicker/kicker/core/extensionmanager.cpp b/kicker/kicker/core/extensionmanager.cpp index d6342b8f9..e1c2c0c57 100644 --- a/kicker/kicker/core/extensionmanager.cpp +++ b/kicker/kicker/core/extensionmanager.cpp @@ -673,7 +673,7 @@ QRect ExtensionManager::workArea(int XineramaScreen, const ExtensionContainer* e } QRect workArea; - if (XineramaScreen == XineramaAllScreens) + if ((XineramaScreen == XineramaAllScreens) || (kapp->desktop()->numScreens() < 2)) { /* special value for all screens */ workArea = Kicker::the()->kwinModule()->workArea(list); diff --git a/kwin/geometry.cpp b/kwin/geometry.cpp index cff5a3a19..4aa520d6f 100644 --- a/kwin/geometry.cpp +++ b/kwin/geometry.cpp @@ -43,7 +43,7 @@ namespace KWinInternal */ void Workspace::desktopResized() { - printf("Workspace::desktopResized()\n\r"); + //printf("Workspace::desktopResized()\n\r"); QRect geom = KApplication::desktop()->geometry(); NETSize desktop_geometry; desktop_geometry.width = geom.width(); @@ -59,7 +59,7 @@ void Workspace::desktopResized() */ void Workspace::kDestopResized() { - printf("Workspace::kDesktopResized()\n\r"); + //printf("Workspace::kDesktopResized()\n\r"); QRect geom = KApplication::desktop()->geometry(); NETSize desktop_geometry; desktop_geometry.width = geom.width(); @@ -232,38 +232,53 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con { if( desktop == NETWinInfo::OnAllDesktops || desktop == 0 ) desktop = currentDesktop(); - QDesktopWidget *desktopwidget = KApplication::desktop(); + QDesktopWidget *desktopwidget = kapp->desktop(); QRect sarea = screenarea // may be NULL during KWin initialization ? screenarea[ desktop ][ screen ] : desktopwidget->screenGeometry( screen ); QRect warea = workarea[ desktop ].isNull() - ? QApplication::desktop()->geometry() + ? kapp->desktop()->geometry() : workarea[ desktop ]; switch (opt) { case MaximizeArea: if (options->xineramaMaximizeEnabled) - return sarea; + if (desktopwidget->numScreens() < 2) + return warea; + else + return sarea; else return warea; case MaximizeFullArea: if (options->xineramaMaximizeEnabled) - return desktopwidget->screenGeometry( screen ); + if (desktopwidget->numScreens() < 2) + return desktopwidget->geometry(); + else + return desktopwidget->screenGeometry( screen ); else return desktopwidget->geometry(); case FullScreenArea: if (options->xineramaFullscreenEnabled) - return desktopwidget->screenGeometry( screen ); + if (desktopwidget->numScreens() < 2) + return desktopwidget->geometry(); + else + return desktopwidget->screenGeometry( screen ); else return desktopwidget->geometry(); case PlacementArea: if (options->xineramaPlacementEnabled) - return sarea; + if (desktopwidget->numScreens() < 2) + return warea; + else + return sarea; else return warea; case MovementArea: if (options->xineramaMovementEnabled) - return desktopwidget->screenGeometry( screen ); + if (desktopwidget->numScreens() < 2) + return desktopwidget->geometry(); + else + return desktopwidget->screenGeometry( screen ); else return desktopwidget->geometry(); case WorkArea: @@ -271,7 +286,10 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con case FullArea: return desktopwidget->geometry(); case ScreenArea: - return desktopwidget->screenGeometry( screen ); + if (desktopwidget->numScreens() < 2) + return desktopwidget->geometry(); + else + return desktopwidget->screenGeometry( screen ); } assert( false ); return QRect(); -- cgit v1.2.1