hrev43935 adds 14 changesets to branch 'master' old head: 94cefc8f79e0e2baad06f28a004efbbec8c5eb55 new head: 91b523054febe7c9bea327e9596e8da5ff94f20e ---------------------------------------------------------------------------- cbdd108: In NotificationWindow, delete AppGroupViews when closed. This is preferable to having them kick around for as long as the server is running. They don't yet close when all of the notifications for the view time out, that's coming next. 80f96f7: In NotificationWindow, have AppGroupViews get deleted upon expiry. I.e. once there are no more notifications in the AppGroupView, we get the NotificationWindow to delete it. As a result of this change, we no longer need the AppGroupView.cpp _ResizeViews() method. 8090bd4: Add a TODO about a possible use after free bug. 002fd62: Fix NotificationWindow's collapsing bug. (#8288) When a BTwoDimensionalLayout has no visible elements, it has a max size of B_SIZE_UNLIMITED in both dimensions. In this case, we want it to shrink down to just the insets. fd3e582: Fix bug in NotificationWindow where the window would be double hidden. Also simplify and rename _ResizeAll(), now that AppGroupViews remove themselves. 617ee9e: be_control_look is never NULL, so we don't need backup drawing code. 259ffc0: Style cleanup in notification_server: #includes 710eb74: Clean up use of SetPosition(). This fixes a bug where an empty white window would appear when changing workspaces if there were no notifications. d19e651: Expand click rects when checking for close/collapse clicks. ac93328: Have NotificationWindow enforce the window size setting. 2fab0e4: Remove dead code in NotificationView.cpp c2fbfb1: Don't hardcode the NotificationView width to 300px. 3c7caf8: Fix a bug that caused some NotificationViews to be double-shown. This bug affected views added while the window was hidden, and would result in that view not being hidden when the group was collapsed for the first time. 91b5230: Resolve TODO about possible use after free bug. [ Alex Wilson <yourpalal2@xxxxxxxxx> ] ---------------------------------------------------------------------------- 7 files changed, 123 insertions(+), 201 deletions(-) src/servers/notification/AppGroupView.cpp | 153 +++++-------------- src/servers/notification/AppGroupView.h | 4 +- src/servers/notification/NotificationServer.cpp | 1 + src/servers/notification/NotificationView.cpp | 53 ++----- src/servers/notification/NotificationView.h | 12 +- src/servers/notification/NotificationWindow.cpp | 81 ++++++----- src/servers/notification/NotificationWindow.h | 20 ++- ############################################################################ Commit: cbdd108a09ab47c523a6debd679eddbe35d1b15c URL: http://cgit.haiku-os.org/haiku/commit/?id=cbdd108 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sat Jan 14 21:12:35 2012 UTC In NotificationWindow, delete AppGroupViews when closed. This is preferable to having them kick around for as long as the server is running. They don't yet close when all of the notifications for the view time out, that's coming next. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 5779b59..5029808 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -156,10 +156,7 @@ AppGroupView::Draw(BRect updateRect) void AppGroupView::MouseDown(BPoint point) { - bool changed = false; if (fCloseRect.Contains(point)) { - changed = true; - int32 children = fInfo.size(); for (int32 i = 0; i < children; i++) { GetLayout()->RemoveView(fInfo[i]); @@ -169,7 +166,7 @@ AppGroupView::MouseDown(BPoint point) fInfo.clear(); // Remove ourselves from the parent view - BMessage message(kRemoveView); + BMessage message(kRemoveGroupView); message.AddPointer("view", this); fParent->PostMessage(&message); } @@ -188,17 +185,10 @@ AppGroupView::MouseDown(BPoint point) fInfo[i]->Show(); } } - changed = true; - Invalidate(); // Need to redraw the collapse indicator and title - BMessage message(kRemoveView); - // Do not actually remive anything, but update size - fParent->PostMessage(&message); + Invalidate(); // Need to redraw the collapse indicator and title } - if (changed) { - _ResizeViews(); - } } @@ -266,6 +256,13 @@ AppGroupView::AddInfo(NotificationView* view) } +const BString& +AppGroupView::Group() const +{ + return fLabel; +} + + void AppGroupView::_ResizeViews() { diff --git a/src/servers/notification/AppGroupView.h b/src/servers/notification/AppGroupView.h index 551bc4f..deb9d09 100644 --- a/src/servers/notification/AppGroupView.h +++ b/src/servers/notification/AppGroupView.h @@ -32,6 +32,8 @@ public: void AddInfo(NotificationView* view); + const BString& Group() const; + private: void _ResizeViews(); diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 690ef93..e37e735 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -10,8 +10,6 @@ * Mikael Eiman, mikael@xxxxxxxx * Pier Luigi Fiorini, pierluigi.fiorini@xxxxxxxxx */ - - #include "NotificationWindow.h" #include <algorithm> @@ -21,7 +19,6 @@ #include <Catalog.h> #include <File.h> #include <GroupLayout.h> -#include <GroupLayoutBuilder.h> #include <Layout.h> #include <NodeMonitor.h> #include <Path.h> @@ -31,6 +28,7 @@ #include "AppGroupView.h" #include "AppUsage.h" + #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "NotificationWindow" @@ -216,6 +214,29 @@ NotificationWindow::MessageReceived(BMessage* message) _ResizeAll(); break; } + case kRemoveGroupView: + { + AppGroupView* view = NULL; + if (message->FindPointer("view", (void**)&view) != B_OK) + return; + + // It's possible that between sending this message, and us receiving + // it, the view has become used again, in which case we shouldn't + // delete it. + if (view->HasChildren()) + return; + + // this shouldn't happen + if (fAppViews.erase(view->Group()) < 1) + break; + + if (GetLayout()->RemoveView(view)) + delete view; + + if (fAppViews.size() == 0) + Hide(); + break; + } default: BWindow::MessageReceived(message); } diff --git a/src/servers/notification/NotificationWindow.h b/src/servers/notification/NotificationWindow.h index 41fc457..b55adf8 100644 --- a/src/servers/notification/NotificationWindow.h +++ b/src/servers/notification/NotificationWindow.h @@ -37,6 +37,9 @@ extern const float kCloseSize; extern const float kExpandSize; extern const float kPenSize; +const uint32 kRemoveGroupView = 'RGVi'; + + class NotificationWindow : public BWindow { public: NotificationWindow(); ############################################################################ Commit: 80f96f761c949c24266a8f96d5e7d8ba83cb69eb URL: http://cgit.haiku-os.org/haiku/commit/?id=80f96f7 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sat Jan 14 21:31:02 2012 UTC In NotificationWindow, have AppGroupViews get deleted upon expiry. I.e. once there are no more notifications in the AppGroupView, we get the NotificationWindow to delete it. As a result of this change, we no longer need the AppGroupView.cpp _ResizeViews() method. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 5029808..e1f36da 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -203,17 +203,22 @@ AppGroupView::MessageReceived(BMessage* msg) return; infoview_t::iterator vIt = find(fInfo.begin(), fInfo.end(), view); + if (vIt == fInfo.end()) + break; - if (vIt != fInfo.end()) { - fInfo.erase(vIt); - GetLayout()->RemoveView(view); - delete view; - } + fInfo.erase(vIt); + GetLayout()->RemoveView(view); + delete view; - _ResizeViews(); + fParent->PostMessage(msg); - if (Window() != NULL) - Window()->PostMessage(msg); + if (!this->HasChildren()) { + Hide(); + BMessage removeSelfMessage(kRemoveGroupView); + removeSelfMessage.AddPointer("view", this); + fParent->PostMessage(&removeSelfMessage); + } + break; } default: @@ -263,28 +268,6 @@ AppGroupView::Group() const } -void -AppGroupView::_ResizeViews() -{ - int32 children = fInfo.size(); - - if (!fCollapsed) { - for (int32 i = 0; i < children; i++) { - if (fInfo[i]->IsHidden()) - fInfo[i]->Show(); - } - } else { - for (int32 i = 0; i < children; i++) - if (!fInfo[i]->IsHidden()) - fInfo[i]->Hide(); - } - - if (!IsHidden() && !HasChildren()) - Hide(); - fParent->Layout(true); -} - - bool AppGroupView::HasChildren() { diff --git a/src/servers/notification/AppGroupView.h b/src/servers/notification/AppGroupView.h index deb9d09..0c1406d 100644 --- a/src/servers/notification/AppGroupView.h +++ b/src/servers/notification/AppGroupView.h @@ -35,8 +35,6 @@ public: const BString& Group() const; private: - void _ResizeViews(); - BString fLabel; NotificationWindow* fParent; infoview_t fInfo; ############################################################################ Commit: 8090bd4a30aa3845a5a7bdc378feadb8f6de3256 URL: http://cgit.haiku-os.org/haiku/commit/?id=8090bd4 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sat Jan 14 21:42:00 2012 UTC Add a TODO about a possible use after free bug. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index e1f36da..444e406 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -238,6 +238,9 @@ AppGroupView::AddInfo(NotificationView* view) for (int32 i = 0; i < children; i++) { if (id == fInfo[i]->MessageID()) { + // TODO: because NotificationWindow also tracks these + // views, we may be heading towards a use-after-free with + // this code. GetLayout()->RemoveView(fInfo[i]); delete fInfo[i]; ############################################################################ Commit: 002fd626d6f0be3261121d320ef8a411af389797 URL: http://cgit.haiku-os.org/haiku/commit/?id=002fd62 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sun Jan 15 12:25:57 2012 UTC Ticket: https://dev.haiku-os.org/ticket/8288 Fix NotificationWindow's collapsing bug. (#8288) When a BTwoDimensionalLayout has no visible elements, it has a max size of B_SIZE_UNLIMITED in both dimensions. In this case, we want it to shrink down to just the insets. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 444e406..bb67f2e 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -169,9 +169,7 @@ AppGroupView::MouseDown(BPoint point) BMessage message(kRemoveGroupView); message.AddPointer("view", this); fParent->PostMessage(&message); - } - - if (fCollapseRect.Contains(point)) { + } else if (fCollapseRect.Contains(point)) { fCollapsed = !fCollapsed; int32 children = fInfo.size(); if (fCollapsed) { @@ -179,16 +177,18 @@ AppGroupView::MouseDown(BPoint point) if (!fInfo[i]->IsHidden()) fInfo[i]->Hide(); } + GetLayout()->SetExplicitMaxSize(GetLayout()->MinSize()); } else { for (int32 i = 0; i < children; i++) { if (fInfo[i]->IsHidden()) fInfo[i]->Show(); } + GetLayout()->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNSET)); } + InvalidateLayout(); Invalidate(); // Need to redraw the collapse indicator and title } - } ############################################################################ Commit: fd3e5821893498a2833597c412377553b732a194 URL: http://cgit.haiku-os.org/haiku/commit/?id=fd3e582 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sat Jan 21 02:38:55 2012 UTC Fix bug in NotificationWindow where the window would be double hidden. Also simplify and rename _ResizeAll(), now that AppGroupViews remove themselves. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index e37e735..c4e39c2 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -98,7 +98,7 @@ NotificationWindow::WorkspaceActivated(int32 /*workspace*/, bool active) { // Ensure window is in the correct position if (active) - _ResizeAll(); + _ShowHide(); } @@ -187,7 +187,7 @@ NotificationWindow::MessageReceived(BMessage* message) group->AddInfo(view); - _ResizeAll(); + _ShowHide(); reply.AddInt32("error", B_OK); } else @@ -210,8 +210,6 @@ NotificationWindow::MessageReceived(BMessage* message) if (it != fViews.end()) fViews.erase(it); - - _ResizeAll(); break; } case kRemoveGroupView: @@ -233,8 +231,7 @@ NotificationWindow::MessageReceived(BMessage* message) if (GetLayout()->RemoveView(view)) delete view; - if (fAppViews.size() == 0) - Hide(); + _ShowHide(); break; } default: @@ -311,39 +308,14 @@ NotificationWindow::Width() void -NotificationWindow::_ResizeAll() +NotificationWindow::_ShowHide() { - appview_t::iterator aIt; - bool shouldHide = true; - - for (aIt = fAppViews.begin(); aIt != fAppViews.end(); aIt++) { - AppGroupView* app = aIt->second; - if (app->HasChildren()) { - shouldHide = false; - break; - } - } - - if (shouldHide) { - if (!IsHidden()) - Hide(); + if (fAppViews.empty() && !IsHidden()) { + Hide(); return; } - for (aIt = fAppViews.begin(); aIt != fAppViews.end(); aIt++) { - AppGroupView* view = aIt->second; - - if (!view->HasChildren()) { - if (!view->IsHidden()) - view->Hide(); - } else { - if (view->IsHidden()) - view->Show(); - } - } - SetPosition(); - if (IsHidden()) Show(); } diff --git a/src/servers/notification/NotificationWindow.h b/src/servers/notification/NotificationWindow.h index b55adf8..84cb81b 100644 --- a/src/servers/notification/NotificationWindow.h +++ b/src/servers/notification/NotificationWindow.h @@ -55,7 +55,7 @@ public: int32 Timeout(); float Width(); - void _ResizeAll(); + void _ShowHide(); private: friend class AppGroupView; ############################################################################ Commit: 617ee9eef69de6339660ce1faef5e6367dfa40df URL: http://cgit.haiku-os.org/haiku/commit/?id=617ee9e Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Wed Feb 22 22:15:14 2012 UTC be_control_look is never NULL, so we don't need backup drawing code. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index bb67f2e..53e085e 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -49,23 +49,14 @@ AppGroupView::Draw(BRect updateRect) bounds.bottom = bounds.top + kHeaderSize; // Draw the header background - if (be_control_look != NULL) { - SetHighColor(tint_color(menuColor, 1.22)); - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); - uint32 borders = BControlLook::B_TOP_BORDER - | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; - - be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, - 0, borders); - } else { - SetHighColor(vlight); - StrokeLine(bounds.LeftTop(), bounds.RightTop()); - StrokeLine(BPoint(bounds.left, bounds.top + 1), bounds.LeftBottom()); - SetHighColor(hilite); - StrokeLine(BPoint(bounds.left + 1, bounds.bottom), - bounds.RightBottom()); - } + SetHighColor(tint_color(menuColor, 1.22)); + SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + StrokeLine(bounds.LeftTop(), bounds.LeftBottom()); + uint32 borders = BControlLook::B_TOP_BORDER + | BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER; + + be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor, + 0, borders); // Draw the buttons fCollapseRect.top = (kHeaderSize - kExpandSize) / 2; @@ -79,54 +70,10 @@ AppGroupView::Draw(BRect updateRect) fCloseRect.left = fCloseRect.right - kCloseSize; fCloseRect.bottom = fCloseRect.top + kCloseSize; - if (be_control_look != NULL) { - uint32 arrowDirection = fCollapsed - ? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW; - be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect, - LowColor(), arrowDirection, 0, B_DARKEN_3_TINT); - } else { - rgb_color outlineColor = {80, 80, 80, 255}; - rgb_color middleColor = {200, 200, 200, 255}; - - SetDrawingMode(B_OP_OVER); - - if (fCollapsed) { - BeginLineArray(6); - - AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 1), - BPoint(fCollapseRect.left + 3, fCollapseRect.bottom - 1), outlineColor); - AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 1), - BPoint(fCollapseRect.left + 7, fCollapseRect.top + 5), outlineColor); - AddLine(BPoint(fCollapseRect.left + 7, fCollapseRect.top + 5), - BPoint(fCollapseRect.left + 3, fCollapseRect.bottom - 1), outlineColor); - - AddLine(BPoint(fCollapseRect.left + 4, fCollapseRect.top + 3), - BPoint(fCollapseRect.left + 4, fCollapseRect.bottom - 3), middleColor); - AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 4), - BPoint(fCollapseRect.left + 5, fCollapseRect.bottom - 4), middleColor); - AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 5), - BPoint(fCollapseRect.left + 6, fCollapseRect.top + 5), middleColor); - EndLineArray(); - } else { - // expanded state - - BeginLineArray(6); - AddLine(BPoint(fCollapseRect.left + 1, fCollapseRect.top + 3), - BPoint(fCollapseRect.right - 3, fCollapseRect.top + 3), outlineColor); - AddLine(BPoint(fCollapseRect.left + 1, fCollapseRect.top + 3), - BPoint(fCollapseRect.left + 5, fCollapseRect.top + 7), outlineColor); - AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 7), - BPoint(fCollapseRect.right - 3, fCollapseRect.top + 3), outlineColor); - - AddLine(BPoint(fCollapseRect.left + 3, fCollapseRect.top + 4), - BPoint(fCollapseRect.right - 5, fCollapseRect.top + 4), middleColor); - AddLine(BPoint(fCollapseRect.left + 4, fCollapseRect.top + 5), - BPoint(fCollapseRect.right - 6, fCollapseRect.top + 5), middleColor); - AddLine(BPoint(fCollapseRect.left + 5, fCollapseRect.top + 5), - BPoint(fCollapseRect.left + 5, fCollapseRect.top + 6), middleColor); - EndLineArray(); - } - } + uint32 arrowDirection = fCollapsed + ? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW; + be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect, + LowColor(), arrowDirection, 0, B_DARKEN_3_TINT); SetPenSize(kPenSize); ############################################################################ Commit: 259ffc02528c0a87b4c5c7a4673efbd4eb27b4b1 URL: http://cgit.haiku-os.org/haiku/commit/?id=259ffc0 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sat Jan 21 03:13:24 2012 UTC Style cleanup in notification_server: #includes ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 53e085e..9f3dc98 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -100,7 +100,7 @@ AppGroupView::Draw(BRect updateRect) } - void +void AppGroupView::MouseDown(BPoint point) { if (fCloseRect.Contains(point)) { diff --git a/src/servers/notification/NotificationServer.cpp b/src/servers/notification/NotificationServer.cpp index 0b528c2..ef1d49e 100644 --- a/src/servers/notification/NotificationServer.cpp +++ b/src/servers/notification/NotificationServer.cpp @@ -8,6 +8,7 @@ #include <Beep.h> #include <Notifications.h> +#include <PropertyInfo.h> #include "NotificationWindow.h" #include "NotificationServer.h" diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 613ecc5..14c21df 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -13,19 +13,24 @@ * Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx> */ -#include <ControlLook.h> + +#include "NotificationView.h" + + +#include <Bitmap.h> #include <GroupLayout.h> -#include <GroupLayoutBuilder.h> -#include <Layout.h> #include <LayoutUtils.h> +#include <MessageRunner.h> #include <Messenger.h> +#include <Notification.h> #include <Path.h> +#include <PropertyInfo.h> #include <Roster.h> #include <StatusBar.h> -#include "NotificationView.h" #include "NotificationWindow.h" + static const int kIconStripeWidth = 32; property_info message_prop_list[] = { diff --git a/src/servers/notification/NotificationView.h b/src/servers/notification/NotificationView.h index 62d12ec..b5ada59 100644 --- a/src/servers/notification/NotificationView.h +++ b/src/servers/notification/NotificationView.h @@ -10,15 +10,19 @@ #include <list> -#include <Bitmap.h> -#include <MessageRunner.h> -#include <Notification.h> +#include <String.h> #include <View.h> + +class BBitmap; +class BMessageRunner; +class BNotification; + class NotificationWindow; const uint32 kRemoveView = 'ReVi'; + class NotificationView : public BView { public: NotificationView(NotificationWindow* win, diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index c4e39c2..08d434d 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -17,13 +17,15 @@ #include <Alert.h> #include <Application.h> #include <Catalog.h> +#include <Deskbar.h> +#include <Directory.h> #include <File.h> +#include <FindDirectory.h> #include <GroupLayout.h> -#include <Layout.h> #include <NodeMonitor.h> +#include <Notifications.h> #include <Path.h> #include <PropertyInfo.h> -#include <private/interface/WindowPrivate.h> #include "AppGroupView.h" #include "AppUsage.h" diff --git a/src/servers/notification/NotificationWindow.h b/src/servers/notification/NotificationWindow.h index 84cb81b..9837c18 100644 --- a/src/servers/notification/NotificationWindow.h +++ b/src/servers/notification/NotificationWindow.h @@ -12,21 +12,18 @@ #include <vector> #include <map> -#include <Directory.h> -#include <Deskbar.h> -#include <Entry.h> -#include <FindDirectory.h> -#include <Message.h> -#include <Notifications.h> -#include <PropertyInfo.h> +#include <AppFileInfo.h> #include <String.h> #include <Window.h> #include "NotificationView.h" + class AppGroupView; class AppUsage; +struct property_info; + typedef std::map<BString, AppGroupView*> appview_t; typedef std::map<BString, AppUsage*> appfilter_t; typedef std::vector<NotificationView*> views_t; ############################################################################ Commit: 710eb7410f2ca3200259d84a5e3f71dde0a21b6f URL: http://cgit.haiku-os.org/haiku/commit/?id=710eb74 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sun Jan 22 01:59:44 2012 UTC Clean up use of SetPosition(). This fixes a bug where an empty white window would appear when changing workspaces if there were no notifications. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 08d434d..e7ff4c2 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -100,7 +100,7 @@ NotificationWindow::WorkspaceActivated(int32 /*workspace*/, bool active) { // Ensure window is in the correct position if (active) - _ShowHide(); + SetPosition(); } @@ -317,9 +317,10 @@ NotificationWindow::_ShowHide() return; } - SetPosition(); - if (IsHidden()) + if (IsHidden()) { + SetPosition(); Show(); + } } ############################################################################ Commit: d19e651f97c678f334ed212699f7d0f4f9676309 URL: http://cgit.haiku-os.org/haiku/commit/?id=d19e651 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Sun Jan 22 02:32:46 2012 UTC Expand click rects when checking for close/collapse clicks. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 9f3dc98..7361bb8 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -103,7 +103,7 @@ AppGroupView::Draw(BRect updateRect) void AppGroupView::MouseDown(BPoint point) { - if (fCloseRect.Contains(point)) { + if (BRect(fCloseRect).InsetBySelf(-5, -5).Contains(point)) { int32 children = fInfo.size(); for (int32 i = 0; i < children; i++) { GetLayout()->RemoveView(fInfo[i]); @@ -116,7 +116,7 @@ AppGroupView::MouseDown(BPoint point) BMessage message(kRemoveGroupView); message.AddPointer("view", this); fParent->PostMessage(&message); - } else if (fCollapseRect.Contains(point)) { + } else if (BRect(fCollapseRect).InsetBySelf(-5, -5).Contains(point)) { fCollapsed = !fCollapsed; int32 children = fInfo.size(); if (fCollapsed) { ############################################################################ Commit: ac93328eb95bb829ae9ee944a65083ea5ad16a1e URL: http://cgit.haiku-os.org/haiku/commit/?id=ac93328 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Tue Mar 27 10:14:18 2012 UTC Have NotificationWindow enforce the window size setting. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index e7ff4c2..6c41d4f 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -520,6 +520,8 @@ NotificationWindow::_LoadDisplaySettings(bool startMonitor) if (settings.FindFloat(kWidthName, &fWidth) != B_OK) fWidth = kDefaultWidth; + GetLayout()->SetExplicitMaxSize(BSize(fWidth, B_SIZE_UNSET)); + GetLayout()->SetExplicitMinSize(BSize(fWidth, B_SIZE_UNSET)); if (settings.FindInt32(kIconSizeName, &setting) != B_OK) fIconSize = kDefaultIconSize; ############################################################################ Commit: 2fab0e48044edb5221cf0b615fb5f0e85e9dc35c URL: http://cgit.haiku-os.org/haiku/commit/?id=2fab0e4 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Tue Mar 27 10:15:47 2012 UTC Remove dead code in NotificationView.cpp ---------------------------------------------------------------------------- diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 14c21df..06c89e7 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -369,31 +369,6 @@ NotificationView::MouseDown(BPoint point) } -/* -BSize -NotificationView::MinSize() -{ -// return BLayoutUtils::ComposeSize(ExplicitMinSize(), _CalculateSize()); - return _CalculateSize(); -} - - -BSize -NotificationView::MaxSize() -{ - return _CalculateSize(); -} - - -BSize -NotificationView::PreferredSize() -{ - return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), - _CalculateSize()); -} -*/ - - BHandler* NotificationView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* spec, int32 form, const char* prop) ############################################################################ Commit: c2fbfb1d5811e3e3057bf5077aae87a48bb36868 URL: http://cgit.haiku-os.org/haiku/commit/?id=c2fbfb1 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Tue Mar 27 10:17:35 2012 UTC Don't hardcode the NotificationView width to 300px. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp index 06c89e7..3bfff10 100644 --- a/src/servers/notification/NotificationView.cpp +++ b/src/servers/notification/NotificationView.cpp @@ -516,24 +516,19 @@ NotificationView::MessageID() const } -BSize +void NotificationView::_CalculateSize() { - BSize size; - - size.width = 300; - size.height = fHeight; + float height = fHeight; if (fNotification->Type() == B_PROGRESS_NOTIFICATION) { font_height fh; be_plain_font->GetHeight(&fh); float fontHeight = fh.ascent + fh.descent + fh.leading; - size.height += 9 + (kSmallPadding * 2) + (kEdgePadding * 1) + height += 9 + (kSmallPadding * 2) + (kEdgePadding * 1) + fontHeight * 2; } - SetExplicitMinSize(size); - SetExplicitMaxSize(size); - - return size; + SetExplicitMinSize(BSize(0, height)); + SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height)); } diff --git a/src/servers/notification/NotificationView.h b/src/servers/notification/NotificationView.h index b5ada59..37ed61c 100644 --- a/src/servers/notification/NotificationView.h +++ b/src/servers/notification/NotificationView.h @@ -51,7 +51,7 @@ public: const char* MessageID() const; private: - BSize _CalculateSize(); + void _CalculateSize(); struct LineInfo { BFont font; ############################################################################ Commit: 3c7caf81db30da3f538525d11d60a1c65b8b4ab6 URL: http://cgit.haiku-os.org/haiku/commit/?id=3c7caf8 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Tue Mar 27 10:39:34 2012 UTC Fix a bug that caused some NotificationViews to be double-shown. This bug affected views added while the window was hidden, and would result in that view not being hidden when the group was collapsed for the first time. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index 7361bb8..eee5fdd 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -206,7 +206,7 @@ AppGroupView::AddInfo(NotificationView* view) if (IsHidden()) Show(); - if (view->IsHidden() && !fCollapsed) + if (view->IsHidden(view) && !fCollapsed) view->Show(); } ############################################################################ Revision: hrev43935 Commit: 91b523054febe7c9bea327e9596e8da5ff94f20e URL: http://cgit.haiku-os.org/haiku/commit/?id=91b5230 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Tue Mar 27 11:17:27 2012 UTC Resolve TODO about possible use after free bug. ---------------------------------------------------------------------------- diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp index eee5fdd..9266c3a 100644 --- a/src/servers/notification/AppGroupView.cpp +++ b/src/servers/notification/AppGroupView.cpp @@ -185,11 +185,10 @@ AppGroupView::AddInfo(NotificationView* view) for (int32 i = 0; i < children; i++) { if (id == fInfo[i]->MessageID()) { - // TODO: because NotificationWindow also tracks these - // views, we may be heading towards a use-after-free with - // this code. - GetLayout()->RemoveView(fInfo[i]); - delete fInfo[i]; + NotificationView* oldView = fInfo[i]; + fParent->NotificationViewSwapped(oldView, view); + GetLayout()->RemoveView(oldView); + delete oldView; fInfo[i] = view; found = true; diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp index 6c41d4f..8ab9794 100644 --- a/src/servers/notification/NotificationWindow.cpp +++ b/src/servers/notification/NotificationWindow.cpp @@ -325,6 +325,17 @@ NotificationWindow::_ShowHide() void +NotificationWindow::NotificationViewSwapped(NotificationView* stale, + NotificationView* fresh) +{ + views_t::iterator it = find(fViews.begin(), fViews.end(), stale); + + if (it != fViews.end()) + *it = fresh; +} + + +void NotificationWindow::SetPosition() { Layout(true); diff --git a/src/servers/notification/NotificationWindow.h b/src/servers/notification/NotificationWindow.h index 9837c18..76dcc83 100644 --- a/src/servers/notification/NotificationWindow.h +++ b/src/servers/notification/NotificationWindow.h @@ -57,6 +57,10 @@ public: private: friend class AppGroupView; + void NotificationViewSwapped( + NotificationView* stale, + NotificationView* fresh); + void SetPosition(); void _LoadSettings(bool startMonitor = false); void _LoadAppFilters(bool startMonitor = false);