[haiku-commits] BRANCH looncraz-github.setviewuicolor [953143816f55] in src: kits/interface servers/app apps preferences/appearance .

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 11 Nov 2015 07:32:13 +0100 (CET)

added 91 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: 23d5dee6c2aaab562a8820fa317a92b7f6be528f
new head: 953143816f5575446cd2e78001cd3d1314144336
overview: https://github.com/looncraz/haiku/compare/23d5dee6c2aa...953143816f55

----------------------------------------------------------------------------

e8f64e69451d: app_server DelayedMessage

Add a system by which messages can be sent at a scheduled time, and can also
be merged according to set rules. A single thread is used to service the
message queue.

ef2760dcd0b3: Cleanup MessageLooper.h

Virtual methods should have been protected, not private, no need to
repeat protected so often, one line exceeded 80 chars.

c49547cff5f2: BColorMap

Useful class for handling system colors in groups rather than just one by one.
The data is hidden from the public API and is a BMessage of the same format
that will be used by the app_server to inform the applications that colors
have changed.

The data is shared in a copy-on-write fashion and a special, private, facility
permits the data to be stolen from a colormap and replaced. This is to enable
the app_server to keep a BColorMap around and to split off its data and allow
parallel adaptation of the changed colors while new updates are free to queue
in a pending BColorMap.

ad9d35551038: Set*UIColor, etc.

The inseperable changes necessary to support live color updating across the
system in a sane, safe, and performant manner.

BView gains:

HasSystemColors()
HasDefaultColors()
AdoptSystemColors()
AdoptParentColors()
AdoptViewColor(BView*)
SetViewUIColor(color_which, float tint)
SetHighUIColor(...
SetLowUIColor(...
ViewUIColor(float* tint)
HighUIColor(...
LowUIColor(...

BWindow gains a simple helper method:
IsOffscreenWindow()

Previous private ColorTools methods are made public and moved into
GraphicsDefs:

mix_color, blend_color, disable_color

These are fully compatible with BeOS dan0 R5.1 methods and are just code
cleanup
of BeOS example code under the OpenTracker license.

In addition, four new colors are created:
B_LINK_TEXT_COLOR
B_LINK_HOVER_COLOR
B_LINK_ACTIVE_COLOR
B_LINK_VISITED_COLOR

These changes are documented in their proper user documentation files.

On the app_server side, the following has changed:

Desktop gains the ability to add message ports to a DelayedMessage so that
said messages can target either all applications or all windows, as needed.

Desktop maintains a BColorMap which is used to queue up all pending color
changes
and the delayed messaging system is used only enact tese changes after a good
period of time has passed. This prevents abuse and allows the system to merge
repeated set_ui_color events into one event for client applications.

In addition, B_COLORS_UPDATED is sent the BApplication, which forwards the
message
to each BWindow. This is done to improve performance over having the
app_server
independently informing each window. This greatly reduces lock contention
around
Desktop's window lock, as each application will grab the lock in ServerApp and
will have each window update its views and decorator, rather than each window
vying for the write lock.

Decorator changes are live now, which required some reworking.

c2c08afb3f9c: LinkReceiver Fix

LinkReceiver would spin endlessly when given a timeout value which prevented
DelayedMessageSender from being operational.

086cb213e583: B_FOLLOW_DEFAULT

Make use of the new flag to cleanup the interface headers.

3a52669f3268: ControlLook Colors

Enable better use of the proper colors, as well as overriding the
assumed proper colors for labels.

a19ed4b70825: ColumnListView colors

ColumnListView now responds to system color changes.

de20fbe09a02: Private Headers B_FOLLOW_DEFAULT

87f6001197b5: StatusBar colors

Add fInternalFlags and a single flag to denote the use of custom colors.
Have status bar use appropriate colors, either by adopting colors, or
by using system standard colors.
Live colors updates are also working.

bc32f3a6d487: BAboutWindow colors

036b345b3273: BAlert colors

f0ef0f1b1ee1: BBox colors

290e0af374a8: BButton colors

BButton now properly uses the B_CONTROL_BACKGROUND_COLOR instead of
a darkened view color.

d11333face4d: BControl colors

This includes simple changes to common controls.

58016f22bac3: AbstractSpinner colors

6629d73e7a3e: Menu colors

6b3d9f1e8ceb: BListView colors

17f05b2a4b67: BTabView colors

7dbd81ee5a95: Specialized Layout Views colors

Views used by layout.

070fb81d0471: Colors

cc8deea45cb1: ToolTip colors

dfb99876ede2: Chart colors and some font awareness

Chart had horrible behavior with large fonts and many hardcoded colors.
This helps this situation immensely.

56f12192f849: Tests color changes

Iteratively replace usage of Set*Color(ui_color... with Set*UIColor(...

4d54076da0e9: Mail Deskbar Replicant colors

ad242c7554a6: Bluetooth Deskbar Replicant colors

620c194c3729: Server UI colors

Iterative changes, mostly.

e3d1f03df3cb: Time Preflet colors

930a81ae2286: Screensaver preflet colors

c7bea78235da: Screen Preflet colors

4c4f90a745d6: Network Preflet Colors

7ce050ab3bee: Mouse Preflet Colors

5f13904edd5e: Media System Colors

Preflet, replicant, and DefaultMediaTheme

c51d52ab9f25: Mail Preflet Colors

a9eb14335d78: Locale Preflet Colors

e5a8806b856b: Keymap colors

1a825b0d3a0e: Joysticks Preflet colors

d6ab7770ab4e: Font Preflet colors

9a04383419bc: FileTypes Preflet colors

0f2d42f550f4: DataTranslation Preflet - and addons - colors

05f4e9fb3d19: Bluetooth Preflet colors

2a3987593b84: Appearance BColorMap

Use BColorMap, use new color system.

fe9927f85300: Print System Colors

08021effa94b: Tracker uses new API, Improved Font Awareness

InfoWindow now uses the font size to determine the window size and
placement of elements. Also uses syste colors, including link
colors. Permissions view not font sensitive at this time.

acd5ad65390c: Mail kit colors

8888dced5991: ToolBar Colors

This was a bigger change than many others as BButton now defaults to using
control background colors, and we can not do that here without the buttons
not appearing as we desire (blending in with the toolbar).

Using the control background color for the toolbar would be unacceptable.

1540effa2cf4: Shared UI element colors

41e8c23ff34f: Bluetooth Incoming Connection colors

8ed5f1e83d1b: /bin colors

091c4f2f8577: WebPositive Colors

Use system colors, ensure that we don't rely on view having a default
white background when using the layout API (DownloadProgressView)

5a4b32ca19a9: Terminal colors

When resizing a window, we need to ensure the low color and the view color
are the same,
otherwise the drawing results will be unpleasant.

Here, I decided to use the user Terminal colors rather than a system color.

92fdcd67371e: Switcher colors

3ea03f09fcc9: Sudoku colors

7dbc094008e5: StyledEdit colors

001d1ff2cf2f: SoundRecorder colors

I lack the hardware to fully adapt this program at this time.

5a287a03ac3b: ShowImage colors

0cacaf9fab51: Screenshot window colors

3ac4c0ef49cf: resedit colors

07f62036a77e: Pulse colors

18877fcfc409: ProcessController colors

a3b240a0ce04: PowerStatus colors

0c9dcb009c45: PatchBay Colors

958584680ed8: Pairs colors

8c6c6f8ea365: PackageInstaller colors

c5edaac58cd8: OverlayImage app colors

bab541c8edc5: Network Status Colors

fd465dcd219b: MediaPlayer colors

61e49c4ca67a: Mail application colors

358e16ba54d2: Magnify app colors

e1d96a566d68: Login UI rework

Improve placement with different font sizes, and use user colors.

b8f864d427ba: Install colors

Also better placement of text when official logo is absent.

cbf3d0e18a06: Uninstaller colors

1ccc0e09b1db: Icon-o-Matic colors

0fed63d92298: HaikuDepot colors

This application proved the most difficult to get to use system colors.
It uses a specialized text handling system that does not expose the
ability to change text or background colors at any point.

After discussing at length with the original author it was discovered
that the system is not working as originally intended and fixing it is
beyond the scope of this commit. As such, I added the ability for this
system to use color defined constants so that it can update with system
color changes. I also removed its use from the package list view, as
there was no way to override the color choices to make the MarkupTextView
fit in properly with list colors. This, however, is a non issue as BTextView
has every needed capability for the short description.

In addition to using system colors and live updates, I took it upon myself
to improve the legibility of the user ratings view. A faint line now
separates
each rating, and the rating bars use the control mark color so that they stand
out as something other than a drawing error (which is what I thought it was
for
a long time).

c52709dbc6bb: FontDemo colors

681f189c26c6: FirstBootPrompt colors and size

Intelligently use font size to set the window size.

680b6ca4d034: Expander colors

172c02727555: DriveSetup colors

861dc3bb5096: DiskProbe colors

8d09fbabb3bd: Device app colors

415b006207bc: Deskbar colors

99528c2ec9ba: DeskCalc colors

Due to the button color logic, we use the rgb_color Brightness to determine
the label colors.

03b65ec81ab8: Debugger colors

a492a5b619c7: CharacterMap colors

8bab082e0dcb: BootManager colors, size

Use system colors, intelligently size window according to the font size.

eafdbb84280b: ActivityMonitor colors

f5520379bc6f: AboutSystem colors

Use slightly different colors for heading text than for subheading text.
Change uptime view from a BTextView to a BStringView. This fixes the issue
where the AboutWindow did not properly fit its contents.

6ead30402707: ScreenSaver add-on prefefernce view colors

db8513bbfc1f: Print server add-ons' colors

dcfef315876e: Mail daemon addon colors

953143816f55: TeamMonitorWindow colors

[ looncraz <looncraz@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

369 files changed, 5735 insertions(+), 1638 deletions(-)
docs/user/interface/View.dox | 189 +++-
docs/user/interface/Window.dox | 18 +-
headers/os/app/AppDefs.h | 6 +-
headers/os/interface/Box.h | 5 +-
headers/os/interface/Button.h | 5 +-
headers/os/interface/ChannelControl.h | 5 +-
headers/os/interface/ChannelSlider.h | 8 +-
headers/os/interface/CheckBox.h | 5 +-
headers/os/interface/ColorMap.h | 103 ++
headers/os/interface/ControlLook.h | 18 +-
headers/os/interface/GraphicsDefs.h | 9 +-
headers/os/interface/InterfaceDefs.h | 6 +
headers/os/interface/LayoutBuilder.h | 19 +-
headers/os/interface/ListView.h | 5 +-
headers/os/interface/MenuField.h | 8 +-
headers/os/interface/MultiChannelControl.h | 5 +-
headers/os/interface/OptionControl.h | 5 +-
headers/os/interface/OptionPopUp.h | 7 +-
headers/os/interface/OutlineListView.h | 5 +-
headers/os/interface/PictureButton.h | 5 +-
headers/os/interface/RadioButton.h | 5 +-
headers/os/interface/ScrollView.h | 3 +-
headers/os/interface/Slider.h | 8 +-
headers/os/interface/SplitView.h | 3 +-
headers/os/interface/StatusBar.h | 5 +-
headers/os/interface/StringView.h | 2 +-
headers/os/interface/TextControl.h | 3 +-
headers/os/interface/View.h | 36 +-
headers/os/interface/Window.h | 2 +-
headers/private/app/ServerProtocol.h | 11 +
headers/private/app/ServerProtocolStructs.h | 4 +
headers/private/app/ServerReadOnlyMemory.h | 10 +-
headers/private/interface/AbstractSpinner.h | 2 +-
headers/private/interface/ColorMapPrivate.h | 79 ++
headers/private/interface/ColorTools.h | 79 --
headers/private/interface/ColumnListView.h | 1 +
headers/private/interface/DecimalSpinner.h | 2 +-
headers/private/interface/ViewPrivate.h | 14 +-
headers/private/shared/CalendarView.h | 3 +-
.../devices/keyboard/TeamMonitorWindow.cpp | 6 +-
.../inbound_filters/match_header/ConfigView.cpp | 2 +-
.../notifier/NotifierConfigView.cpp | 2 +-
.../spam_filter/SpamFilterConfig.cpp | 2 +-
.../outbound_filters/fortune/ConfigView.cpp | 2 +-
.../print/drivers/pdf/source/DocInfoWindow.cpp | 4 +-
.../print/drivers/pdf/source/FontsWindow.cpp | 4 +-
.../transports/hp_jetdirect/SetupWindow.cpp | 2 +-
src/add-ons/print/transports/ipp/IppSetupDlg.cpp | 2 +-
src/add-ons/print/transports/lpr/LprSetupDlg.cpp | 2 +-
src/add-ons/screen_savers/glife/GLifeConfig.cpp | 2 +-
src/add-ons/screen_savers/gravity/ConfigView.cpp | 2 +-
src/add-ons/screen_savers/nebula/Nebula.cpp | 2 +-
.../slideshowsaver/SlideShowConfigView.cpp | 2 +-
src/add-ons/screen_savers/spider/SpiderSaver.cpp | 2 +-
src/add-ons/translators/bmp/BMPView.cpp | 2 +-
src/add-ons/translators/exr/ConfigView.cpp | 2 +-
src/add-ons/translators/gif/GIFView.cpp | 2 +-
src/add-ons/translators/hpgs/ConfigView.cpp | 2 +-
src/add-ons/translators/jpeg/JPEGTranslator.cpp | 2 +-
.../translators/jpeg2000/JPEG2000Translator.cpp | 2 +-
src/add-ons/translators/pcx/ConfigView.cpp | 2 +-
src/add-ons/translators/png/PNGView.cpp | 5 +-
src/add-ons/translators/ppm/PPMTranslator.cpp | 2 +-
src/add-ons/translators/raw/ConfigView.cpp | 2 +-
src/add-ons/translators/rtf/ConfigView.cpp | 2 +-
src/add-ons/translators/sgi/SGIView.cpp | 2 +-
src/add-ons/translators/stxt/STXTView.cpp | 2 +-
src/add-ons/translators/tga/TGAView.cpp | 2 +-
src/add-ons/translators/tiff/TIFFView.cpp | 4 +-
src/add-ons/translators/webp/ConfigView.cpp | 2 +-
.../translators/wonderbrush/WonderBrushView.cpp | 2 +-
src/apps/aboutsystem/AboutSystem.cpp | 74 +-
src/apps/activitymonitor/ActivityView.cpp | 9 +-
src/apps/activitymonitor/ActivityWindow.cpp | 3 +-
src/apps/activitymonitor/SettingsWindow.cpp | 2 +
src/apps/bootmanager/BootManagerWindow.cpp | 8 +-
src/apps/bootmanager/WizardPageView.cpp | 20 +-
src/apps/charactermap/CharacterView.cpp | 16 +-
.../gui/inspector_window/InspectorWindow.cpp | 6 +-
.../gui/inspector_window/MemoryView.cpp | 4 +-
.../utility_windows/ExpressionPromptWindow.cpp | 2 +-
.../gui/utility_windows/WatchPromptWindow.cpp | 2 +-
src/apps/deskbar/BarMenuBar.cpp | 2 +-
src/apps/deskbar/BarMenuTitle.cpp | 2 +-
src/apps/deskbar/BarView.cpp | 2 +-
src/apps/deskbar/ExpandoMenuBar.cpp | 2 +-
src/apps/deskbar/InlineScrollView.cpp | 2 +-
src/apps/deskbar/StatusView.cpp | 11 +-
src/apps/deskbar/Switcher.cpp | 92 +-
src/apps/deskbar/TeamMenuItem.cpp | 11 +-
src/apps/deskbar/TimeView.cpp | 10 +-
src/apps/deskbar/WindowMenuItem.cpp | 2 +-
src/apps/deskcalc/CalcView.cpp | 18 +-
src/apps/devices/PropertyListPlain.cpp | 26 +-
src/apps/devices/PropertyListPlain.h | 3 +
src/apps/devices/ResourceUsageWindow.cpp | 2 +-
src/apps/diskprobe/FindWindow.cpp | 2 +-
src/apps/diskprobe/ProbeView.cpp | 6 +-
src/apps/diskprobe/TypeEditors.cpp | 16 +-
[ *** stats truncated: 270 lines dropped *** ]

############################################################################

Commit: e8f64e69451dff690c008643fadfa669d870c6da
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 04:02:57 2015 UTC

app_server DelayedMessage

Add a system by which messages can be sent at a scheduled time, and can also
be merged according to set rules. A single thread is used to service the
message queue.

----------------------------------------------------------------------------

diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp
index 710d61c..1e212c8 100644
--- a/src/servers/app/AppServer.cpp
+++ b/src/servers/app/AppServer.cpp
@@ -18,6 +18,7 @@
#include <PortLink.h>

#include "BitmapManager.h"
+#include "DelayedMessageSender.h"
#include "Desktop.h"
#include "FontManager.h"
#include "InputManager.h"
@@ -68,6 +69,8 @@ AppServer::AppServer(status_t* status)
// Create the bitmap allocator. Object declared in BitmapManager.cpp
gBitmapManager = new BitmapManager();

+ new DelayedMessageSender();
+
// TODO: check the attached displays, and launch login session for them
BMessage data;
data.AddString("name", "app_server");
diff --git a/src/servers/app/DelayedMessage.cpp
b/src/servers/app/DelayedMessage.cpp
new file mode 100644
index 0000000..ce89024
--- /dev/null
+++ b/src/servers/app/DelayedMessage.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#include "DelayedMessage.h"
+#include "DelayedMessageSender.h"
+
+
+DelayedMessage::DelayedMessage(port_id port, int32 code, bigtime_t delay,
+ uint32 delayMode, uint32 mergeMode, uint32 mergeMask)
+ :
+ fData(new(std::nothrow) DelayedMessageData(port, code,
+ delay < DM_MINIMUM_DELAY ? DM_MINIMUM_DELAY : delay, delayMode,
+ mergeMode, mergeMask)),
+ fHandedOff(false)
+{
+}
+
+
+DelayedMessage::~DelayedMessage()
+{
+ // Message is canceled without a handoff.
+ if (!fHandedOff)
+ delete fData;
+}
+
+
+bool
+DelayedMessage::AddTarget(port_id port)
+{
+ if (fData == NULL
+ || fHandedOff)
+ return false;
+
+ return fData->AddTarget(port);
+}
+
+
+//! Attach data to message. Memory is not allocated nor copied until handoff.
+status_t
+DelayedMessage::Attach(const void* data, size_t size)
+{
+ if (fData == NULL)
+ return B_NO_MEMORY;
+
+ if (fHandedOff)
+ return B_ERROR;
+
+ if (data == NULL
+ || size == 0)
+ return B_BAD_VALUE;
+
+ return fData->Attach(data, size);
+}
+
+
+status_t
+DelayedMessage::Flush()
+{
+ if (fData == NULL
+ || gDelayedMessageSender == NULL)
+ return B_NO_MEMORY;
+
+ if (fHandedOff)
+ return B_ERROR;
+
+ return gDelayedMessageSender->ScheduleMessage(*this);
+}
+
+
+/*! The data handoff occurs upon scheduling and reduces copies to only
+ when a message is actually scheduled. Canceled messages have low cost.
+*/
+DelayedMessageData*
+DelayedMessage::HandOff()
+{
+ if (fData == NULL
+ || fHandedOff)
+ return NULL;
+
+ if (fData->CopyData()) {
+ fHandedOff = true;
+ return fData;
+ }
+
+ return NULL;
+}
+
diff --git a/src/servers/app/DelayedMessage.h b/src/servers/app/DelayedMessage.h
new file mode 100644
index 0000000..4cee92d
--- /dev/null
+++ b/src/servers/app/DelayedMessage.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#ifndef AS_DELAYED_MESSAGE_H
+#define AS_DELAYED_MESSAGE_H
+
+
+#include <ObjectList.h>
+#include <OS.h>
+
+
+//! Method by which to merge DelayedMessages with the same code.
+enum DMMergeMode {
+ DM_NO_MERGE = 0,// Will send this message, and the
other(s)
+ DM_MERGE_REPLACE = 1,// Replace older data with newer data
+ DM_MERGE_CANCEL = 2,// keeps older data, cancels this message
+ DM_MERGE_DUPLICATES = 3 // If data is the same, cancel new message
+};
+
+
+//! Merge-mode data-matching Z
+enum {
+ DM_DATA_DEFAULT = 0,
+ DM_DATA_1 = 1 << 0,
+ DM_DATA_2 = 1 << 1,
+ DM_DATA_3 = 1 << 2,
+ DM_DATA_4 = 1 << 3,
+ DM_DATA_5 = 1 << 4,
+ DM_DATA_6 = 1 << 5
+};
+
+
+//! Convenient delay definitions.
+enum {
+ DM_MINIMUM_DELAY = 500ULL,
+ DM_SHORT_DELAY = 1000ULL,
+ DM_120HZ_DELAY = 8888ULL,
+ DM_60HZ_DELAY = 16666ULL,
+ DM_MEDIUM_DELAY = 15000ULL,
+ DM_30HZ_DELAY = 33332ULL,
+ DM_15HZ_DELAY = 66664ULL,
+ DM_LONG_DELAY = 100000ULL,
+ DM_QUARTER_SECOND_DELAY = 250000ULL,
+ DM_HALF_SECOND_DELAY = 500000ULL,
+ DM_ONE_SECOND_DELAY = 1000000ULL,
+ DM_ONE_MINUTE_DELAY = DM_ONE_SECOND_DELAY * 60,
+ DM_ONE_HOUR_DELAY = DM_ONE_MINUTE_DELAY * 60,
+ DM_MAX_DELAY = DM_ONE_HOUR_DELAY
+};
+
+
+class DelayedMessageData;
+class DMScheduledMessage;
+
+
+/*! \class DelayedMessage
+ \brief Friendly API for creating messages to be sent at a future time.
+
+ Messages can be sent with a relative delay, or at a set time. Messages
with
+ the same code can be merged according to various rules. Each message can
+ have any number of target recipients, but must be constructed with at
least
+ one (need not be valid, all valid ports will still receive the message).
+
+ DelayedMessage is a throw-away object, it is to be created on the stack
+ only, Flush()'d, then left to be destructed when out of scope.
+*/
+class DelayedMessage {
+public:
+
DelayedMessage(port_id port, int32 code,
+
bigtime_t delay = DM_SHORT_DELAY,
+ uint32
delayMode = B_RELATIVE_TIMEOUT,
+ uint32
mergeMode = DM_NO_MERGE,
+ uint32
mergeMask = DM_DATA_DEFAULT);
+
~DelayedMessage();
+
+ bool AddTarget(port_id port);
+
+ template <class Type>
+ status_t Attach(const Type&
data);
+ status_t Attach(const void*
data, size_t size);
+
+ template <class Type>
+ status_t AttachList(const
BObjectList<Type>& list);
+
+ template <class Type>
+ status_t AttachList(const
BObjectList<Type>& list,
+ bool*
whichArray);
+
+ status_t Flush();
+
+private:
+ friend class DMScheduledMessage;
+
+ // forbidden methods
+ void* operator new(size_t);
+ void* operator new[](size_t);
+
+ DelayedMessageData* HandOff();
+
+ DelayedMessageData* fData;
+ bool fHandedOff;
+};
+
+
+template <class Type>
+status_t
+DelayedMessage::Attach(const Type& data)
+{
+ return Attach(&data, sizeof(Type));
+}
+
+
+template <class Type>
+status_t
+DelayedMessage::AttachList(const BObjectList<Type>& list)
+{
+ if (list.CountItems() == 0)
+ return B_BAD_VALUE;
+
+ status_t error = Attach<int32>(list.CountItems());
+
+ for (int32 index = 0; index < list.CountItems(); ++index) {
+ if (error != B_OK)
+ break;
+
+ error = Attach<Type>(*(list.ItemAt(index)));
+ }
+
+ return error;
+}
+
+
+template <class Type>
+status_t
+DelayedMessage::AttachList(const BObjectList<Type>& list, bool* which)
+{
+ if (list.CountItems() == 0)
+ return B_BAD_VALUE;
+
+ if (which == NULL)
+ return AttachList(list);
+
+ int32 count = 0;
+ for (int32 index = 0; index < list.CountItems(); ++index)
+ if (which[index])
+ ++count;
+
+ if (count == 0)
+ return B_ERROR;
+
+ status_t error = Attach<int32>(count);
+
+ for (int32 index = 0; index < list.CountItems(); ++index) {
+ if (error != B_OK)
+ break;
+
+ if (which[index])
+ error = Attach<Type>(*(list.ItemAt(index)));
+ }
+
+ return error;
+}
+
+
+#endif // AS_DELAYED_MESSAGE_H
diff --git a/src/servers/app/DelayedMessagePrivate.cpp
b/src/servers/app/DelayedMessagePrivate.cpp
new file mode 100644
index 0000000..cf2d8c1
--- /dev/null
+++ b/src/servers/app/DelayedMessagePrivate.cpp
@@ -0,0 +1,426 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <LinkSender.h>
+#include <ServerProtocol.h>
+
+#include "DelayedMessagePrivate.h"
+
+#include "DelayedMessage.h"
+#include "DelayedMessageSender.h"
+
+
+//#pragma mark DelayedMessageData
+
+
+DelayedMessageData::DelayedMessageData(port_id port, int32 code,
+ bigtime_t delay, uint32 delayMode, uint32 mergeMode, uint32 mergeMask)
+ :
+ fAttachments(3, true),
+ fValid(false),
+ fScheduledTime(delay),
+ fTargets(NULL),
+ fMainTarget(port),
+ fCode(code),
+ fMergeMode(mergeMode),
+ fMergeMask(mergeMask)
+{
+ bigtime_t currentTime = system_time();
+
+ if (delayMode == B_RELATIVE_TIMEOUT) {
+ if (fScheduledTime > DM_MAX_DELAY)
+ fScheduledTime = DM_MINIMUM_DELAY;
+ // Set to minimum so error is apparent
+
+ fScheduledTime += currentTime;
+ } else if (delayMode == B_ABSOLUTE_TIMEOUT) {
+ if (fScheduledTime - currentTime > DM_MAX_DELAY)
+ fScheduledTime = currentTime + DM_MINIMUM_DELAY;
+ }
+}
+
+
+DelayedMessageData::~DelayedMessageData()
+{
+ // fAttachments goes out of scope and frees all memory allocated by the
+ // attachments upon copying.
+}
+
+
+bool
+DelayedMessageData::AddTarget(port_id port)
+{
+ if (fMainTarget == port
+ || port <= 0)
+ return false;
+
+ if (fMainTarget < 0) {
+ fMainTarget = port;
+ return true;
+ }
+
+ if (fTargets == NULL)
+ fTargets = new(std::nothrow) BObjectList<port_id>(1, true);
+
+ if (fTargets == NULL)
+ return false;
+
+ // check for duplicates:
+ for (int32 index = 0; index < fTargets->CountItems(); ++index)
+ if (port == *(fTargets->ItemAt(index)))
+ return false;
+
+ return fTargets->AddItem(new(std::nothrow) port_id(port));
+}
+
+
+void
+DelayedMessageData::RemoveTarget(port_id port)
+{
+ if (port <= 0)
+ return;
+
+ if (fMainTarget == port) {
+ fMainTarget = -1;
+ return;
+ }
+
+ if (fTargets != NULL) {
+ port_id* target = NULL;
+ for (int32 index = 0; index < fTargets->CountItems(); ++index) {
+ target = fTargets->ItemAt(index);
+ if (port == *target) {
+ fTargets->RemoveItem(target, true);
+ return;
+ }
+ }
+ }
+}
+
+
+int32
+DelayedMessageData::CountTargets() const
+{
+ int32 count = 0;
+
+ if (fMainTarget > 0)
+ ++count;
+
+ if (fTargets == NULL)
+ return count;
+
+ return count + fTargets->CountItems();
+}
+
+
+void
+DelayedMessageData::MergeTargets(DelayedMessageData* other)
+{
+ AddTarget(other->fMainTarget);
+
+ if (other->fTargets != NULL)
+ for (int32 index = 0; index < other->fTargets->CountItems();
++index)
+ AddTarget(*(other->fTargets->ItemAt(index)));
+}
+
+
+//! Copy data from original location - merging failed
+bool
+DelayedMessageData::CopyData()
+{
+ Attachment* attached = NULL;
+
+ for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
+ attached = fAttachments.ItemAt(index);
+
+ if (attached == NULL
+ || attached->data != NULL)
+ return false;
+
+ attached->data = malloc(attached->size);
+ if (attached->data == NULL)
+ return false;
+
+ memcpy(attached->data, attached->constData, attached->size);
+ }
+
+ fValid = true;
+ return true;
+}
+
+
+bool
+DelayedMessageData::MergeData(DelayedMessageData* other)
+{
+ if (!fValid
+ || other == NULL
+ || other->fCode != fCode
+ || fMergeMode == DM_NO_MERGE
+ || other->fMergeMode == DM_NO_MERGE
+ || other->fMergeMode != fMergeMode
+ || other->fAttachments.CountItems() !=
fAttachments.CountItems())
+ return false;
+
+ if (other->fMergeMode == DM_MERGE_CANCEL) {
+ MergeTargets(other);
+ return true;
+ }
+
+ // Compare data
+ Attachment* attached = NULL;
+ Attachment* otherAttached = NULL;
+
+ for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
+ attached = fAttachments.ItemAt(index);
+ otherAttached = other->fAttachments.ItemAt(index);
+
+ if (attached == NULL
+ || otherAttached == NULL
+ || attached->data == NULL
+ || otherAttached->constData == NULL
+ || attached->size != otherAttached->size)
+ return false;
+
+ // Compares depending upon mode & flags
+ if (!_Compare(attached, otherAttached, index))
+ return false;
+ }
+
+ // add any targets not included in the existing message!
+ MergeTargets(other);
+
+ // since these are duplicates, we need not copy anything...
+ if (fMergeMode == DM_MERGE_DUPLICATES)
+ return true;
+
+ // DM_MERGE_REPLACE:
+
+ // Import the new data!
+ for (int32 index = 0; index < fAttachments.CountItems(); ++index) {
+ attached = fAttachments.ItemAt(index);
+ otherAttached = other->fAttachments.ItemAt(index);
+
+ // We already have allocated our memory, but the other data
+ // has not. So this reduces memory allocations.
+ memcpy(attached->data, otherAttached->constData,
attached->size);
+ }
+
+ return true;
+}
+
+
+bool
+DelayedMessageData::IsValid() const
+{
+ return fValid;
+}
+
+
+status_t
+DelayedMessageData::Attach(const void* data, size_t size)
+{
+ // Sanity checking already performed
+ Attachment* attach = new(std::nothrow) Attachment(data, size);
+
+ if (attach == NULL)
+ return B_NO_MEMORY;
+
+ if (fAttachments.AddItem(attach) == false) {
+ delete attach;
+ return B_ERROR;
+ }
+
+ return B_OK;
+}
+
+
+bool
+DelayedMessageData::_Compare(DelayedMessageData::Attachment* one,
+ DelayedMessageData::Attachment* two, int32 index)
+{
+ if (fMergeMode == DM_MERGE_DUPLICATES) {
+
+ // Default-policy: all data must match
+ if (fMergeMask == DM_DATA_DEFAULT
+ || (fMergeMask & 1 << index) != 0)
+ return memcmp(one->data, two->constData, one->size) ==
0;
+
+ } else if (fMergeMode == DM_MERGE_REPLACE) {
+
+ // Default Policy: no data needs to match
+ if (fMergeMask != DM_DATA_DEFAULT
+ && (fMergeMask & 1 << index) != 0)
+ return memcmp(one->data, two->constData, one->size) ==
0;
+ }
+
+ return true;
+}
+
+
+DelayedMessageData::Attachment::Attachment(const void* _data, size_t _size)
+ :
+ constData(_data),
+ data(NULL),
+ size(_size)
+{
+}
+
+
+DelayedMessageData::Attachment::~Attachment()
+{
+ free(data);
+}
+
+
+//#pragma mark DMScheduledMessage
+
+
+DMScheduledMessage::DMScheduledMessage(DelayedMessage& message)
+ :
+ fData(message.HandOff()),
+ fFailureCount(0)
+{
+}
+
+
+DMScheduledMessage::~DMScheduledMessage()
+{
+ delete fData;
+}
+
+
+int32
+DMScheduledMessage::CountTargets() const
+{
+ if (fData == NULL)
+ return 0;
+
+ return fData->CountTargets();
+}
+
+
+bigtime_t
+DMScheduledMessage::ScheduledTime() const
+{
+ if (fData == NULL)
+ return 0;
+
+ return fData->fScheduledTime;
+}
+
+
+//! Send our message and data to their intended target(s)
+int32
+DMScheduledMessage::SendMessage()
+{
+ if (fData == NULL
+ || !fData->IsValid()) {
+ fFailureCount += 10000;
+ return -2;
+ }
+
+ int32 sent = 0;
+ if (_SendMessageToPort(fData->fMainTarget) == B_OK)
+ ++sent;
+ else
+ ++fFailureCount;
+
+ if (fData->fTargets == NULL)
+ return sent;
+
+ port_id port;
+ for (int32 index = 0; index < fData->fTargets->CountItems(); ++index) {
+ port = *(fData->fTargets->ItemAt(index));
+
+ if (_SendMessageToPort(port) == B_OK)
+ ++sent;
+ else
+ ++fFailureCount;
+ }
+
+ return sent;
+}
+
+
+status_t
+DMScheduledMessage::_SendMessageToPort(port_id port)
+{
+ if (fData == NULL
+ || !fData->IsValid())
+ return B_BAD_DATA;
+
+ if (port == B_BAD_PORT_ID)
+ return B_BAD_VALUE;
+
+ BPrivate::LinkSender sender(port);
+ if (sender.StartMessage(fData->fCode) != B_OK)
+ return B_ERROR;
+
+ BObjectList<DelayedMessageData::Attachment>& list = fData->fAttachments;
+ DelayedMessageData::Attachment* attached = NULL;
+ status_t error = B_OK;
+
+ // The data has been checked already, so we assume it is all good
+ for (int32 index = 0; index < list.CountItems(); ++index) {
+ attached = list.ItemAt(index);
+
+ error = sender.Attach(attached->data, attached->size);
+ if (error != B_OK) {
+ sender.CancelMessage();
+ return error;
+ }
+ }
+
+ error = sender.Flush(DM_ONE_SECOND_DELAY);
+
+ if (error == B_OK
+ || error == B_BAD_PORT_ID)
+ fData->RemoveTarget(port);
+
+ return error;
+}
+
+
+bool
+DMScheduledMessage::IsValid() const
+{
+ return fData != NULL && fData->IsValid();
+}
+
+
+bool
+DMScheduledMessage::Merge(DelayedMessage& other)
+{
+ if (!IsValid())
+ return false;
+
+ return fData->MergeData(other.fData);
+}
+
+
+uint32
+DMScheduledMessage::FailureCount() const
+{
+ return fFailureCount;
+}
+
+
+bool
+DMScheduledMessage:: operator<(const DMScheduledMessage& other) const
+{
+ if (!IsValid()
+ || !other.IsValid())
+ return false;
+
+ return fData->fScheduledTime < other.fData->fScheduledTime;
+}
+
diff --git a/src/servers/app/DelayedMessagePrivate.h
b/src/servers/app/DelayedMessagePrivate.h
new file mode 100644
index 0000000..1f19fed
--- /dev/null
+++ b/src/servers/app/DelayedMessagePrivate.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#ifndef DELAYED_MESSAGE_PRIVATE_H
+#define DELAYED_MESSAGE_PRIVATE_H
+
+
+#include <ObjectList.h>
+#include <OS.h>
+
+
+class DelayedMessage;
+class DelayedMessageSender;
+
+
+/*! \class DelayedMessageData DelayedMessageSender.h
+ \brief Owns DelayedMessage data, allocates memory and copies data only
+ when needed,
+*/
+class DelayedMessageData {
+private:
+ friend class DMScheduledMessage;
+ friend class DelayedMessage;
+
+
DelayedMessageData(port_id port, int32 code,
+
bigtime_t delay, uint32 delayMode,
+ uint32
mergeMode, uint32 mergeMask);
+
~DelayedMessageData();
+
+ bool AddTarget(port_id port);
+ void RemoveTarget(port_id
port);
+ int32 CountTargets() const;
+
+ void
MergeTargets(DelayedMessageData* other);
+
+ bool CopyData();
+ bool
MergeData(DelayedMessageData* other);
+
+ bool IsValid() const;
+ // Only valid after a successful CopyData()
+
+ status_t Attach(const void*
data, size_t size);
+
+private:
+ struct Attachment {
+ const void* constData;
+ void* data;
+ size_t size;
+
+
Attachment(const void*, size_t);
+ ~Attachment();
+ };
+
+ bool _Compare(Attachment*
one, Attachment* two,
+ int32
index);
+
+ BObjectList<Attachment> fAttachments;
+ bool fValid;
+ bigtime_t fScheduledTime;
+ BObjectList<port_id>* fTargets;
+ port_id fMainTarget;
+ int32 fCode;
+ uint32 fMergeMode;
+ uint32 fMergeMask;
+};
+
+
+/*! \class DMScheduledMessage DelayedMessageSender.h
+ \brief Responsible for sending of delayed message.
+*/
+class DMScheduledMessage {
+private:
+
DMScheduledMessage(DelayedMessage& message);
+
~DMScheduledMessage();
+
+ int32 CountTargets() const;
+
+ void Finalize();
+ bigtime_t ScheduledTime() const;
+ int32 SendMessage();
+ bool IsValid() const;
+ bool Merge(DelayedMessage&
message);
+ uint32 FailureCount() const;
+
+private:
+ status_t
_SendMessageToPort(port_id port);
+
+ DelayedMessageData* fData;
+ uint32 fFailureCount;
+
+ friend class DelayedMessageSender;
+ friend class DelayedMessage;
+ friend class BObjectList<DMScheduledMessage>;
+public:
+ bool operator <(const DMScheduledMessage&
other) const;
+};
+
+
+#endif // DELAYED_MESSAGE_PRIVATE_H
diff --git a/src/servers/app/DelayedMessageSender.cpp
b/src/servers/app/DelayedMessageSender.cpp
new file mode 100644
index 0000000..732118f
--- /dev/null
+++ b/src/servers/app/DelayedMessageSender.cpp
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <LinkSender.h>
+#include <ServerProtocol.h>
+
+#include <Autolock.h>
+#include <String.h>
+
+#include "DelayedMessage.h"
+#include "DelayedMessageSender.h"
+
+
+static const int32 kWakeupMessage = AS_LAST_CODE + 2048;
+static const int32 kExitMessage = kWakeupMessage + 1;
+
+static const char* kName = "DMT is here for you, eventually...";
+static int32 kPriority = B_URGENT_DISPLAY_PRIORITY;
+static int32 kPortCapacity = 10;
+
+
+DelayedMessageSender* gDelayedMessageSender = NULL;
+
+
+DelayedMessageSender::DelayedMessageSender()
+ :
+ fLock("DelayedMessageSender"),
+ fMessages(20, true),
+ fScheduledWakeup(B_INFINITE_TIMEOUT),
+ fWakeupRetry(0),
+ fThread(spawn_thread(&_thread_func, kName, kPriority, this)),
+ fPort(create_port(kPortCapacity, "DelayedMessageSender")),
+ fSentCount(0)
+{
+ gDelayedMessageSender = this;
+ resume_thread(fThread);
+}
+
+
+DelayedMessageSender::~DelayedMessageSender()
+{
+ // write the exit message to our port
+ write_port(fPort, kExitMessage, NULL, 0);
+
+ // send data to the thread so it knows how to respond
+ send_data(fThread, 0, NULL, 0);
+
+ // wait for response
+ thread_id sender = -1;
+ receive_data(&sender, NULL, 0);
+
+ // We now know the thread has exited, it is safe to cleanup
+ delete_port(fPort);
+ fMessages.MakeEmpty();
+}
+
+
+int CompareMessages(const DMScheduledMessage* one,
+ const DMScheduledMessage* two)
+{
+ return *one < *two;
+}
+
+
+status_t
+DelayedMessageSender::ScheduleMessage(DelayedMessage& message)
+{
+ BAutolock _(fLock);
+
+ // Can we merge with a pending message?
+ DMScheduledMessage* pending = NULL;
+ for (int32 index = 0; index < fMessages.CountItems(); ++index) {
+ pending = fMessages.ItemAt(index);
+ if (pending->Merge(message))
+ return B_OK;
+ }
+
+ // Guess not, add it to our list!
+ DMScheduledMessage* scheduled = new(std::nothrow)
DMScheduledMessage(message);
+
+ if (scheduled == NULL)
+ return B_NO_MEMORY;
+
+ if (!scheduled->IsValid())
+ return B_BAD_DATA;
+
+ if (fMessages.AddItem(scheduled)) {
+ fMessages.SortItems(&CompareMessages);
+ _Wakeup(scheduled->ScheduledTime());
+ return B_OK;
+ }
+
+ return B_ERROR;
+}
+
+
+int32
+DelayedMessageSender::CountDelayedMessages() const
+{
+ BAutolock _(fLock);
+ return fMessages.CountItems();
+}
+
+
+int64
+DelayedMessageSender::CountSentMessages() const
+{
+ return atomic_get64(&fSentCount);
+}
+
+
+void
+DelayedMessageSender::_MessageLoop()
+{
+ status_t status = B_TIMED_OUT;
+ int32 code = -1;
+ bigtime_t timeout = B_INFINITE_TIMEOUT;
+
+ while (true) {
+ timeout = atomic_get64(&fScheduledWakeup) - (system_time()
+ + (DM_MINIMUM_DELAY / 2));
+
+ if (timeout > DM_MINIMUM_DELAY / 4)
+ status = read_port_etc(fPort, &code, NULL, 0,
B_TIMEOUT, timeout);
+ else
+ status = B_TIMED_OUT;
+
+ if (status == B_INTERRUPTED)
+ continue;
+
+ if (status == B_TIMED_OUT) {
+ _SendDelayedMessages();
+ continue;
+ }
+
+ if (status == B_OK) {
+ switch (code) {
+ case kWakeupMessage:
+ continue;
+
+ case kExitMessage: {
+ thread_id sender = -1;
+ code = receive_data(&sender, NULL, 0);
+ send_data(sender, 0, NULL, 0);
+ gDelayedMessageSender = NULL;
+ return;
+ }
+
+ // TODO: trace unhandled messages
+ default:
+ continue;
+ }
+ }
+
+ // port deleted?
+ if (status < B_OK)
+ break;
+ }
+}
+
+
+int32
+DelayedMessageSender::_thread_func(void* sender)
+{
+ (static_cast<DelayedMessageSender*>(sender))->_MessageLoop();
+ return 0;
+}
+
+
+//! Sends pending messages, call ONLY from sender thread!
+int32
+DelayedMessageSender::_SendDelayedMessages()
+{
+ // avoid sending messages during times of contention
+ if (fLock.LockWithTimeout(30000) != B_OK) {
+ atomic_add64(&fScheduledWakeup, DM_MINIMUM_DELAY);
+ return 0;
+ }
+
+ atomic_set64(&fScheduledWakeup, B_INFINITE_TIMEOUT);
+
+ if (fMessages.CountItems() == 0) {
+ fLock.Unlock();
+ return 0;
+ }
+
+ int32 sent = 0;
+
+ bigtime_t time = system_time() + DM_MINIMUM_DELAY / 2;
+ // capture any that may be on the verge of being sent.
+
+ BObjectList<DMScheduledMessage> remove;
+
+ DMScheduledMessage* message = NULL;
+ for (int32 index = 0; index < fMessages.CountItems(); ++index) {
+ message = fMessages.ItemAt(index);
+
+ if (message->ScheduledTime() > time) {
+ atomic_set64(&fScheduledWakeup,
message->ScheduledTime());
+ break;
+ }
+
+ int32 sendCount = message->SendMessage();
+ if (sendCount > 0)
+ sent += sendCount;
+
+ if (message->CountTargets() == 0)
+ remove.AddItem(message);
+ }
+
+ // remove serviced messages
+ for (int32 index = 0; index < remove.CountItems(); ++index)
+ fMessages.RemoveItem(remove.ItemAt(index));
+
+ atomic_add64(&fSentCount, sent);
+
+ // catch any partly-failed messages (possibly late):
+ if (fMessages.CountItems() > 0
+ && atomic_get64(&fScheduledWakeup) == B_INFINITE_TIMEOUT) {
+
+ fMessages.SortItems(&CompareMessages);
+ message = fMessages.ItemAt(0);
+ bigtime_t timeout = message->ScheduledTime() - time;
+
+ if (timeout < 0)
+ timeout = DM_MINIMUM_DELAY;
+
+ atomic_set64(&fScheduledWakeup, timeout);
+ }
+
+ fLock.Unlock();
+ return sent;
+}
+
+
+void
+DelayedMessageSender::_Wakeup(bigtime_t when)
+{
+ if (atomic_get64(&fScheduledWakeup) < when
+ && atomic_get(&fWakeupRetry) == 0)
+ return;
+
+ atomic_set64(&fScheduledWakeup, when);
+
+ BPrivate::LinkSender sender(fPort);
+ sender.StartMessage(kWakeupMessage);
+ status_t error = sender.Flush(30000);
+ atomic_set(&fWakeupRetry, (int32)error == B_TIMED_OUT);
+}
diff --git a/src/servers/app/DelayedMessageSender.h
b/src/servers/app/DelayedMessageSender.h
new file mode 100644
index 0000000..a80a452
--- /dev/null
+++ b/src/servers/app/DelayedMessageSender.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#ifndef AS_DELAYED_MESSAGE_SENDER_H
+#define AS_DELAYED_MESSAGE_SENDER_H
+
+
+#include <Locker.h>
+#include <ObjectList.h>
+
+#include "DelayedMessage.h"
+#include "DelayedMessagePrivate.h"
+
+
+/*! \class DelayedMessageSender DelayedMessageSender.h
+ \brief Responsible for scheduling and sending of delayed messages
+*/
+class DelayedMessageSender {
+public:
+ explicit DelayedMessageSender();
+
~DelayedMessageSender();
+
+ status_t ScheduleMessage
(DelayedMessage& message);
+
+ int32 CountDelayedMessages()
const;
+ int64 CountSentMessages()
const;
+
+private:
+ void _MessageLoop();
+ int32 _SendDelayedMessages();
+ static int32 _thread_func(void* sender);
+ void _Wakeup(bigtime_t
whatTime);
+
+ mutable BLocker fLock;
+ BObjectList<DMScheduledMessage> fMessages;
+
+ bigtime_t fScheduledWakeup;
+
+ int32 fWakeupRetry;
+
+ thread_id fThread;
+ port_id fPort;
+
+ mutable int64 fSentCount;
+};
+
+extern DelayedMessageSender* gDelayedMessageSender;
+
+#endif // AS_DELAYED_MESSAGE_SENDER_H
diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile
index 024088b..7b61d65 100644
--- a/src/servers/app/Jamfile
+++ b/src/servers/app/Jamfile
@@ -55,6 +55,9 @@ Server app_server :
CursorData.cpp
CursorManager.cpp
CursorSet.cpp
+ DelayedMessage.cpp
+ DelayedMessagePrivate.cpp
+ DelayedMessageSender.cpp
Desktop.cpp
DesktopListener.cpp
DesktopSettings.cpp

############################################################################

Commit: ef2760dcd0b3877ef41eb06439ff2618fab1cc44
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 04:08:41 2015 UTC

Cleanup MessageLooper.h

Virtual methods should have been protected, not private, no need to
repeat protected so often, one line exceeded 80 chars.

----------------------------------------------------------------------------

diff --git a/src/servers/app/MessageLooper.h b/src/servers/app/MessageLooper.h
index 9cacd30..a797006 100644
--- a/src/servers/app/MessageLooper.h
+++ b/src/servers/app/MessageLooper.h
@@ -22,7 +22,9 @@ class MessageLooper : public BLocker {
virtual bool Run();
virtual void Quit();

- status_t PostMessage(int32 code, bigtime_t
timeout = B_INFINITE_TIMEOUT);
+ status_t PostMessage(int32 code,
+ bigtime_t timeout =
B_INFINITE_TIMEOUT);
+
thread_id Thread() const { return fThread; }
bool IsQuitting() const { return fQuitting; }
sem_id DeathSemaphore() const { return
fDeathSemaphore; }
@@ -32,16 +34,14 @@ class MessageLooper : public BLocker {
static status_t WaitForQuit(sem_id semaphore,
bigtime_t timeout =
B_INFINITE_TIMEOUT);

- private:
+ protected:
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t length);
virtual void _DispatchMessage(int32 code,
BPrivate::LinkReceiver &link);
virtual void _MessageLooper();

- protected:
static int32 _message_thread(void *_looper);

- protected:
thread_id fThread;
BPrivate::PortLink fLink;
bool fQuitting;

############################################################################

Commit: c49547cff5f2a874829f075e3cf8a9e28da43714
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 04:12:25 2015 UTC

BColorMap

Useful class for handling system colors in groups rather than just one by one.
The data is hidden from the public API and is a BMessage of the same format
that will be used by the app_server to inform the applications that colors
have changed.

The data is shared in a copy-on-write fashion and a special, private, facility
permits the data to be stolen from a colormap and replaced. This is to enable
the app_server to keep a BColorMap around and to split off its data and allow
parallel adaptation of the changed colors while new updates are free to queue
in a pending BColorMap.

----------------------------------------------------------------------------

diff --git a/headers/os/interface/ColorMap.h b/headers/os/interface/ColorMap.h
new file mode 100644
index 0000000..e65bcf5
--- /dev/null
+++ b/headers/os/interface/ColorMap.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2015 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _B_COLOR_MAP
+#define _B_COLOR_MAP
+
+
+#include <Archivable.h>
+#include <InterfaceDefs.h>
+
+
+namespace BPrivate {
+ class BColorMapData;
+ class BColorMapPrivate;
+};
+
+
+class BColorMap : public BArchivable {
+public:
+ BColorMap();
+ BColorMap(const
BColorMap& other);
+
BColorMap(BMessage* from);
+ virtual ~BColorMap();
+
+ virtual status_t Archive(BMessage* into, bool
deep = true) const;
+ static BArchivable* Instantiate(BMessage* archive);
+
+ // Static methods
+
+ static const BColorMap* DefaultColorMap();
+ static const BColorMap* CurrentColorMap();
+ static status_t SetUIColors(const BColorMap*
colorMap);
+
+ static status_t Get(const BMessage* message,
int32 key,
+
rgb_color* color = NULL);
+ static status_t Get(const BMessage* message,
color_which which,
+
rgb_color* color = NULL);
+ static status_t Get(const BMessage* message,
+ const
BString& key,
+
rgb_color* color = NULL);
+
+ // Adding and removing colors.
+ // Will fail if key currently in use
+ status_t Add(int32 key,
rgb_color color);
+ status_t Add(color_which which,
rgb_color color);
+ status_t Add(const BString& key,
rgb_color color);
+ status_t Add(const BColorMap&
ColorMap);
+
+ // Will add if key not in use
+ status_t Set(int32 key,
rgb_color color);
+ status_t Set(color_which which,
rgb_color color);
+ status_t Set(const BString& key,
rgb_color color);
+ status_t Set(const BColorMap&
ColorMap);
+
+ status_t Remove(int32 key);
+ status_t Remove(color_which
which);
+ status_t Remove(const BString&
key);
+ status_t Remove(const BColorMap&
ColorMap);
+
+ void MakeEmpty();
+
+ // Retrieve colors
+ status_t Get(int32 key,
rgb_color* color) const;
+ status_t Get(color_which which,
rgb_color* color) const;
+ status_t Get(const BString& key,
rgb_color* color) const;
+
+ status_t GetNext(int32* index,
BString* key,
+
rgb_color* color);
+ // Query
+ bool HasColor(int32 key)
const;
+ bool HasColor(color_which
which) const;
+ bool HasColor(const BString&
key) const;
+
+ status_t InitCheck() const;
+ int32 CountColors() const;
+ bool IsEmpty() const;
+
+ void PrintToStream() const;
+
+ // operators
+ bool operator==(const
BColorMap& other) const;
+ bool operator!=(const
BColorMap& other) const;
+ BColorMap& operator=(const
BColorMap& other);
+
+private:
+ friend class BPrivate::BColorMapPrivate;
+ typedef BPrivate::BColorMapData* ColorMap;
+
+ status_t Set(const BMessage*
message);
+ bool _GetDataAt(int32 index,
BString* key,
+ int32*
data) const;
+ void _Init(BMessage* from);
+ status_t _InitCopyOnWrite();
+ ColorMap _ShareData() const;
+
+ ColorMap fData;
+
+ status_t fInitStatus;
+};
+
+
+#endif // _B_COLOR_MAP
diff --git a/headers/private/interface/ColorMapPrivate.h
b/headers/private/interface/ColorMapPrivate.h
new file mode 100644
index 0000000..d1b82ad
--- /dev/null
+++ b/headers/private/interface/ColorMapPrivate.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+*/
+#ifndef _B_COLORMAP_PRIVATE_H_
+#define _B_COLORMAP_PRIVATE_H_
+
+
+#include <ColorMap.h>
+#include <Locker.h>
+#include <Message.h>
+#include <Referenceable.h>
+
+
+namespace BPrivate {
+
+
+//! Shared data for BColorMap
+class BColorMapData : public BReferenceable, public BMessage, public BLocker {
+public:
+ BColorMapData();
+
BColorMapData(BMessage* from);
+
BColorMapData(const BColorMapData& other);
+ virtual ~BColorMapData();
+
+ status_t Add(const BString& key,
rgb_color color);
+ status_t Add(const BString& key,
int32 color);
+ void Remove(const BString&
key);
+ void RemoveAll();
+
+ status_t Send(port_id port,
team_id team, int32 token,
+
bigtime_t timeout = 25000);
+
+ // iteration interface for app_server use
+ status_t GetNext(int32* cookie,
color_which* key,
+
rgb_color* color);
+
+ void SetShared(bool shared);
+ bool IsShared() const;
+private:
+ bool fIsShared;
+};
+
+
+//! Data acquisition modes
+enum {
+ B_CM_SHARE_DATA = 0,// Default - just acquire a reference
+ // Copies are made if modifications are made to maps which share
+ // data.
+
+ B_CM_STEAL_DATA = 1,// Take the data, and reset the colormap
+ // The given color map will get a new, clean, data object, and
+ // the caller will take ownership of the acquired data.
+
+ B_CM_COPY_DATA = 2 // Copy the data, release to destroy
copy
+};
+
+
+//! Provide direct read-only access to private BColorMap data
+class BColorMapPrivate {
+public:
+ static BColorMapData* AcquireData(BColorMap& colorMap,
+ int32
count = 1,
+ uint32
mode = B_CM_SHARE_DATA);
+ static void
ReleaseData(BColorMapData* data,
+ int32
count = 1,
+ bool
ensureDestruction = false);
+
+ // Update current colormap - if it exists
+ static void Update(const BMessage* message);
+ static void Update(const color_which& which,
+ const
rgb_color& color);
+};
+
+
+}; // end namespace BPrivate
+
+
+#endif //_B_COLORMAP_PRIVATE_H_
diff --git a/src/kits/interface/ColorMap.cpp b/src/kits/interface/ColorMap.cpp
new file mode 100644
index 0000000..e8d7a1a
--- /dev/null
+++ b/src/kits/interface/ColorMap.cpp
@@ -0,0 +1,940 @@
+/*
+ * Copyright 2015, Haiku.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Joseph Groover <looncraz@xxxxxxxxxxxx>
+*/
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <Application.h>
+#include <Autolock.h>
+#include <ColorMap.h>
+#include <Locker.h>
+#include <StringList.h>
+
+#include <ColorMapPrivate.h>
+#include <DefaultColors.h>
+#include <MessagePrivate.h>
+#include <ServerReadOnlyMemory.h>
+
+
+// helpful macros
+#define CHECK_READ_STATUS(X) if (InitCheck() != B_OK) return X ;
+#define CHECK_WRITE_STATUS(X) if (_InitCopyOnWrite() != B_OK) return X ;
+
+
+static BLocker be_global_colormap_lock;
+static BColorMap* be_default_colormap = NULL;
+static BColorMap* be_current_colormap = NULL;
+
+static const rgb_color kFailureColor = make_color(0, 0, 0, 0);
+
+
+BColorMap::BColorMap()
+ :
+ fData(NULL),
+ fInitStatus(B_OK)
+{
+ _Init(NULL);
+}
+
+
+BColorMap::BColorMap(const BColorMap& other)
+ :
+ fData(other._ShareData()),
+ fInitStatus(B_OK)
+{
+ if (fData == NULL)
+ fInitStatus = B_BAD_VALUE;
+}
+
+
+BColorMap::BColorMap(BMessage* from)
+ :
+ fData(NULL),
+ fInitStatus(B_OK)
+{
+ _Init(from);
+}
+
+
+BColorMap::~BColorMap()
+{
+ BAutolock _(be_global_colormap_lock);
+ if (this == be_current_colormap)
+ be_current_colormap = NULL;
+ else if (this == be_default_colormap)
+ be_default_colormap = NULL;
+
+ // fData will delete itself when not used
+ if (fData != NULL)
+ fData->ReleaseReference();
+}
+
+
+// #pragma mark Archiving
+
+
+status_t
+BColorMap::Archive(BMessage* into, bool deep) const
+{
+ CHECK_READ_STATUS(fInitStatus);
+
+ if (into == NULL)
+ return B_BAD_VALUE;
+
+ return into->AddMessage("be:colormap", fData);
+}
+
+
+BArchivable*
+BColorMap::Instantiate(BMessage* archive)
+{
+ return new(std::nothrow) BColorMap(archive);
+}
+
+
+// #pragma mark Static
+
+
+const BColorMap*
+BColorMap::DefaultColorMap()
+{
+ BAutolock _(be_global_colormap_lock);
+
+ if (be_default_colormap != NULL)
+ return be_default_colormap;
+
+ be_default_colormap = new(std::nothrow) BColorMap();
+ if (be_default_colormap == NULL) {
+ fprintf(stderr, "no memory!\n");
+ return NULL;
+ }
+
+ for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which) {
+ be_default_colormap->Add(which, BPrivate::kDefaultColors[
+ color_which_to_index((color_which)which)]);
+ }
+
+ be_default_colormap->Add((int32)B_SUCCESS_COLOR,
+
BPrivate::kDefaultColors[color_which_to_index(B_SUCCESS_COLOR)]);
+ be_default_colormap->Add((int32)B_FAILURE_COLOR,
+
BPrivate::kDefaultColors[color_which_to_index(B_FAILURE_COLOR)]);
+
+ return be_default_colormap;
+}
+
+
+const BColorMap*
+BColorMap::CurrentColorMap()
+{
+ if (be_app == NULL) {
+ printf("BApplication object required to get current color
set!\n");
+ return DefaultColorMap();
+ }
+
+ BAutolock _(be_global_colormap_lock);
+
+ // set_ui_color will keep this up-to-date
+ if (be_current_colormap != NULL)
+ return be_current_colormap;
+
+ be_current_colormap = new(std::nothrow) BColorMap();
+ if (be_current_colormap == NULL) {
+ fprintf(stderr, "no memory!\n");
+ return NULL;
+ }
+
+ for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which)
+ be_current_colormap->Add(which, ui_color((color_which)which));
+
+ be_current_colormap->Add((int32)B_SUCCESS_COLOR,
+ ui_color(B_SUCCESS_COLOR));
+ be_current_colormap->Add((int32)B_FAILURE_COLOR,
+ ui_color(B_FAILURE_COLOR));
+
+ return be_current_colormap;
+}
+
+
+status_t
+BColorMap::SetUIColors(const BColorMap* colorMap)
+{
+ if (colorMap == NULL || colorMap->CountColors() < 0)
+ return B_BAD_VALUE;
+
+ if (colorMap->CountColors() == 0)
+ return B_OK;
+
+ // We do this by searching for known color_which values, rather than
+ // iterating through the color-map, so maps can have erroneous entries
+ // without us knowing or caring about them. It also has nice error
+ // checking, performance, and security advantages - a color map with
+ // 1,000+ false entries should not cause issues of any kind.
+ rgb_color color;
+ int32 count = 0;
+ for (int32 key = 1; key <= kColorWhichLastContinuous; ++key) {
+ if (colorMap->Get(key, &color) == B_OK) {
+ ++count;
+ set_ui_color((color_which)key, color);
+ }
+ }
+
+ // These colors have special key values
+ if (colorMap->Get(B_FAILURE_COLOR, &color) == B_OK) {
+ ++count;
+ set_ui_color(B_FAILURE_COLOR, color);
+ }
+
+ if (colorMap->Get(B_SUCCESS_COLOR, &color) == B_OK) {
+ ++count;
+ set_ui_color(B_SUCCESS_COLOR, color);
+ }
+
+ // having no system colors in the map *IS* an error at this point
+ return count > 0 ? B_OK : B_ERROR;
+}
+
+
+status_t
+BColorMap::Get(const BMessage* message, int32 key, rgb_color* color)
+{
+ BString name;
+ name << key;
+ return BColorMap::Get(message, name, color);
+}
+
+
+status_t
+BColorMap::Get(const BMessage* message, color_which which, rgb_color* color)
+{
+ return BColorMap::Get(message, (int32)which, color);
+}
+
+
+status_t
+BColorMap::Get(const BMessage* message, const BString& key, rgb_color* color)
+{
+ if (message == NULL)
+ return B_BAD_VALUE;
+
+ int32 intColor = 0;
+ status_t error = message->FindInt32(key, &intColor);
+
+ if (error == B_OK && color != NULL) {
+ intColor = B_HOST_TO_BENDIAN_INT32(intColor);
+ *color = *(rgb_color*)&intColor;
+ }
+
+ return error;
+}
+
+
+// #pragma mark Add
+
+
+status_t
+BColorMap::Add(int32 key, rgb_color color)
+{
+ BString name;
+ name << key;
+ return Add(name, color);
+}
+
+
+status_t
+BColorMap::Add(color_which which, rgb_color color)
+{
+ return Add((int32)which, color);
+}
+
+
+status_t
+BColorMap::Add(const BString& key, rgb_color color)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ if (HasColor(key))
+ return B_BAD_INDEX;
+
+ return fData->Add(key, color);
+}
+
+
+status_t
+BColorMap::Add(const BColorMap& colorMap)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ // Technically not an error
+ if (colorMap.CountColors() == 0)
+ return B_OK;
+
+ status_t error = B_OK;
+ BString key;
+ int32 color = 0;
+
+ for (int32 index = 0; index < colorMap.CountColors(); ++index) {
+ if (!colorMap._GetDataAt(index, &key, &color))
+ return B_BAD_DATA;
+
+ error = fData->Add(key, color);
+ if (error != B_OK)
+ break;
+ }
+
+ return error;
+}
+
+
+// #pragma mark Set
+
+
+status_t
+BColorMap::Set(int32 key, rgb_color color)
+{
+ BString name;
+ name << key;
+ return Set(name, color);
+}
+
+
+status_t
+BColorMap::Set(color_which which, rgb_color color)
+{
+ return Set((int32)which, color);
+}
+
+
+status_t
+BColorMap::Set(const BString& key, rgb_color color)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ fData->Remove(key);
+ return fData->Add(key, color);
+}
+
+
+status_t
+BColorMap::Set(const BColorMap& colorMap)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ // Technically not an error
+ if (colorMap.CountColors() == 0)
+ return B_OK;
+
+ BString key;
+ int32 color = 0;
+
+ status_t error = B_OK;
+ for (int32 index = 0; index < colorMap.CountColors(); ++index) {
+ if (!colorMap._GetDataAt(index, &key, &color))
+ return B_BAD_DATA;
+
+ fData->Remove(key);
+ error = fData->Add(key, color);
+
+ if (error != B_OK)
+ break;
+ }
+
+ return error;
+}
+
+
+// #pragma mark Remove
+
+
+status_t
+BColorMap::Remove(int32 key)
+{
+ BString name;
+ name << key;
+ return Remove(name);
+}
+
+
+status_t
+BColorMap::Remove(color_which which)
+{
+ return Remove((int32)which);
+}
+
+
+status_t
+BColorMap::Remove(const BString& key)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ if (!HasColor(key))
+ return B_BAD_VALUE;
+
+ fData->Remove(key);
+ return B_OK;
+}
+
+
+status_t
+BColorMap::Remove(const BColorMap& colorMap)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ if (colorMap.CountColors() == 0)
+ return B_OK;
+
+ BString key;
+ int32 color = 0;
+
+ for (int32 index = 0; index < colorMap.CountColors(); ++index) {
+ if (!colorMap._GetDataAt(index, &key, &color))
+ return B_BAD_DATA;
+
+ fData->Remove(key);
+ }
+
+ return B_OK;
+}
+
+
+void
+BColorMap::MakeEmpty()
+{
+ if (fData != NULL && _InitCopyOnWrite() == B_OK) {
+ BAutolock _(fData);
+ fData->RemoveAll();
+ }
+}
+
+
+// #pragma mark Retrieve
+
+
+status_t
+BColorMap::Get(int32 key, rgb_color* color) const
+{
+ BString name;
+ name << key;
+ return Get(name, color);
+}
+
+
+status_t
+BColorMap::Get(color_which which, rgb_color* color) const
+{
+ return Get((int32)which, color);
+}
+
+
+status_t
+BColorMap::Get(const BString& key, rgb_color* color) const
+{
+ CHECK_READ_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ int32 intColor = 0;
+ status_t error = fData->FindInt32(key.String(), &intColor);
+
+ if (error == B_OK && color != NULL) {
+ intColor = B_HOST_TO_BENDIAN_INT32(intColor);
+ *color = *(rgb_color*)&intColor;
+ }
+
+ return error;
+}
+
+
+status_t
+BColorMap::GetNext(int32* index, BString* key, rgb_color* color)
+{
+ if (index == NULL || key == NULL || *index < 0)
+ return B_BAD_VALUE;
+
+ CHECK_READ_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ int32 intColor = 0;
+ if (!_GetDataAt(*index, key, &intColor))
+ return B_BAD_INDEX;
+
+ if (color != NULL) {
+ intColor = B_HOST_TO_BENDIAN_INT32(intColor);
+ *color = *(rgb_color*)&intColor;
+ }
+
+ return B_OK;
+}
+
+
+// #pragma mark Query
+
+
+bool
+BColorMap::HasColor(int32 key) const
+{
+ BString name;
+ name << key;
+ return HasColor(name);
+}
+
+
+bool
+BColorMap::HasColor(color_which which) const
+{
+ return HasColor((int32)which);
+}
+
+
+bool
+BColorMap::HasColor(const BString& key) const
+{
+ CHECK_READ_STATUS(false);
+ BAutolock _(fData);
+
+ int32 color = 0;
+ return fData->FindInt32(key.String(), &color) == B_OK;
+}
+
+
+status_t
+BColorMap::InitCheck() const
+{
+ return fInitStatus;
+}
+
+
+int32
+BColorMap::CountColors() const
+{
+ CHECK_READ_STATUS(0);
+ BAutolock _(fData);
+
+ return fData->CountNames(B_INT32_TYPE);
+}
+
+
+bool
+BColorMap::IsEmpty() const
+{
+ return CountColors() == 0;
+}
+
+
+void
+BColorMap::PrintToStream() const
+{
+ if (fData == NULL) {
+ printf("BColorMap: ERROR: NULL DATA!\n");
+ return;
+ }
+
+ BAutolock _(fData);
+
+ printf("BColorMap: %li colors {\n", CountColors());
+
+ BString key;
+ int32 intColor;
+ rgb_color color;
+
+ if (fInitStatus != B_OK)
+ printf("\tINIT FAILURE: %li\n", fInitStatus);
+
+ for (int32 index = 0; index < CountColors(); ++index) {
+ if (!_GetDataAt(index, &key, &intColor)) {
+ printf("\tError @ index %li\n", index);
+ break;
+ }
+ intColor = B_HOST_TO_BENDIAN_INT32(intColor);
+ color = *(rgb_color*)&intColor;
+
+ printf("\t%-5li %-20s rgb_color(%3i, %3i, %3i, %3i)\n", index,
+ key.String(), color.red, color.green, color.blue,
color.alpha);
+ }
+ printf("}\n");
+}
+
+
+// #pragma mark Operators
+
+
+bool
+BColorMap::operator==(const BColorMap& other) const
+{
+ if (other.CountColors() != CountColors()
+ || other.fData == NULL || fData == NULL)
+ return false;
+
+ // Do we use the same shared data?
+ if (other.fData == fData)
+ return true;
+
+ // Important: the order of colors MUST NOT matter!
+ BString key;
+ int32 ourData = 0;
+ int32 otherData = 0;
+ int32 index = 0;
+ while (_GetDataAt(index++, &key, &ourData)) {
+ if (other.fData->FindInt32(key.String(), &otherData) != B_OK
+ || otherData != ourData) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+bool
+BColorMap::operator!=(const BColorMap& other) const
+{
+ return !(*this == other);
+}
+
+
+BColorMap&
+BColorMap::operator=(const BColorMap& other)
+{
+ if (fData != NULL)
+ fData->ReleaseReference();
+
+ fData = other._ShareData();
+ return *this;
+}
+
+
+// #pragma mark Private
+
+
+status_t
+BColorMap::Set(const BMessage* message)
+{
+ CHECK_WRITE_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ int32 count = message->CountNames(B_INT32_TYPE);
+ if (count == 0)
+ return B_OK;
+
+ count = 0;
+ int32 intColor = 0;
+ const char* key;
+ for (int32 which = 1; which < kColorWhichLastContinuous + 1; ++which) {
+ BString name;
+ name << which;
+ key = name.String();
+ if (message->FindInt32(key, &intColor) == B_OK) {
+ fData->Remove(name);
+
+ fData->AddInt32(key, intColor);
+ ++count;
+ }
+ }
+
+ return count > 0 ? B_OK : B_ERROR;
+}
+
+
+bool
+BColorMap::_GetDataAt(int32 index, BString* keyOut, int32* data) const
+{
+ if (index < 0 || index >= CountColors())
+ return false;
+
+ char* name = NULL;
+ type_code type;
+
+ if (fData->GetInfo(B_INT32_TYPE, index, &name, &type) != B_OK)
+ return false;
+
+ if (keyOut != NULL)
+ *keyOut = name;
+
+ if (data != NULL && fData->FindInt32(name, data) != B_OK)
+ return false;
+
+ return true;
+}
+
+
+void
+BColorMap::_Init(BMessage* from)
+{
+ BMessage archive;
+
+ if (from == NULL)
+ fData = new(std::nothrow) BPrivate::BColorMapData();
+ else if (from->FindMessage("be:colormap", &archive) == B_OK)
+ fData = new(std::nothrow) BPrivate::BColorMapData(&archive);
+ else
+ fData = new(std::nothrow) BPrivate::BColorMapData(from);
+
+ if (fData == NULL)
+ fInitStatus = B_NO_MEMORY;
+}
+
+
+status_t
+BColorMap::_InitCopyOnWrite()
+{
+ // If we can't read, we can't copy for writing...
+ CHECK_READ_STATUS(fInitStatus);
+ BAutolock _(fData);
+
+ if (fData->IsShared()) {
+ BPrivate::BColorMapData* newData = new(std::nothrow) BPrivate
+ ::BColorMapData(*fData);
+
+ if (newData == NULL)
+ return B_NO_MEMORY;
+
+ fData->ReleaseReference();
+ fData = newData;
+ return B_OK;
+ }
+
+ return B_OK;
+}
+
+
+BPrivate::BColorMapData*
+BColorMap::_ShareData() const
+{
+ BPrivate
+ ::BColorMapData* data = const_cast<BPrivate::BColorMapData*>(fData);
+
+ data->AcquireReference();
+ data->SetShared(true);
+ return data;
+}
+
+
+// #pragma mark BColorMapData
+
+
+namespace BPrivate {
+
+
+BColorMapData::BColorMapData()
+ :
+ BMessage(B_COLORS_UPDATED),
+ BLocker("BColorMapData", true),
+ fIsShared(false)
+{
+}
+
+
+BColorMapData::BColorMapData(BMessage* message)
+ :
+ BMessage(*message),
+ BLocker("BColorMapData", true),
+ fIsShared(false)
+{
+ what = B_COLORS_UPDATED;
+}
+
+
+BColorMapData::BColorMapData(const BColorMapData& other)
+ :
+ BMessage(other),
+ BLocker("BColorMapData", true),
+ fIsShared(false)
+{
+ what = B_COLORS_UPDATED;
+}
+
+
+BColorMapData::~BColorMapData()
+{
+}
+
+
+status_t
+BColorMapData::Add(const BString& key, rgb_color color)
+{
+ return Add(key, B_BENDIAN_TO_HOST_INT32(*(int32*)&color));
+}
+
+
+status_t
+BColorMapData::Add(const BString& key, int32 color)
+{
+ int32 test = 0;
+ if (FindInt32(key.String(), &test) == B_OK)
+ return B_BAD_INDEX;
+
+ return AddInt32(key.String(), color);
+}
+
+
+void
+BColorMapData::Remove(const BString& key)
+{
+ RemoveName(key.String());
+}
+
+
+void
+BColorMapData::RemoveAll()
+{
+ MakeEmpty();
+}
+
+
+status_t
+BColorMapData::Send(port_id port, team_id team, int32 token,
+ bigtime_t timeout)
+{
+ if (port < 0 || team < 0 || token == B_NULL_TOKEN)
+ return B_BAD_VALUE;
+
+ BMessenger reply;
+ BMessage::Private messagePrivate(this);
+
+ what = B_COLORS_UPDATED;
+ return messagePrivate.SendMessage(port, team, token, timeout, false,
+ reply);
+}
+
+
+status_t
+BColorMapData::GetNext(int32* cookie, color_which* key, rgb_color* color)
+{
+ if (cookie == NULL || key == NULL || color == NULL)
+ return B_BAD_VALUE;
+
+ char* name = NULL;
+ type_code type;
+
+ status_t error = GetInfo(B_INT32_TYPE, *cookie, &name, &type);
+ if (error != B_OK)
+ return error;
+
+ int32 intColor = 0;
+ error = FindInt32(name, &intColor);
+
+ if (error == B_OK) {
+ *key = (color_which)atoi(name);
+ intColor = B_HOST_TO_BENDIAN_INT32(intColor);
+ *color = *(rgb_color*)&intColor;
+ }
+
+ // increment no matter what, some errors may be ignored by the caller...
+ *cookie = *cookie + 1;
+ return error;
+}
+
+
+void
+BColorMapData::SetShared(bool shared)
+{
+ fIsShared = shared;
+}
+
+
+bool
+BColorMapData::IsShared() const
+{
+ return fIsShared;
+}
+
+
+// #pragma mark BColorMapPrivate
+
+
+BColorMapData*
+BColorMapPrivate::AcquireData(BColorMap& colorMap, int32 times,
+ uint32 mode)
+{
+ if (times < 1)
+ return NULL;
+
+ BColorMapData* data = colorMap.fData;
+ if (data != NULL) {
+
+ // Lock the data so it doesn't change, and obtain a reference
so it
+ // isn't deleted until we are done. The order here is
important.
+ data->AcquireReference();
+ BAutolock _(data);
+
+ switch (mode) {
+ case B_CM_SHARE_DATA:
+ break;
+ case B_CM_STEAL_DATA:
+ {
+ BColorMapData* newData = new(std::nothrow)
BColorMapData();
+ if (newData == NULL)
+ return NULL;
+
+ data->ReleaseReference();
+ colorMap.fData = newData;
+ // release BColorMap's default reference
+ break;
+ }
+ case B_CM_COPY_DATA:
+ {
+ data = new(std::nothrow)
BColorMapData(*colorMap.fData);
+ // starts life with one reference, so
all is good!
+
+ if (data == NULL)
+ return NULL;
+ break;
+ }
+ }
+
+ // acquire the reference(s) (minus the one we already hold)
+ // BReferenceable could probably use a facility for this...
+ for (int32 count = 0; count < times - 1; ++count)
+ data->AcquireReference();
+ }
+
+ return data;
+}
+
+
+void
+BColorMapPrivate::ReleaseData(BColorMapData* data, int32 times, bool destroy)
+{
+ if (data != NULL) {
+ if (destroy)
+ times = data->ReleaseReference() - 1;
+
+ for (int32 count = 0; count < times; ++count)
+ data->ReleaseReference();
+ }
+}
+
+
+void
+BColorMapPrivate::Update(const BMessage* message)
+{
+ if (be_global_colormap_lock.Lock()) {
+ if (be_current_colormap != NULL)
+ be_current_colormap->Set(message);
+
+ be_global_colormap_lock.Unlock();
+ }
+}
+
+
+void
+BColorMapPrivate::Update(const color_which& which, const rgb_color& color)
+{
+ if (be_global_colormap_lock.Lock()) {
+ if (be_current_colormap != NULL)
+ be_current_colormap->Set(which, color);
+
+ be_global_colormap_lock.Unlock();
+ }
+}
+
+
+}; // end namespace BPrivate

############################################################################

Commit: ad9d35551038083c0bb3b83775fa3114a12cffcd
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 04:44:27 2015 UTC

Set*UIColor, etc.

The inseperable changes necessary to support live color updating across the
system in a sane, safe, and performant manner.

BView gains:

HasSystemColors()
HasDefaultColors()
AdoptSystemColors()
AdoptParentColors()
AdoptViewColor(BView*)
SetViewUIColor(color_which, float tint)
SetHighUIColor(...
SetLowUIColor(...
ViewUIColor(float* tint)
HighUIColor(...
LowUIColor(...

BWindow gains a simple helper method:
IsOffscreenWindow()

Previous private ColorTools methods are made public and moved into GraphicsDefs:

mix_color, blend_color, disable_color

These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup
of BeOS example code under the OpenTracker license.

In addition, four new colors are created:
B_LINK_TEXT_COLOR
B_LINK_HOVER_COLOR
B_LINK_ACTIVE_COLOR
B_LINK_VISITED_COLOR

These changes are documented in their proper user documentation files.

On the app_server side, the following has changed:

Desktop gains the ability to add message ports to a DelayedMessage so that
said messages can target either all applications or all windows, as needed.

Desktop maintains a BColorMap which is used to queue up all pending color
changes
and the delayed messaging system is used only enact tese changes after a good
period of time has passed. This prevents abuse and allows the system to merge
repeated set_ui_color events into one event for client applications.

In addition, B_COLORS_UPDATED is sent the BApplication, which forwards the
message
to each BWindow. This is done to improve performance over having the app_server
independently informing each window. This greatly reduces lock contention
around
Desktop's window lock, as each application will grab the lock in ServerApp and
will have each window update its views and decorator, rather than each window
vying for the write lock.

Decorator changes are live now, which required some reworking.

----------------------------------------------------------------------------

diff --git a/docs/user/interface/View.dox b/docs/user/interface/View.dox
index 80f7767..fd8abbb 100644
--- a/docs/user/interface/View.dox
+++ b/docs/user/interface/View.dox
@@ -1,13 +1,14 @@
/*
- * Copyright 2011-2014 Haiku, Inc. All rights reserved.
+ * Copyright 2011-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* John Scipione, jscipione@xxxxxxxxx
+ * Joseph Groover, looncraz@xxxxxxxxxxxx
*
* Corresponds to:
- * headers/os/interface/View.h hrev47274
- * src/kits/interface/View.cpp hrev47274
+ * headers/os/interface/View.h hrev497**
+ * src/kits/interface/View.cpp hrev497**
*/


@@ -524,6 +525,15 @@


/*!
+ \var B_FOLLOW_DEFAULT
+ \brief The margins between the left and top sides of the view and the
left
+ and top sides of its parent remain constant.
+
+ \since Haiku B1
+*/
+
+
+/*!
\class BView
\ingroup interface
\ingroup libbe
@@ -596,12 +606,13 @@ if (Window()->LockLooper()) {

Each view has a ViewColor() that fills the frame rectangle before the
view does any drawing of its own. The default view color is white, you
may
- change the view color by calling SetViewColor(). A commonly used view
color
- is \c B_PANEL_BACKGROUND_COLOR which is a grey color used as the view
color
- of many Interface Kit classes. If you set the view color to
- \c B_TRANSPARENT_COLOR then the Application Server won't erase the
clipping
- region of the view before updating, this should only be used if the view
- erases itself by drawing on every pixel in the clipping region.
+ change the view color by calling SetViewColor() or, as of Haiku B1,
+ SetViewUIColor(). A commonly used view color is \c
B_PANEL_BACKGROUND_COLOR
+ which is a user-defined color used as the view color of most
applications.
+ If you set the view color to \c B_TRANSPARENT_COLOR then the
Application Server
+ won't erase the clipping region of the view before updating, this
should only
+ be used if the view erases itself by drawing on every pixel in the
clipping
+ region.

If you want to set the view color of a view to be the same as its
parent you
need to set it within the AttachedToWindow() method of the view like so:
@@ -614,6 +625,7 @@ SetViewColor(Parent()->ViewColor());
*/


+
/*!
\fn BView::BView(const char* name, uint32 flags, BLayout* layout)
\brief Layout constructor.
@@ -2058,6 +2070,59 @@ SetViewColor(Parent()->ViewColor());


/*!
+ \fn bool BView::HasDefaultColors() const
+ \brief Tests if the view has any colors set.
+
+ \return Boolean value, true if colors are not set.
+
+ \since Haiku B1
+*/
+
+
+/*!
+ \fn bool BView::HasSystemColors() const
+ \brief Tests if the view is using system "panel" colors.
+ B_PANEL_BACKGROUND_COLOR for ViewUIColor()
+ B_PANEL_BACKGROUND_COLOR for LowUIColor()
+ B_PANEL_TEXT_COLOR for HighUIColor()
+
+ \return Boolean value, true if colors are as described.
+
+ \since Haiku B1
+*/
+
+
+/*!
+ \fn void BView::AdoptParentColors()
+ \brief Attempts to use the colors of any parent view.
+ Will adopt view, low, and high colors.
+ Should be called in AttachedToWindow() or AllAttached().
+
+ \since Haiku B1
+*/
+
+
+/*!
+ \fn void BView::AdoptSystemColors()
+ \brief Instructs view to use standard system "panel" colors.
+ B_PANEL_BACKGROUND_COLOR for ViewUIColor()
+ B_PANEL_BACKGROUND_COLOR for LowUIColor()
+ B_PANEL_TEXT_COLOR for HighUIColor()
+
+ \since Haiku B1
+*/
+
+
+/*!
+ \fn void BView::AdoptViewColors(BView* view)
+ \brief Attempts to use the colors of a given view.
+ Will adopt view, low, and high colors.
+
+ \since Haiku B1
+*/
+
+
+/*!
\fn void BView::SetHighColor(rgb_color color)
\brief Set the high color of the view.

@@ -2082,6 +2147,18 @@ SetViewColor(Parent()->ViewColor());


/*!
+ \fn void BView::SetHighUIColor(color_which which, float tint)
+ \brief Set the high color of the view to a system constant.
+ The color will update live with user changes.
+
+ \param which The color_which constant to set.
+ \param tint Optional tint value to use.
+
+ \since Haiku B1
+*/
+
+
+/*!
\fn rgb_color BView::HighColor() const
\brief Return the current high color.

@@ -2095,6 +2172,20 @@ SetViewColor(Parent()->ViewColor());


/*!
+ \fn color_which BView::HighUIColor(float* tint) const
+ \brief Return the current high color constant being used.
+
+ \param tint Optional float pointer in which to store the tint
+ value used to modify the system color constant.
+ \return The current high color constant.
+
+ \sa SetHighUIColor(color_which, float)

[ *** diff truncated: 3298 lines dropped *** ]


############################################################################

Commit: c2c08afb3f9cfe729fd2d251d6a08405b7475cc4
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:04:18 2015 UTC

LinkReceiver Fix

LinkReceiver would spin endlessly when given a timeout value which prevented
DelayedMessageSender from being operational.

----------------------------------------------------------------------------

############################################################################

Commit: 086cb213e583658ba8e26c35860d64d2642ca90d
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:11:05 2015 UTC

B_FOLLOW_DEFAULT

Make use of the new flag to cleanup the interface headers.

----------------------------------------------------------------------------

############################################################################

Commit: 3a52669f32688a4181d18d1b502484277ddf2fe8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:12:03 2015 UTC

ControlLook Colors

Enable better use of the proper colors, as well as overriding the
assumed proper colors for labels.

----------------------------------------------------------------------------

############################################################################

Commit: a19ed4b7082562d459150318ebf9f94879166d47
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:13:15 2015 UTC

ColumnListView colors

ColumnListView now responds to system color changes.

----------------------------------------------------------------------------

############################################################################

Commit: de20fbe09a02dc9214b7b26267985e1ac2fa6a47
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:14:44 2015 UTC

Private Headers B_FOLLOW_DEFAULT

----------------------------------------------------------------------------

############################################################################

Commit: 87f6001197b562bcbc3f1026ba3b6c6ab9d7e9e8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:15:45 2015 UTC

StatusBar colors

Add fInternalFlags and a single flag to denote the use of custom colors.
Have status bar use appropriate colors, either by adopting colors, or
by using system standard colors.
Live colors updates are also working.

----------------------------------------------------------------------------

############################################################################

Commit: bc32f3a6d487a231e9d9ed09179756cb6f0f11cc
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:18:51 2015 UTC

BAboutWindow colors

----------------------------------------------------------------------------

############################################################################

Commit: 036b345b3273205f8526c3bd0024a696bafc4871
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:19:18 2015 UTC

BAlert colors

----------------------------------------------------------------------------

############################################################################

Commit: f0ef0f1b1ee1ea88e2dcabcf6ee52318e009c373
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:19:34 2015 UTC

BBox colors

----------------------------------------------------------------------------

############################################################################

Commit: 290e0af374a8fdc155710d56bd05a90bf3e81d34
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:19:47 2015 UTC

BButton colors

BButton now properly uses the B_CONTROL_BACKGROUND_COLOR instead of
a darkened view color.

----------------------------------------------------------------------------

############################################################################

Commit: d11333face4d32e2c7eb5a7a6f7f80ad359aa2ef
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:23:44 2015 UTC

BControl colors

This includes simple changes to common controls.

----------------------------------------------------------------------------

############################################################################

Commit: 58016f22bac32a014c436ac42aa9d59964669817
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:25:36 2015 UTC

AbstractSpinner colors

----------------------------------------------------------------------------

############################################################################

Commit: 6629d73e7a3e666963543cb9a4eda6bfbe702af6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:26:29 2015 UTC

Menu colors

----------------------------------------------------------------------------

############################################################################

Commit: 6b3d9f1e8ceb9bad71074b8a449edb216a18a213
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:27:03 2015 UTC

BListView colors

----------------------------------------------------------------------------

############################################################################

Commit: 17f05b2a4b675bef0e5e311cd8d0f3299b2544a2
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:27:35 2015 UTC

BTabView colors

----------------------------------------------------------------------------

############################################################################

Commit: 7dbd81ee5a958bb4a505f43d592947b0f828ec93
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:28:20 2015 UTC

Specialized Layout Views colors

Views used by layout.

----------------------------------------------------------------------------

############################################################################

Commit: 070fb81d0471321a9c0531ea7b2cd28b302012a8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:30:18 2015 UTC

Colors

----------------------------------------------------------------------------

############################################################################

Commit: cc8deea45cb19933187f381b41967a79396d96ab
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:32:46 2015 UTC

ToolTip colors

----------------------------------------------------------------------------

############################################################################

Commit: dfb99876ede2b6dbd4540e46d161e2a56520371a
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:34:00 2015 UTC

Chart colors and some font awareness

Chart had horrible behavior with large fonts and many hardcoded colors.
This helps this situation immensely.

----------------------------------------------------------------------------

############################################################################

Commit: 56f12192f8498a3e493bb817b4acd0ad410ab5e2
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:34:58 2015 UTC

Tests color changes

Iteratively replace usage of Set*Color(ui_color... with Set*UIColor(...

----------------------------------------------------------------------------

############################################################################

Commit: 4d54076da0e907683ffe3bb9561c737503b538c4
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:37:21 2015 UTC

Mail Deskbar Replicant colors

----------------------------------------------------------------------------

############################################################################

Commit: ad242c7554a604c5ced63b4f9ffd42028a6ea6ad
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:38:02 2015 UTC

Bluetooth Deskbar Replicant colors

----------------------------------------------------------------------------

############################################################################

Commit: 620c194c3729592202b5c877bcf0138675086ebb
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:38:18 2015 UTC

Server UI colors

Iterative changes, mostly.

----------------------------------------------------------------------------

############################################################################

Commit: e3d1f03df3cb8854b195ae2aa4075484da5136f6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:38:56 2015 UTC

Time Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: 930a81ae22861a4f7357598ceb8d369e44e9c9e1
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:40:15 2015 UTC

Screensaver preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: c7bea78235dac1e010515537e844b24d86067f44
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:40:30 2015 UTC

Screen Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: 4c4f90a745d6e1bf28ebf1176f8da50e42f07b00
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:40:44 2015 UTC

Network Preflet Colors

----------------------------------------------------------------------------

############################################################################

Commit: 7ce050ab3beea1b7b5456df37e62d85391c81a8e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:40:58 2015 UTC

Mouse Preflet Colors

----------------------------------------------------------------------------

############################################################################

Commit: 5f13904edd5ea9f962bbcefae1ebf8043d11e5a5
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:42:28 2015 UTC

Media System Colors

Preflet, replicant, and DefaultMediaTheme

----------------------------------------------------------------------------

############################################################################

Commit: c51d52ab9f25722dd4218cebda72af093a8fed4a
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:43:02 2015 UTC

Mail Preflet Colors

----------------------------------------------------------------------------

############################################################################

Commit: a9eb14335d7806b4176150f5f307cc3c2200bb15
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:43:17 2015 UTC

Locale Preflet Colors

----------------------------------------------------------------------------

############################################################################

Commit: e5a8806b856b8c92df74da134a0d25f1a910b67b
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:43:30 2015 UTC

Keymap colors

----------------------------------------------------------------------------

############################################################################

Commit: 1a825b0d3a0e678da86a6b76e8732850eba8c9c8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:43:43 2015 UTC

Joysticks Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: d6ab7770ab4e37d73b9d6064703a9677420d36ae
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:43:58 2015 UTC

Font Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: 9a04383419bc9b4de626a7e8188140ffa018dd8e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:44:12 2015 UTC

FileTypes Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: 0f2d42f550f49cc011f413cdc67fdf312c7c8ab5
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:45:12 2015 UTC

DataTranslation Preflet - and addons - colors

----------------------------------------------------------------------------

############################################################################

Commit: 05f4e9fb3d1921f792c1e2db71230f915741d3a1
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:45:42 2015 UTC

Bluetooth Preflet colors

----------------------------------------------------------------------------

############################################################################

Commit: 2a3987593b84524991f8e372fb073865cb6c21a7
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:45:56 2015 UTC

Appearance BColorMap

Use BColorMap, use new color system.

----------------------------------------------------------------------------

############################################################################

Commit: fe9927f85300c3dde0209cb95c787463d7d03899
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:46:55 2015 UTC

Print System Colors

----------------------------------------------------------------------------

############################################################################

Commit: 08021effa94bc5c63f364253ee7d9af7ddbb7a96
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:47:24 2015 UTC

Tracker uses new API, Improved Font Awareness

InfoWindow now uses the font size to determine the window size and
placement of elements. Also uses syste colors, including link
colors. Permissions view not font sensitive at this time.

----------------------------------------------------------------------------

############################################################################

Commit: acd5ad65390c3af9ad469a89bfc8b641fc9e0b03
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:49:43 2015 UTC

Mail kit colors

----------------------------------------------------------------------------

############################################################################

Commit: 8888dced59913d914437ff63f0e05a2d9997a1d7
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:50:40 2015 UTC

ToolBar Colors

This was a bigger change than many others as BButton now defaults to using
control background colors, and we can not do that here without the buttons
not appearing as we desire (blending in with the toolbar).

Using the control background color for the toolbar would be unacceptable.

----------------------------------------------------------------------------

############################################################################

Commit: 1540effa2cf455f74565ae74c65cf58260bb2c99
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:52:55 2015 UTC

Shared UI element colors

----------------------------------------------------------------------------

############################################################################

Commit: 41e8c23ff34f341d5680872ca849931ed815a354
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:53:23 2015 UTC

Bluetooth Incoming Connection colors

----------------------------------------------------------------------------

############################################################################

Commit: 8ed5f1e83d1b0510f6836f27109e867d0c34125f
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:54:34 2015 UTC

/bin colors

----------------------------------------------------------------------------

############################################################################

Commit: 091c4f2f8577f017fbee192545f441ba6f8412a8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:55:04 2015 UTC

WebPositive Colors

Use system colors, ensure that we don't rely on view having a default
white background when using the layout API (DownloadProgressView)

----------------------------------------------------------------------------

############################################################################

Commit: 5a4b32ca19a90521f9ae46fb95b49835f710cd45
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:55:56 2015 UTC

Terminal colors

When resizing a window, we need to ensure the low color and the view color are
the same,
otherwise the drawing results will be unpleasant.

Here, I decided to use the user Terminal colors rather than a system color.

----------------------------------------------------------------------------

############################################################################

Commit: 92fdcd67371efef19cc48d99046ccc5fa860e97d
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:57:16 2015 UTC

Switcher colors

----------------------------------------------------------------------------

############################################################################

Commit: 3ea03f09fcc99711d87c8a3d66ffdb7d76fe7bcc
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:57:34 2015 UTC

Sudoku colors

----------------------------------------------------------------------------

############################################################################

Commit: 7dbc094008e588ad54c67c29df0f257d376118c6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:58:03 2015 UTC

StyledEdit colors

----------------------------------------------------------------------------

############################################################################

Commit: 001d1ff2cf2f336ffcdccdd0032ce68f485da49a
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:58:28 2015 UTC

SoundRecorder colors

I lack the hardware to fully adapt this program at this time.

----------------------------------------------------------------------------

############################################################################

Commit: 5a287a03ac3b6730ecadee21d141e6b7e77b44ab
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:59:04 2015 UTC

ShowImage colors

----------------------------------------------------------------------------

############################################################################

Commit: 0cacaf9fab51935ea9964f84a0b5f80d0b10fb8e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:59:26 2015 UTC

Screenshot window colors

----------------------------------------------------------------------------

############################################################################

Commit: 3ac4c0ef49cfe09b36c8554ec43f0b612d8c114f
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:59:41 2015 UTC

resedit colors

----------------------------------------------------------------------------

############################################################################

Commit: 07f62036a77e5416225d5d9f3f3a86063b4167f6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:59:52 2015 UTC

Pulse colors

----------------------------------------------------------------------------

############################################################################

Commit: 18877fcfc4090fa2058bc87a3687210e360e7196
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:00:24 2015 UTC

ProcessController colors

----------------------------------------------------------------------------

############################################################################

Commit: a3b240a0ce04567c99a9599a97acd2119b997709
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:00:53 2015 UTC

PowerStatus colors

----------------------------------------------------------------------------

############################################################################

Commit: 0c9dcb009c45961b0b303a86f5d9781696781161
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:01:05 2015 UTC

PatchBay Colors

----------------------------------------------------------------------------

############################################################################

Commit: 958584680ed8af88dd8e7cdd547195b1115edd56
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:01:18 2015 UTC

Pairs colors

----------------------------------------------------------------------------

############################################################################

Commit: 8c6c6f8ea3654bc11c1822c75d5b9e58b1584165
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:01:28 2015 UTC

PackageInstaller colors

----------------------------------------------------------------------------

############################################################################

Commit: c5edaac58cd85e26b67cb309271c212fbc17ded6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:01:43 2015 UTC

OverlayImage app colors

----------------------------------------------------------------------------

############################################################################

Commit: bab541c8edc5b2dc39008e9d6c059320d90f5bc4
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:01:58 2015 UTC

Network Status Colors

----------------------------------------------------------------------------

############################################################################

Commit: fd465dcd219bbae1073340e96699d6af486c8fd0
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:02:10 2015 UTC

MediaPlayer colors

----------------------------------------------------------------------------

############################################################################

Commit: 61e49c4ca67a9942f6df6c8d327367b733c5a278
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:02:28 2015 UTC

Mail application colors

----------------------------------------------------------------------------

############################################################################

Commit: 358e16ba54d2e55e6b16f8c3fff23ac36332994e
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:02:41 2015 UTC

Magnify app colors

----------------------------------------------------------------------------

############################################################################

Commit: e1d96a566d68b2648866deb40e5864daa737cc32
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:02:53 2015 UTC

Login UI rework

Improve placement with different font sizes, and use user colors.

----------------------------------------------------------------------------

############################################################################

Commit: b8f864d427ba372af1c8ffc7284d89d4bca025e5
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:03:45 2015 UTC

Install colors

Also better placement of text when official logo is absent.

----------------------------------------------------------------------------

############################################################################

Commit: cbf3d0e18a06cea456b1b99263c01f2fe9f43560
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:04:20 2015 UTC

Uninstaller colors

----------------------------------------------------------------------------

############################################################################

Commit: 1ccc0e09b1db80dc20aaa41eff4030a1ba521e48
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:04:32 2015 UTC

Icon-o-Matic colors

----------------------------------------------------------------------------

############################################################################

Commit: 0fed63d9229865d35f78acebb71f2d75b2a00e81
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:04:47 2015 UTC

HaikuDepot colors

This application proved the most difficult to get to use system colors.
It uses a specialized text handling system that does not expose the
ability to change text or background colors at any point.

After discussing at length with the original author it was discovered
that the system is not working as originally intended and fixing it is
beyond the scope of this commit. As such, I added the ability for this
system to use color defined constants so that it can update with system
color changes. I also removed its use from the package list view, as
there was no way to override the color choices to make the MarkupTextView
fit in properly with list colors. This, however, is a non issue as BTextView
has every needed capability for the short description.

In addition to using system colors and live updates, I took it upon myself
to improve the legibility of the user ratings view. A faint line now separates
each rating, and the rating bars use the control mark color so that they stand
out as something other than a drawing error (which is what I thought it was for
a long time).

----------------------------------------------------------------------------

############################################################################

Commit: c52709dbc6bb3d1fb830ab0e4772c820d2b1645c
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:10:30 2015 UTC

FontDemo colors

----------------------------------------------------------------------------

############################################################################

Commit: 681f189c26c6461decedfd0308eabb8f294789da
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:10:41 2015 UTC

FirstBootPrompt colors and size

Intelligently use font size to set the window size.

----------------------------------------------------------------------------

############################################################################

Commit: 680b6ca4d034b53477b591977d254bcc4dbe92c6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:12:32 2015 UTC

Expander colors

----------------------------------------------------------------------------

############################################################################

Commit: 172c02727555a7539bcb5854e5c9896053cc87a3
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:12:45 2015 UTC

DriveSetup colors

----------------------------------------------------------------------------

############################################################################

Commit: 861dc3bb5096c9bb01f28da688c0e52e3625098f
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:12:58 2015 UTC

DiskProbe colors

----------------------------------------------------------------------------

############################################################################

Commit: 8d09fbabb3bd11beb78d5f14c28cd63d37e4ca42
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:13:15 2015 UTC

Device app colors

----------------------------------------------------------------------------

############################################################################

Commit: 415b006207bc88b400fd1d7b7e57d79c88fcfdef
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:13:29 2015 UTC

Deskbar colors

----------------------------------------------------------------------------

############################################################################

Commit: 99528c2ec9bac5a665a1568f63557fda8bfc8ed8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:13:45 2015 UTC

DeskCalc colors

Due to the button color logic, we use the rgb_color Brightness to determine
the label colors.

----------------------------------------------------------------------------

############################################################################

Commit: 03b65ec81ab86c12bf1cb259092a1e98e6eabf54
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:14:26 2015 UTC

Debugger colors

----------------------------------------------------------------------------

############################################################################

Commit: a492a5b619c706ec258ec07920248c556a0cfcfa
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:14:42 2015 UTC

CharacterMap colors

----------------------------------------------------------------------------

############################################################################

Commit: 8bab082e0dcb2739bffa707d1723bc071919a29b
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:14:57 2015 UTC

BootManager colors, size

Use system colors, intelligently size window according to the font size.

----------------------------------------------------------------------------

############################################################################

Commit: eafdbb84280bffda103ec8e82535aa387b2459bc
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:15:35 2015 UTC

ActivityMonitor colors

----------------------------------------------------------------------------

############################################################################

Commit: f5520379bc6fdb0a0fdb90e3fb1cad39951f4564
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:15:53 2015 UTC

AboutSystem colors

Use slightly different colors for heading text than for subheading text.
Change uptime view from a BTextView to a BStringView. This fixes the issue
where the AboutWindow did not properly fit its contents.

----------------------------------------------------------------------------

############################################################################

Commit: 6ead3040270776e88b0ff9ccb428f20d09b9cc93
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:17:17 2015 UTC

ScreenSaver add-on prefefernce view colors

----------------------------------------------------------------------------

############################################################################

Commit: db8513bbfc1fca0b29a45d7a5c6afe1266a270d7
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:17:39 2015 UTC

Print server add-ons' colors

----------------------------------------------------------------------------

############################################################################

Commit: dcfef315876e378c0ab647b47082df7bdd317d48
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:18:06 2015 UTC

Mail daemon addon colors

----------------------------------------------------------------------------

############################################################################

Commit: 953143816f5575446cd2e78001cd3d1314144336
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:18:25 2015 UTC

TeamMonitorWindow colors

----------------------------------------------------------------------------


Other related posts: