Icon-O-Matic: cleanup workspace switching code
* Remove comment stating DesktopColor is buggy. The documentation has since been updated clarifying that this is the expected behavior. * Refactor code. * No functional changes. Change-Id: I03711136eb613afb80ad8c03a7f18ba6d15f641c Reviewed-on: https://review.haiku-os.org/c/haiku/+/6256 Tested-by: Automation <automation@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
a231654f09
commit
e48af9e4ec
@ -575,34 +575,18 @@ MainWindow::WorkspaceActivated(int32 workspace, bool active)
|
||||
{
|
||||
BWindow::WorkspaceActivated(workspace, active);
|
||||
|
||||
// NOTE: hack to workaround buggy BScreen::DesktopColor() on R5
|
||||
|
||||
uint32 workspaces = Workspaces();
|
||||
if (!active || ((1 << workspace) & workspaces) == 0)
|
||||
return;
|
||||
|
||||
WorkspacesChanged(workspaces, workspaces);
|
||||
if (active)
|
||||
_WorkspaceEntered();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::WorkspacesChanged(uint32 oldWorkspaces, uint32 newWorkspaces)
|
||||
{
|
||||
if (oldWorkspaces != newWorkspaces)
|
||||
BWindow::WorkspacesChanged(oldWorkspaces, newWorkspaces);
|
||||
BWindow::WorkspacesChanged(oldWorkspaces, newWorkspaces);
|
||||
|
||||
BScreen screen(this);
|
||||
|
||||
// Unfortunately, this is buggy on R5: screen.DesktopColor()
|
||||
// as well as ui_color(B_DESKTOP_COLOR) return the color
|
||||
// of the *active* screen, not the one on which this window
|
||||
// is. So this trick only works when you drag this window
|
||||
// from another workspace onto the current workspace, not
|
||||
// when you drag the window from the current workspace onto
|
||||
// another workspace and then switch to the other workspace.
|
||||
|
||||
fIconPreview32Desktop->SetIconBGColor(screen.DesktopColor());
|
||||
fIconPreview64->SetIconBGColor(screen.DesktopColor());
|
||||
if((1 << current_workspace() & newWorkspaces) != 0)
|
||||
_WorkspaceEntered();
|
||||
}
|
||||
|
||||
|
||||
@ -1274,6 +1258,18 @@ MainWindow::_ImproveScrollBarLayout(BView* target)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
MainWindow::_WorkspaceEntered()
|
||||
{
|
||||
BScreen screen(this);
|
||||
fIconPreview32Desktop->SetIconBGColor(screen.DesktopColor());
|
||||
fIconPreview64->SetIconBGColor(screen.DesktopColor());
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
bool
|
||||
MainWindow::_CheckSaveIcon(const BMessage* currentMessage)
|
||||
{
|
||||
|
@ -84,6 +84,8 @@ private:
|
||||
|
||||
void _ImproveScrollBarLayout(BView* target);
|
||||
|
||||
void _WorkspaceEntered();
|
||||
|
||||
bool _CheckSaveIcon(const BMessage* currentMessage);
|
||||
void _PickUpActionBeforeSave();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user