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

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 17 Nov 2015 20:17:12 +0100 (CET)

added 92 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: 44553178f2c1174ddab320123f836c6732252160
new head: f3f3ae3aa9d72e7aa947db8e67f38ec9425e6c9a
overview: https://github.com/looncraz/haiku/compare/44553178f2c1...f3f3ae3aa9d7

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

752a9370e317: Merge https://github.com/haiku/haiku

6fe5d2039b23: 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.

00a6d4859e6e: Cleanup MessageLooper.h

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

da52e696b72e: 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.

23b40faff242: 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.

d2360f8f6bad: LinkReceiver Fix

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

494fa3397281: B_FOLLOW_DEFAULT

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

384d4d4d4b0a: ControlLook Colors

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

747b36720617: ColumnListView colors

ColumnListView now responds to system color changes.

ba28aadb39e5: Private Headers B_FOLLOW_DEFAULT

e01af5ce724b: 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.

b86b0ba70ac4: BAboutWindow colors

fcdc6092fbf3: BAlert colors

656cae692a45: BBox colors

ef55340560d0: BButton colors

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

9b4f08d76c8f: BControl colors

This includes simple changes to common controls.

5ee40ba97efd: AbstractSpinner colors

22575951426e: Menu colors

4633b0b979c3: BListView colors

7273c42bcca0: BTabView colors

5ccc7fd2b094: Specialized Layout Views colors

Views used by layout.

f94b0fb8490f: Colors

808c2b930bb8: ToolTip colors

726ea1b331fc: Chart colors and some font awareness

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

ac9e0908c9a6: Tests color changes

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

cd65d7d2503d: Mail Deskbar Replicant colors

3d73786866a9: Bluetooth Deskbar Replicant colors

4509c0d2f63b: Server UI colors

Iterative changes, mostly.

ce4ea5ecf75b: Time Preflet colors

e893e8c1a081: Screensaver preflet colors

c79468cd169e: Screen Preflet colors

3fe284e5dd9a: Network Preflet Colors

d69fc1487d7a: Mouse Preflet Colors

f12c1e4c6cde: Media System Colors

Preflet, replicant, and DefaultMediaTheme

8c19e2391474: Mail Preflet Colors

748a44f7fe34: Locale Preflet Colors

283129673603: Keymap colors

541ede0d036d: Joysticks Preflet colors

d0093f799c14: Font Preflet colors

7714ca522caf: FileTypes Preflet colors

7fa25a379b90: DataTranslation Preflet - and addons - colors

48d2832e1f77: Bluetooth Preflet colors

4f46fdd6904a: Appearance BColorMap

Use BColorMap, use new color system.

ad4789239bf5: Print System Colors

28d661fd7eec: 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.

5cca3779e52f: Mail kit colors

c3e1153a4b2a: 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.

092526d82a5a: Shared UI element colors

de4642fa585d: Bluetooth Incoming Connection colors

d992756aa5b2: /bin colors

d38fd020049d: WebPositive Colors

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

0a6f6f28a57b: 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.

aed839dfad13: Switcher colors

20229a2d2104: Sudoku colors

539c0d9cf16f: StyledEdit colors

efc3daaa0c85: SoundRecorder colors

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

f8f67c5a90a2: ShowImage colors

c7640d9f7637: Screenshot window colors

e537e8e42a75: resedit colors

2f1f9fa3d1bb: Pulse colors

be1d27bab553: ProcessController colors

3c83647271a4: PowerStatus colors

a63736dd2671: PatchBay Colors

969513540952: Pairs colors

a66a33a09854: PackageInstaller colors

ed67f51690a2: OverlayImage app colors

04ea123866fe: Network Status Colors

f09496c3a223: MediaPlayer colors

e05fd4f929d1: Mail application colors

80f5afaba512: Magnify app colors

b92719f52b1e: Login UI rework

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

d4a6e7eea2aa: Install colors

Also better placement of text when official logo is absent.

c9a3f25ebe7e: Uninstaller colors

44e52e1230c1: Icon-o-Matic colors

f5d99ca753ed: 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).

4fafb47d2ec1: FontDemo colors

bba613c867ea: FirstBootPrompt colors and size

Intelligently use font size to set the window size.

94b4732bef70: Expander colors

f7abf8d4105f: DriveSetup colors

c21d1c0f1dee: DiskProbe colors

314eb7dbdd03: Device app colors

3c9db22431ea: Deskbar colors

9fd3a9ab688a: DeskCalc colors

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

ab1161feb4f1: Debugger colors

95a02f4c116b: CharacterMap colors

5580814213b5: BootManager colors, size

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

8700a75fbf3b: ActivityMonitor colors

02e93fa4a0e6: 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.

44fc4d29969e: ScreenSaver add-on prefefernce view colors

5b75313b50fd: Print server add-ons' colors

a589f4847445: Mail daemon addon colors

f3f3ae3aa9d7: TeamMonitorWindow colors

[ looncraz <looncraz@xxxxxxxxxxxx> ]

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

421 files changed, 13259 insertions(+), 2189 deletions(-)
3rdparty/pulkomandy/unbootstrap.sh | 0
LICENSE | 5715 ++++++++++++++++++
build/jam/packages/Haiku | 5 +-
build/jam/repositories/HaikuPorts/x86_gcc2 | 90 +-
.../inbound_filters/notifier/ro.catkeys | 26 +-
data/catalogs/apps/diskusage/ro.catkeys | 3 +-
data/catalogs/apps/webpositive/ro.catkeys | 3 +-
docs/user/interface/View.dox | 189 +-
docs/user/interface/Window.dox | 18 +-
headers/cpp/std/bastring.h | 2 +
headers/os/app/AppDefs.h | 73 +-
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/os/translation/TranslatorRoster.h | 15 +-
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/ShapePrivate.h | 40 +-
headers/private/interface/ViewPrivate.h | 14 +-
headers/private/shared/CalendarView.h | 3 +-
.../devices/keyboard/TeamMonitorWindow.cpp | 6 +-
src/add-ons/kernel/busses/usb/xhci.cpp | 10 +
.../inbound_filters/match_header/ConfigView.cpp | 2 +-
.../notifier/NotifierConfigView.cpp | 2 +-
.../spam_filter/SpamFilterConfig.cpp | 2 +-
.../outbound_filters/fortune/ConfigView.cpp | 2 +-
.../media/plugins/ffmpeg/AVCodecDecoder.cpp | 14 +
src/add-ons/media/plugins/ffmpeg/Utilities.h | 10 +-
.../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/aboutsystem/Credits.h | 1 +
src/apps/activitymonitor/ActivityView.cpp | 9 +-
src/apps/activitymonitor/ActivityWindow.cpp | 3 +-
src/apps/activitymonitor/SettingsWindow.cpp | 1 +
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 +-
.../value/value_nodes/BMessageValueNode.cpp | 3 +-
src/apps/deskbar/BarMenuBar.cpp | 2 +-
src/apps/deskbar/BarMenuTitle.cpp | 2 +-
[ *** stats truncated: 322 lines dropped *** ]

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

Commit: 752a9370e31711823a6f55cfb4061da144d2ba84
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Tue Nov 17 18:51:32 2015 UTC

Merge https://github.com/haiku/haiku

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

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

Commit: 6fe5d2039b23bcd87fa524600b83ed2b6d4c575e
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 9090086..c1a9cbc 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"
@@ -69,6 +70,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 7c96133..5a3d81a 100644
--- a/src/servers/app/Jamfile
+++ b/src/servers/app/Jamfile
@@ -56,6 +56,9 @@ Server app_server :
CursorData.cpp
CursorManager.cpp
CursorSet.cpp
+ DelayedMessage.cpp
+ DelayedMessagePrivate.cpp
+ DelayedMessageSender.cpp
Desktop.cpp
DesktopListener.cpp
DesktopSettings.cpp

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

Commit: 00a6d4859e6e651af5beb3200f89f04a9d9bf1db
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: da52e696b72e15e2adadf408153bbc61ad8cbe2e
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: 23b40faff242ae2427af6a0230fe8485c69be4bc
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: 3263 lines dropped *** ]


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

Commit: d2360f8f6bad30cc72a0526b427dc75fd2dc943a
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: 494fa33972818c8404dee51de22d9ca2ead9367f
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: 384d4d4d4b0a832ab37027e965d0e3a190d956fe
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: 747b367206175b8349ed24bea00971a073522b8c
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:13:15 2015 UTC

ColumnListView colors

ColumnListView now responds to system color changes.

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

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

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

Private Headers B_FOLLOW_DEFAULT

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

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

Commit: e01af5ce724b5d24e0abca2b2139fd0b6f636dc8
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: b86b0ba70ac4873173f68cffc959b2d7d0c2cd85
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:18:51 2015 UTC

BAboutWindow colors

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

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

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

BAlert colors

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

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

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

BBox colors

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

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

Commit: ef55340560d0a0d19ee7527a98920dee0bb30fa5
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: 9b4f08d76c8f7ec6b613de09ad771208202add00
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:23:44 2015 UTC

BControl colors

This includes simple changes to common controls.

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

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

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

AbstractSpinner colors

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

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

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

Menu colors

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

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

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

BListView colors

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

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

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

BTabView colors

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

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

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

Specialized Layout Views colors

Views used by layout.

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

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

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

Colors

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

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

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

ToolTip colors

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

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

Commit: 726ea1b331fc68145a97648dda73bfee002d3d80
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: ac9e0908c9a63559bce53bcc60a14b21ebce2687
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: cd65d7d2503dd9f6a042ea7360e1e7ea620057a8
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:37:21 2015 UTC

Mail Deskbar Replicant colors

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

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

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

Bluetooth Deskbar Replicant colors

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

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

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

Server UI colors

Iterative changes, mostly.

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

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

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

Time Preflet colors

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

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

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

Screensaver preflet colors

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

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

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

Screen Preflet colors

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

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

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

Network Preflet Colors

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

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

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

Mouse Preflet Colors

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

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

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

Media System Colors

Preflet, replicant, and DefaultMediaTheme

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

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

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

Mail Preflet Colors

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

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

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

Locale Preflet Colors

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

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

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

Keymap colors

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

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

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

Joysticks Preflet colors

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

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

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

Font Preflet colors

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

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

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

FileTypes Preflet colors

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

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

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

DataTranslation Preflet - and addons - colors

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

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

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

Bluetooth Preflet colors

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

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

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

Appearance BColorMap

Use BColorMap, use new color system.

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

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

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

Print System Colors

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

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

Commit: 28d661fd7eec9b2f34aaae33346a0d7c43993e9b
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: 5cca3779e52f72295624901cc63a2dc5f8675b4a
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:49:43 2015 UTC

Mail kit colors

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

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

Commit: c3e1153a4b2aa3ea85eb60753b4800c01e3f0e34
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: 092526d82a5adc723d08da902c444b8a2140291f
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:52:55 2015 UTC

Shared UI element colors

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

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

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

Bluetooth Incoming Connection colors

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

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

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

/bin colors

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

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

Commit: d38fd020049d2c25eccd665abd457f7ca261a3c5
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: 0a6f6f28a57b39b5622a220dcca87f4812d5c938
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: aed839dfad13f88ef78aab839234fb06ccba0805
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:57:16 2015 UTC

Switcher colors

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

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

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

Sudoku colors

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

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

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

StyledEdit colors

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

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

Commit: efc3daaa0c858b48425277ada828c7a77b9bd3a5
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: f8f67c5a90a2d471a3ac154455551204dcab6f98
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 05:59:04 2015 UTC

ShowImage colors

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

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

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

Screenshot window colors

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

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

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

resedit colors

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

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

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

Pulse colors

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

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

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

ProcessController colors

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

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

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

PowerStatus colors

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

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

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

PatchBay Colors

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

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

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

Pairs colors

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

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

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

PackageInstaller colors

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

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

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

OverlayImage app colors

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

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

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

Network Status Colors

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

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

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

MediaPlayer colors

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

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

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

Mail application colors

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

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

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

Magnify app colors

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

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

Commit: b92719f52b1ea43237a01810426beeee655e0dec
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: d4a6e7eea2aa7a4bce0d0f03180e803ab5c4f559
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: c9a3f25ebe7e615d8f0b3c7dbe5958c8cdec985f
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:04:20 2015 UTC

Uninstaller colors

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

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

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

Icon-o-Matic colors

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

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

Commit: f5d99ca753edcc93a251a6fe2db689da584bee8c
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: 4fafb47d2ec109777d99b040b205342fa9071823
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:10:30 2015 UTC

FontDemo colors

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

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

Commit: bba613c867ea82952ff8404396b84af86d93771a
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: 94b4732bef70fb4446f0ee682932f4ec30e64f50
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:12:32 2015 UTC

Expander colors

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

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

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

DriveSetup colors

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

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

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

DiskProbe colors

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

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

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

Device app colors

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

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

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

Deskbar colors

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

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

Commit: 9fd3a9ab688aa4040139e67651d09d7eda6d7b4c
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: ab1161feb4f17a672040def88d5cc3f8b8376a3c
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:14:26 2015 UTC

Debugger colors

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

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

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

CharacterMap colors

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

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

Commit: 5580814213b53cabc26d390ff446fcb4a45d8a2a
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: 8700a75fbf3bc007e761263ccf90086be381ecd6
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:15:35 2015 UTC

ActivityMonitor colors

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

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

Commit: 02e93fa4a0e63b36ad7f2dc9f776168591bb0024
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: 44fc4d29969e0068d1b1b47978779d29f33e9f8d
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Wed Nov 11 06:17:17 2015 UTC

ScreenSaver add-on prefefernce view colors

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

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

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

Print server add-ons' colors

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

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

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

Mail daemon addon colors

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

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

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

TeamMonitorWindow colors

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


Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.setviewuicolor [f3f3ae3aa9d7] in src: apps servers/app kits/interface preferences kits - looncraz-github . setviewuicolor