From 8f3508d9c55bb9a093c9f9eb2fba86641f54c5f8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 26 Aug 2022 18:53:13 -0400 Subject: [PATCH] desklink: Make use of BControlLook::ComposeIconSize(). Fixes #16370. --- src/bin/desklink/DeskButton.cpp | 21 ++++++++------------- src/bin/desklink/desklink.cpp | 12 +++++++----- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/bin/desklink/DeskButton.cpp b/src/bin/desklink/DeskButton.cpp index 022289f57f..a74d4a1dda 100644 --- a/src/bin/desklink/DeskButton.cpp +++ b/src/bin/desklink/DeskButton.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -42,17 +43,13 @@ DeskButton::DeskButton(BRect frame, entry_ref* ref, const char* name, fActionList(actions), fTitleList(titles) { -#ifdef __HAIKU__ - fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); -#else - fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); -#endif - BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON); + fSegments = new BBitmap(frame, B_RGBA32); + BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)(frame.IntegerWidth() + 1)); } DeskButton::DeskButton(BMessage *message) - : BView(message) + : BView(message) { message->FindRef("ref", &fRef); @@ -65,12 +62,10 @@ DeskButton::DeskButton(BMessage *message) index++; } -#ifdef __HAIKU__ - fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); -#else - fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); -#endif - BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON); + fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)), + B_RGBA32); + BNodeInfo::GetTrackerIcon(&fRef, fSegments, + (icon_size)(fSegments->Bounds().IntegerWidth() + 1)); } diff --git a/src/bin/desklink/desklink.cpp b/src/bin/desklink/desklink.cpp index 89d39cf83f..03f7901bcf 100644 --- a/src/bin/desklink/desklink.cpp +++ b/src/bin/desklink/desklink.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,7 @@ const char *kAppSignature = "application/x-vnd.Haiku-desklink"; int main(int, char **argv) -{ +{ BApplication app(kAppSignature); bool atLeastOnePath = false; BList titleList; @@ -45,7 +46,7 @@ main(int, char **argv) for (int32 i = 1; argv[i]!=NULL; i++) { if (strcmp(argv[i], "--help") == 0) break; - + if (strcmp(argv[i], "--list") == 0) { int32 count = deskbar.CountItems(); int32 found = 0; @@ -124,7 +125,7 @@ main(int, char **argv) BEntry entry(argv[i], true); entry_ref ref; - + if (entry.Exists()) { entry.GetRef(&ref); } else if (BMimeType::IsValid(argv[i])) { @@ -136,10 +137,11 @@ main(int, char **argv) printf("desklink: cannot find '%s'\n", argv[i]); return 1; } - + err = deskbar.AddItem(&ref); if (err != B_OK) { - err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), + err = deskbar.AddItem(new DeskButton(BRect(BPoint(0, 0), + be_control_look->ComposeIconSize(B_MINI_ICON)), &ref, ref.name, titleList, actionList)); if (err != B_OK) { printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));