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
v3.5.13-sru
tpearson 14 years ago
parent 42980db88e
commit 5669b778e5

@ -117,10 +117,10 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
// Deactivate this display to avoid a crash! // Deactivate this display to avoid a crash!
randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; 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 = randr_screen_info->outputs[i];
@ -128,10 +128,10 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
randr_screen_info->cur_output->off_set = 1; randr_screen_info->cur_output->off_set = 1;
output_off(randr_screen_info, randr_screen_info->cur_output); output_off(randr_screen_info, randr_screen_info->cur_output);
main_low_apply(randr_screen_info); main_low_apply(randr_screen_info);
screenDeactivated = 1; screenDeactivated = 1;
} }
if (screenDeactivated == 1) { if (screenDeactivated == 1) {
findPrimaryDisplay(); findPrimaryDisplay();
refresh(); refresh();
@ -139,8 +139,11 @@ void KRandRSystemTray::contextMenuAboutToShow(KPopupMenu* menu)
// HACK // HACK
// This is needed because Qt does not properly generate screen // This is needed because Qt does not properly generate screen
// resize events when switching screens, so KDE gets stuck in the old resolution // resize events when switching screens, so KDE gets stuck in the old resolution
currentScreen()->proposeSize(GetHackResolutionParameter()); // This only seems to happen with more than one screen, so check for that condition...
currentScreen()->applyProposed(); if (kapp->desktop()->numScreens() > 1) {
currentScreen()->proposeSize(GetHackResolutionParameter());
currentScreen()->applyProposed();
}
currentScreen()->proposeSize(GetDefaultResolutionParameter()); currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed(); currentScreen()->applyProposed();
@ -443,7 +446,7 @@ void KRandRSystemTray::slotCycleDisplays()
if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
current_on_index = i; current_on_index = i;
@ -462,7 +465,7 @@ void KRandRSystemTray::slotCycleDisplays()
if (randr_screen_info->outputs[i]->cur_crtc) { if (randr_screen_info->outputs[i]->cur_crtc) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
if (i > max_index) { if (i > max_index) {
@ -480,7 +483,7 @@ void KRandRSystemTray::slotCycleDisplays()
if (randr_screen_info->outputs[i]->cur_crtc) { if (randr_screen_info->outputs[i]->cur_crtc) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
if (i > max_index) { if (i > max_index) {
@ -539,10 +542,10 @@ void KRandRSystemTray::slotCycleDisplays()
if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) { if (RR_Disconnected != randr_screen_info->outputs[i]->info->connection) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
// Deactivate this display to avoid a crash! // Deactivate this display to avoid a crash!
randr_screen_info->cur_crtc = randr_screen_info->outputs[i]->cur_crtc; 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 = randr_screen_info->outputs[i];
@ -558,8 +561,11 @@ void KRandRSystemTray::slotCycleDisplays()
// HACK // HACK
// This is needed because Qt does not properly generate screen // This is needed because Qt does not properly generate screen
// resize events when switching screens, so KDE gets stuck in the old resolution // resize events when switching screens, so KDE gets stuck in the old resolution
currentScreen()->proposeSize(GetHackResolutionParameter()); // This only seems to happen with more than one screen, so check for that condition...
currentScreen()->applyProposed(); if (kapp->desktop()->numScreens() > 1) {
currentScreen()->proposeSize(GetHackResolutionParameter());
currentScreen()->applyProposed();
}
currentScreen()->proposeSize(GetDefaultResolutionParameter()); currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed(); currentScreen()->applyProposed();
@ -590,7 +596,7 @@ void KRandRSystemTray::findPrimaryDisplay()
if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
//printf("ACTIVE CHECK: Found output %s\n\r", output_name); //printf("ACTIVE CHECK: Found output %s\n\r", output_name);
@ -611,7 +617,7 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
if (isValid() == true) { if (isValid() == true) {
menu->insertTitle(SmallIcon("kcmkwm"), i18n("Output Port")); menu->insertTitle(SmallIcon("kcmkwm"), i18n("Output Port"));
for (i = 0; i < randr_screen_info->n_output; i++) { for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info; output_info = randr_screen_info->outputs[i]->info;
// Look for ON outputs // Look for ON outputs
@ -621,19 +627,19 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) { if (RR_Disconnected == randr_screen_info->outputs[i]->info->connection) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
//printf("ON: Found output %s\n\r", output_name); //printf("ON: Found output %s\n\r", output_name);
lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name)); lastIndex = menu->insertItem(i18n("%1 (Active)").arg(output_name));
menu->setItemChecked(lastIndex, true); menu->setItemChecked(lastIndex, true);
menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int)));
menu->setItemParameter(lastIndex, i); menu->setItemParameter(lastIndex, i);
connected_displays++; connected_displays++;
} }
for (i = 0; i < randr_screen_info->n_output; i++) { for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info; output_info = randr_screen_info->outputs[i]->info;
// Look for CONNECTED outputs.... // Look for CONNECTED outputs....
@ -644,19 +650,19 @@ void KRandRSystemTray::addOutputMenu(KPopupMenu* menu)
if (randr_screen_info->outputs[i]->cur_crtc) { if (randr_screen_info->outputs[i]->cur_crtc) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
//printf("CONNECTED, NOT ON: Found output %s\n\r", output_name); //printf("CONNECTED, NOT ON: Found output %s\n\r", output_name);
lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name)); lastIndex = menu->insertItem(i18n("%1 (Connected, Inactive)").arg(output_name));
menu->setItemChecked(lastIndex, false); menu->setItemChecked(lastIndex, false);
menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int)));
menu->setItemParameter(lastIndex, i); menu->setItemParameter(lastIndex, i);
connected_displays++; connected_displays++;
} }
for (i = 0; i < randr_screen_info->n_output; i++) { for (i = 0; i < randr_screen_info->n_output; i++) {
output_info = randr_screen_info->outputs[i]->info; output_info = randr_screen_info->outputs[i]->info;
// Look for ALL outputs that are not connected.... // 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) { if (randr_screen_info->outputs[i]->cur_crtc) {
continue; continue;
} }
output_name = output_info->name; output_name = output_info->name;
output_id = randr_screen_info->outputs[i]->id; output_id = randr_screen_info->outputs[i]->id;
//printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name); //printf("DISCONNECTED, NOT ON: Found output %s\n\r", output_name);
lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name)); lastIndex = menu->insertItem(i18n("%1 (Disconnected, Inactive)").arg(output_name));
menu->setItemChecked(lastIndex, false); menu->setItemChecked(lastIndex, false);
menu->setItemEnabled(lastIndex, false); menu->setItemEnabled(lastIndex, false);
menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int))); menu->connectItem(lastIndex, this, SLOT(slotOutputChanged(int)));
menu->setItemParameter(lastIndex, i); menu->setItemParameter(lastIndex, i);
} }
lastIndex = menu->insertItem(SmallIcon("forward"), i18n("Next available output")); lastIndex = menu->insertItem(SmallIcon("forward"), i18n("Next available output"));
if (connected_displays < 2) { if (connected_displays < 2) {
menu->setItemEnabled(lastIndex, false); menu->setItemEnabled(lastIndex, false);
@ -703,7 +709,7 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
if (!randr_screen_info->outputs[i]->cur_crtc) { if (!randr_screen_info->outputs[i]->cur_crtc) {
continue; continue;
} }
num_outputs_on++; num_outputs_on++;
} }
@ -738,8 +744,11 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
// HACK // HACK
// This is needed because Qt does not properly generate screen // This is needed because Qt does not properly generate screen
// resize events when switching screens, so KDE gets stuck in the old resolution // resize events when switching screens, so KDE gets stuck in the old resolution
currentScreen()->proposeSize(GetHackResolutionParameter()); // This only seems to happen with more than one screen, so check for that condition...
currentScreen()->applyProposed(); if (kapp->desktop()->numScreens() > 1) {
currentScreen()->proposeSize(GetHackResolutionParameter());
currentScreen()->applyProposed();
}
currentScreen()->proposeSize(GetDefaultResolutionParameter()); currentScreen()->proposeSize(GetDefaultResolutionParameter());
currentScreen()->applyProposed(); currentScreen()->applyProposed();
@ -748,4 +757,4 @@ void KRandRSystemTray::slotOutputChanged(int parameter)
KMessageBox::sorry(my_parent, i18n("<b>You are attempting to deactivate the only active output</b><p>You must keep at least one display output active at all times!"), i18n("Invalid Operation Requested")); KMessageBox::sorry(my_parent, i18n("<b>You are attempting to deactivate the only active output</b><p>You must keep at least one display output active at all times!"), i18n("Invalid Operation Requested"));
} }
} }
} }

@ -673,7 +673,7 @@ QRect ExtensionManager::workArea(int XineramaScreen, const ExtensionContainer* e
} }
QRect workArea; QRect workArea;
if (XineramaScreen == XineramaAllScreens) if ((XineramaScreen == XineramaAllScreens) || (kapp->desktop()->numScreens() < 2))
{ {
/* special value for all screens */ /* special value for all screens */
workArea = Kicker::the()->kwinModule()->workArea(list); workArea = Kicker::the()->kwinModule()->workArea(list);

@ -43,7 +43,7 @@ namespace KWinInternal
*/ */
void Workspace::desktopResized() void Workspace::desktopResized()
{ {
printf("Workspace::desktopResized()\n\r"); //printf("Workspace::desktopResized()\n\r");
QRect geom = KApplication::desktop()->geometry(); QRect geom = KApplication::desktop()->geometry();
NETSize desktop_geometry; NETSize desktop_geometry;
desktop_geometry.width = geom.width(); desktop_geometry.width = geom.width();
@ -59,7 +59,7 @@ void Workspace::desktopResized()
*/ */
void Workspace::kDestopResized() void Workspace::kDestopResized()
{ {
printf("Workspace::kDesktopResized()\n\r"); //printf("Workspace::kDesktopResized()\n\r");
QRect geom = KApplication::desktop()->geometry(); QRect geom = KApplication::desktop()->geometry();
NETSize desktop_geometry; NETSize desktop_geometry;
desktop_geometry.width = geom.width(); 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 ) if( desktop == NETWinInfo::OnAllDesktops || desktop == 0 )
desktop = currentDesktop(); desktop = currentDesktop();
QDesktopWidget *desktopwidget = KApplication::desktop(); QDesktopWidget *desktopwidget = kapp->desktop();
QRect sarea = screenarea // may be NULL during KWin initialization QRect sarea = screenarea // may be NULL during KWin initialization
? screenarea[ desktop ][ screen ] ? screenarea[ desktop ][ screen ]
: desktopwidget->screenGeometry( screen ); : desktopwidget->screenGeometry( screen );
QRect warea = workarea[ desktop ].isNull() QRect warea = workarea[ desktop ].isNull()
? QApplication::desktop()->geometry() ? kapp->desktop()->geometry()
: workarea[ desktop ]; : workarea[ desktop ];
switch (opt) switch (opt)
{ {
case MaximizeArea: case MaximizeArea:
if (options->xineramaMaximizeEnabled) if (options->xineramaMaximizeEnabled)
return sarea; if (desktopwidget->numScreens() < 2)
return warea;
else
return sarea;
else else
return warea; return warea;
case MaximizeFullArea: case MaximizeFullArea:
if (options->xineramaMaximizeEnabled) if (options->xineramaMaximizeEnabled)
return desktopwidget->screenGeometry( screen ); if (desktopwidget->numScreens() < 2)
return desktopwidget->geometry();
else
return desktopwidget->screenGeometry( screen );
else else
return desktopwidget->geometry(); return desktopwidget->geometry();
case FullScreenArea: case FullScreenArea:
if (options->xineramaFullscreenEnabled) if (options->xineramaFullscreenEnabled)
return desktopwidget->screenGeometry( screen ); if (desktopwidget->numScreens() < 2)
return desktopwidget->geometry();
else
return desktopwidget->screenGeometry( screen );
else else
return desktopwidget->geometry(); return desktopwidget->geometry();
case PlacementArea: case PlacementArea:
if (options->xineramaPlacementEnabled) if (options->xineramaPlacementEnabled)
return sarea; if (desktopwidget->numScreens() < 2)
return warea;
else
return sarea;
else else
return warea; return warea;
case MovementArea: case MovementArea:
if (options->xineramaMovementEnabled) if (options->xineramaMovementEnabled)
return desktopwidget->screenGeometry( screen ); if (desktopwidget->numScreens() < 2)
return desktopwidget->geometry();
else
return desktopwidget->screenGeometry( screen );
else else
return desktopwidget->geometry(); return desktopwidget->geometry();
case WorkArea: case WorkArea:
@ -271,7 +286,10 @@ QRect Workspace::clientArea( clientAreaOption opt, int screen, int desktop ) con
case FullArea: case FullArea:
return desktopwidget->geometry(); return desktopwidget->geometry();
case ScreenArea: case ScreenArea:
return desktopwidget->screenGeometry( screen ); if (desktopwidget->numScreens() < 2)
return desktopwidget->geometry();
else
return desktopwidget->screenGeometry( screen );
} }
assert( false ); assert( false );
return QRect(); return QRect();

Loading…
Cancel
Save