From f2a95c67298238dc0a739a9758462ece03147954 Mon Sep 17 00:00:00 2001
From: Markus Himmel <markus@himmel-villmar.de>
Date: Tue, 30 Dec 2014 18:14:49 +0000
Subject: [PATCH] Fix #8881: Add color drops to Backgrounds
- The Backgrounds preferences app will now accept color drops.
- The Backgrounds app will update if a color drop to the desktop has changed its color due to a direct color drop
---
src/kits/tracker/DeskWindow.cpp | 10 ++++++++++
src/preferences/backgrounds/Backgrounds.cpp | 12 ++++++++++++
src/preferences/backgrounds/BackgroundsView.cpp | 13 +++++++++++++
3 files changed, 35 insertions(+)
diff --git a/src/kits/tracker/DeskWindow.cpp b/src/kits/tracker/DeskWindow.cpp
index 94cb0b7..b101324 100644
a
|
b
|
All rights reserved.
|
39 | 39 | #include <Debug.h> |
40 | 40 | #include <FindDirectory.h> |
41 | 41 | #include <Locale.h> |
| 42 | #include <Messenger.h> |
42 | 43 | #include <NodeMonitor.h> |
43 | 44 | #include <Path.h> |
44 | 45 | #include <PathFinder.h> |
… |
… |
BDeskWindow::MessageReceived(BMessage* message)
|
641 | 642 | BScreen(this).SetDesktopColor(*color); |
642 | 643 | fPoseView->SetViewColor(*color); |
643 | 644 | fPoseView->SetLowColor(*color); |
| 645 | |
| 646 | // Notify the backgrounds app that the background changed |
| 647 | status_t initStatus; |
| 648 | BMessenger messenger = BMessenger( |
| 649 | "application/x-vnd.Haiku-Backgrounds", -1, &initStatus); |
| 650 | if (initStatus == B_OK) { |
| 651 | messenger.SendMessage(message); |
| 652 | } |
| 653 | |
644 | 654 | return; |
645 | 655 | } |
646 | 656 | } |
diff --git a/src/preferences/backgrounds/Backgrounds.cpp b/src/preferences/backgrounds/Backgrounds.cpp
index 4907bd1..20206a7 100644
a
|
b
|
public:
|
30 | 30 | BackgroundsWindow(); |
31 | 31 | |
32 | 32 | void RefsReceived(BMessage* message); |
| 33 | void MessageReceived(BMessage* message); |
33 | 34 | |
34 | 35 | protected: |
35 | 36 | virtual bool QuitRequested(); |
… |
… |
BackgroundsApplication::BackgroundsApplication()
|
67 | 68 | void |
68 | 69 | BackgroundsApplication::MessageReceived(BMessage* message) |
69 | 70 | { |
| 71 | if (message->WasDropped()) { |
| 72 | // This is the desktop telling us that it was changed by a color drop |
| 73 | BMessenger(fWindow).SendMessage(message); |
| 74 | return; |
| 75 | } |
70 | 76 | switch (message->what) { |
71 | 77 | case B_SILENT_RELAUNCH: |
72 | 78 | fWindow->Activate(); |
… |
… |
BackgroundsWindow::RefsReceived(BMessage* message)
|
115 | 121 | Activate(); |
116 | 122 | } |
117 | 123 | |
| 124 | void |
| 125 | BackgroundsWindow::MessageReceived(BMessage* message) |
| 126 | { |
| 127 | BMessenger(fBackgroundsView).SendMessage(message); |
| 128 | } |
| 129 | |
118 | 130 | |
119 | 131 | bool |
120 | 132 | BackgroundsWindow::QuitRequested() |
diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp
index 3c1c1f2..f7d8827 100644
a
|
b
|
BackgroundsView::AllAttached()
|
293 | 293 | void |
294 | 294 | BackgroundsView::MessageReceived(BMessage* message) |
295 | 295 | { |
| 296 | // Color drop |
| 297 | if (message->WasDropped()) { |
| 298 | rgb_color *clr; |
| 299 | ssize_t out_size; |
| 300 | if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, |
| 301 | (const void **)&clr, &out_size) == B_OK) { |
| 302 | fPicker->SetValue(*clr); |
| 303 | _UpdatePreview(); |
| 304 | _UpdateButtons(); |
| 305 | return; |
| 306 | } |
| 307 | } |
| 308 | |
296 | 309 | switch (message->what) { |
297 | 310 | case B_SIMPLE_DATA: |
298 | 311 | case B_REFS_RECEIVED: |