From 3d06de689b12c90a0930fc93be95adca8dd2998b Mon Sep 17 00:00:00 2001
From: Brian Hill <supernova@warpmail.net>
Date: Wed, 8 Feb 2017 16:46:36 -0500
Subject: [PATCH] Bug fix: 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.
---
headers/private/preferences/ScreenDefs.h | 15 +++++++++++++
src/preferences/backgrounds/BackgroundsView.cpp | 29 ++++++++++++++++++++-----
src/preferences/backgrounds/BackgroundsView.h | 1 +
src/preferences/backgrounds/Jamfile | 2 +-
src/preferences/screen/Constants.h | 4 +++-
src/preferences/screen/Jamfile | 2 +-
src/preferences/screen/ScreenApplication.cpp | 1 +
src/preferences/screen/ScreenWindow.cpp | 4 ++++
8 files changed, 50 insertions(+), 8 deletions(-)
create mode 100644 headers/private/preferences/ScreenDefs.h
diff --git a/headers/private/preferences/ScreenDefs.h b/headers/private/preferences/ScreenDefs.h
new file mode 100644
index 0000000..f03a3a7
-
|
+
|
|
| 1 | /* |
| 2 | * Copyright 2017, Haiku. |
| 3 | * Distributed under the terms of the MIT License. |
| 4 | * |
| 5 | * Authors: |
| 6 | * Brian Hill <supernova@warpmail.net> |
| 7 | */ |
| 8 | #ifndef _SCREEN_DEFS_H |
| 9 | #define _SCREEN_DEFS_H |
| 10 | |
| 11 | |
| 12 | // Message sent to Screen from Backgrounds when updating the background color |
| 13 | static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; |
| 14 | |
| 15 | #endif // _SCREEN_DEFS_H |
diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp
index 71853c8..4f49b40 100644
a
|
b
|
|
1 | 1 | /* |
2 | | * Copyright 2002-2015 Haiku, Inc. All rights reserved. |
| 2 | * Copyright 2002-2017 Haiku, Inc. All rights reserved. |
3 | 3 | * Distributed under the terms of the MIT License. |
4 | 4 | * |
5 | 5 | * Authors: |
… |
… |
|
7 | 7 | * Jerome Duval, jerome.duval@free.fr |
8 | 8 | * Jonas Sundström, jonas@kirilla.se |
9 | 9 | * John Scipione, jscipione@gmail.com |
| 10 | * Brian Hill <supernova@warpmail.net> |
10 | 11 | */ |
11 | 12 | |
12 | 13 | |
… |
… |
|
17 | 18 | #include <stdio.h> |
18 | 19 | #include <stdlib.h> |
19 | 20 | |
| 21 | #include <Alert.h> |
20 | 22 | #include <Bitmap.h> |
21 | 23 | #include <Catalog.h> |
22 | 24 | #include <ControlLook.h> |
… |
… |
|
33 | 35 | #include <PopUpMenu.h> |
34 | 36 | |
35 | 37 | #include <be_apps/Tracker/Background.h> |
| 38 | #include <ScreenDefs.h> |
36 | 39 | |
37 | 40 | #include "ImageFilePanel.h" |
38 | 41 | |
… |
… |
BackgroundsView::MessageReceived(BMessage* message)
|
415 | 418 | { |
416 | 419 | _Save(); |
417 | 420 | |
418 | | //_NotifyServer(); |
| 421 | // Notify the server and Screen preflet |
419 | 422 | thread_id notify_thread; |
420 | 423 | notify_thread = spawn_thread(BackgroundsView::_NotifyThread, |
421 | | "notifyServer", B_NORMAL_PRIORITY, this); |
| 424 | "notifyThread", B_NORMAL_PRIORITY, this); |
422 | 425 | resume_thread(notify_thread); |
423 | 426 | _UpdateButtons(); |
424 | 427 | break; |
… |
… |
BackgroundsView::_Save()
|
659 | 662 | |
660 | 663 | status_t status = fCurrent->SetBackgroundImage(&node); |
661 | 664 | if (status != B_OK) { |
662 | | // TODO: this should be a BAlert! |
663 | | printf("setting background image failed: %s\n", strerror(status)); |
| 665 | BString error(strerror(status)); |
| 666 | BString text(B_TRANSLATE("Setting the background image failed:")); |
| 667 | text.Append("\n").Append(error); |
| 668 | BAlert* alert = new BAlert(B_TRANSLATE("Set background image error"), |
| 669 | text, B_TRANSLATE("OK")); |
| 670 | alert->SetShortcut(0, B_ESCAPE); |
| 671 | alert->Go(NULL); |
| 672 | printf("setting background image failed: %s\n", error.String()); |
664 | 673 | } |
665 | 674 | } |
666 | 675 | |
… |
… |
BackgroundsView::_NotifyServer()
|
743 | 752 | } |
744 | 753 | |
745 | 754 | |
| 755 | void |
| 756 | BackgroundsView::_NotifyScreenPreflet() |
| 757 | { |
| 758 | BMessenger messenger("application/x-vnd.Haiku-Screen"); |
| 759 | if (messenger.IsValid()) |
| 760 | messenger.SendMessage(UPDATE_DESKTOP_COLOR_MSG); |
| 761 | } |
| 762 | |
| 763 | |
746 | 764 | int32 |
747 | 765 | BackgroundsView::_NotifyThread(void* data) |
748 | 766 | { |
749 | 767 | BackgroundsView* view = (BackgroundsView*)data; |
750 | 768 | |
751 | 769 | view->_NotifyServer(); |
| 770 | view->_NotifyScreenPreflet(); |
752 | 771 | return B_OK; |
753 | 772 | } |
754 | 773 | |
diff --git a/src/preferences/backgrounds/BackgroundsView.h b/src/preferences/backgrounds/BackgroundsView.h
index eece562..4df303f 100644
a
|
b
|
public:
|
120 | 120 | protected: |
121 | 121 | void _Save(); |
122 | 122 | void _NotifyServer(); |
| 123 | void _NotifyScreenPreflet(); |
123 | 124 | void _LoadSettings(); |
124 | 125 | void _LoadDesktopFolder(); |
125 | 126 | void _LoadDefaultFolder(); |
diff --git a/src/preferences/backgrounds/Jamfile b/src/preferences/backgrounds/Jamfile
index 3d134f5..75b6cd6 100644
a
|
b
|
|
1 | 1 | SubDir HAIKU_TOP src preferences backgrounds ; |
2 | 2 | |
3 | | UsePrivateHeaders shared ; |
| 3 | UsePrivateHeaders preferences shared ; |
4 | 4 | |
5 | 5 | Preference Backgrounds : |
6 | 6 | BackgroundImage.cpp |
diff --git a/src/preferences/screen/Constants.h b/src/preferences/screen/Constants.h
index 3191d9d..f581d56 100644
a
|
b
|
|
10 | 10 | #define CONSTANTS_H |
11 | 11 | |
12 | 12 | |
| 13 | #include <ScreenDefs.h> |
13 | 14 | #include <SupportDefs.h> |
14 | 15 | |
15 | 16 | |
… |
… |
static const uint32 POP_COMBINE_DISPLAYS_MSG = 'pcdi';
|
30 | 31 | static const uint32 POP_SWAP_DISPLAYS_MSG = 'psdi'; |
31 | 32 | static const uint32 POP_USE_LAPTOP_PANEL_MSG = 'pulp'; |
32 | 33 | static const uint32 POP_TV_STANDARD_MSG = 'ptvs'; |
33 | | static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; |
| 34 | //static const uint32 UPDATE_DESKTOP_COLOR_MSG = 'udsc'; |
| 35 | // This is now defined in headers/private/preferences/ScreenDefs.h |
34 | 36 | static const uint32 UPDATE_DESKTOP_MSG = 'udsk'; |
35 | 37 | static const uint32 SLIDER_MODIFICATION_MSG = 'sldm'; |
36 | 38 | static const uint32 SLIDER_INVOKE_MSG = 'sldi'; |
diff --git a/src/preferences/screen/Jamfile b/src/preferences/screen/Jamfile
index 116d9f2..ce605a8 100644
a
|
b
|
AddSubDirSupportedPlatforms libbe_test ;
|
4 | 4 | |
5 | 5 | UsePrivateHeaders [ FDirName graphics common ] ; |
6 | 6 | UsePrivateHeaders [ FDirName graphics radeon ] ; |
7 | | UsePrivateHeaders interface ; |
| 7 | UsePrivateHeaders interface preferences ; |
8 | 8 | |
9 | 9 | Preference Screen : |
10 | 10 | AlertWindow.cpp |
diff --git a/src/preferences/screen/ScreenApplication.cpp b/src/preferences/screen/ScreenApplication.cpp
index f022380..e5be94f 100644
a
|
b
|
ScreenApplication::MessageReceived(BMessage* message)
|
51 | 51 | switch (message->what) { |
52 | 52 | case SET_CUSTOM_REFRESH_MSG: |
53 | 53 | case MAKE_INITIAL_MSG: |
| 54 | case UPDATE_DESKTOP_COLOR_MSG: |
54 | 55 | fScreenWindow->PostMessage(message); |
55 | 56 | break; |
56 | 57 | |
diff --git a/src/preferences/screen/ScreenWindow.cpp b/src/preferences/screen/ScreenWindow.cpp
index 0054c31..22c8d80 100644
a
|
b
|
ScreenWindow::MessageReceived(BMessage* message)
|
1131 | 1131 | _UpdateActiveMode(); |
1132 | 1132 | break; |
1133 | 1133 | |
| 1134 | case UPDATE_DESKTOP_COLOR_MSG: |
| 1135 | PostMessage(message, fMonitorView); |
| 1136 | break; |
| 1137 | |
1134 | 1138 | default: |
1135 | 1139 | BWindow::MessageReceived(message); |
1136 | 1140 | } |