Fix glitch in Screen prefs when changing background color.

When both Backgrounds and Screen are open, if the workspace color is changed
in Backgrounds the monitor preview in Screen will now refresh to the new color.

Also added a BAlert in BackgroundsView.cpp when failing to change the
background image.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #13286.
This commit is contained in:
Brian Hill 2017-02-08 16:46:36 -05:00 committed by Adrien Destugues
parent 4c3f62c894
commit b8a6139981
8 changed files with 50 additions and 8 deletions

View File

@ -0,0 +1,15 @@
/*
* Copyright 2017, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Brian Hill <supernova@warpmail.net>
*/
#ifndef _SCREEN_DEFS_H
#define _SCREEN_DEFS_H
// Message sent to Screen from Backgrounds when updating the background color
static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc';
#endif // _SCREEN_DEFS_H

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 Haiku, Inc. All rights reserved.
* Copyright 2002-2017 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -7,6 +7,7 @@
* Jerome Duval, jerome.duval@free.fr
* Jonas Sundström, jonas@kirilla.se
* John Scipione, jscipione@gmail.com
* Brian Hill <supernova@warpmail.net>
*/
@ -17,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <Alert.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <ControlLook.h>
@ -33,6 +35,7 @@
#include <PopUpMenu.h>
#include <be_apps/Tracker/Background.h>
#include <ScreenDefs.h>
#include "ImageFilePanel.h"
@ -415,10 +418,10 @@ BackgroundsView::MessageReceived(BMessage* message)
{
_Save();
//_NotifyServer();
// Notify the server and Screen preflet
thread_id notify_thread;
notify_thread = spawn_thread(BackgroundsView::_NotifyThread,
"notifyServer", B_NORMAL_PRIORITY, this);
"notifyThread", B_NORMAL_PRIORITY, this);
resume_thread(notify_thread);
_UpdateButtons();
break;
@ -659,8 +662,14 @@ BackgroundsView::_Save()
status_t status = fCurrent->SetBackgroundImage(&node);
if (status != B_OK) {
// TODO: this should be a BAlert!
printf("setting background image failed: %s\n", strerror(status));
BString error(strerror(status));
BString text(B_TRANSLATE("Setting the background image failed:"));
text.Append("\n").Append(error);
BAlert* alert = new BAlert(B_TRANSLATE("Set background image error"),
text, B_TRANSLATE("OK"));
alert->SetShortcut(0, B_ESCAPE);
alert->Go(NULL);
printf("setting background image failed: %s\n", error.String());
}
}
@ -743,12 +752,22 @@ BackgroundsView::_NotifyServer()
}
void
BackgroundsView::_NotifyScreenPreflet()
{
BMessenger messenger("application/x-vnd.Haiku-Screen");
if (messenger.IsValid())
messenger.SendMessage(UPDATE_DESKTOP_COLOR_MSG);
}
int32
BackgroundsView::_NotifyThread(void* data)
{
BackgroundsView* view = (BackgroundsView*)data;
view->_NotifyServer();
view->_NotifyScreenPreflet();
return B_OK;
}

View File

@ -120,6 +120,7 @@ public:
protected:
void _Save();
void _NotifyServer();
void _NotifyScreenPreflet();
void _LoadSettings();
void _LoadDesktopFolder();
void _LoadDefaultFolder();

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src preferences backgrounds ;
UsePrivateHeaders shared ;
UsePrivateHeaders preferences shared ;
Preference Backgrounds :
BackgroundImage.cpp

View File

@ -10,6 +10,7 @@
#define CONSTANTS_H
#include <ScreenDefs.h>
#include <SupportDefs.h>
@ -30,7 +31,8 @@ static const uint32 POP_COMBINE_DISPLAYS_MSG = 'pcdi';
static const uint32 POP_SWAP_DISPLAYS_MSG = 'psdi';
static const uint32 POP_USE_LAPTOP_PANEL_MSG = 'pulp';
static const uint32 POP_TV_STANDARD_MSG = 'ptvs';
static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc';
//static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc';
// This is now defined in headers/private/preferences/ScreenDefs.h
static const uint32 UPDATE_DESKTOP_MSG = 'udsk';
static const uint32 SLIDER_MODIFICATION_MSG = 'sldm';
static const uint32 SLIDER_INVOKE_MSG = 'sldi';

View File

@ -4,7 +4,7 @@ AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders [ FDirName graphics common ] ;
UsePrivateHeaders [ FDirName graphics radeon ] ;
UsePrivateHeaders interface ;
UsePrivateHeaders interface preferences ;
Preference Screen :
AlertWindow.cpp

View File

@ -51,6 +51,7 @@ ScreenApplication::MessageReceived(BMessage* message)
switch (message->what) {
case SET_CUSTOM_REFRESH_MSG:
case MAKE_INITIAL_MSG:
case UPDATE_DESKTOP_COLOR_MSG:
fScreenWindow->PostMessage(message);
break;

View File

@ -1131,6 +1131,10 @@ ScreenWindow::MessageReceived(BMessage* message)
_UpdateActiveMode();
break;
case UPDATE_DESKTOP_COLOR_MSG:
PostMessage(message, fMonitorView);
break;
default:
BWindow::MessageReceived(message);
}