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:
Yourself 2023-03-22 15:11:23 -04:00 committed by waddlesplash
parent a231654f09
commit e48af9e4ec
2 changed files with 19 additions and 21 deletions

View File

@ -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)
{

View File

@ -84,6 +84,8 @@ private:
void _ImproveScrollBarLayout(BView* target);
void _WorkspaceEntered();
bool _CheckSaveIcon(const BMessage* currentMessage);
void _PickUpActionBeforeSave();