From e1474dd440b905cab57c4d9b5a7003fb921a22b1 Mon Sep 17 00:00:00 2001 From: DarkmatterVale Date: Sun, 3 Jan 2016 11:58:43 +0000 Subject: [PATCH] BSnow: Remove from tree. Signed-off-by: Augustin Cavalier It now lives at HaikuArchives. --- src/apps/Jamfile | 1 - src/apps/bsnow/BSnow.rdef | 49 --- src/apps/bsnow/Flakes.cpp | 40 --- src/apps/bsnow/Flakes.h | 12 - src/apps/bsnow/Jamfile | 18 - src/apps/bsnow/README.html | 38 --- src/apps/bsnow/SnowApp.cpp | 27 -- src/apps/bsnow/SnowView.cpp | 636 ------------------------------------ src/apps/bsnow/SnowView.h | 83 ----- 9 files changed, 904 deletions(-) delete mode 100644 src/apps/bsnow/BSnow.rdef delete mode 100644 src/apps/bsnow/Flakes.cpp delete mode 100644 src/apps/bsnow/Flakes.h delete mode 100644 src/apps/bsnow/Jamfile delete mode 100644 src/apps/bsnow/README.html delete mode 100644 src/apps/bsnow/SnowApp.cpp delete mode 100644 src/apps/bsnow/SnowView.cpp delete mode 100644 src/apps/bsnow/SnowView.h diff --git a/src/apps/Jamfile b/src/apps/Jamfile index b643ddd705..e9366de5f7 100644 --- a/src/apps/Jamfile +++ b/src/apps/Jamfile @@ -4,7 +4,6 @@ HaikuSubInclude 3dmov ; HaikuSubInclude aboutsystem ; HaikuSubInclude activitymonitor ; HaikuSubInclude autoraise ; -HaikuSubInclude bsnow ; HaikuSubInclude bootmanager ; HaikuSubInclude charactermap ; HaikuSubInclude clock ; diff --git a/src/apps/bsnow/BSnow.rdef b/src/apps/bsnow/BSnow.rdef deleted file mode 100644 index bcac9ab7bf..0000000000 --- a/src/apps/bsnow/BSnow.rdef +++ /dev/null @@ -1,49 +0,0 @@ - -resource app_signature "application/x-vnd.mmu_man.BSnow"; - -resource app_name_catalog_entry "x-vnd.mmu_man.BSnow:System name:BSnow"; - -resource app_flags B_SINGLE_LAUNCH; - -resource app_version { - major = 1, - middle = 0, - minor = 0, - - variety = B_APPV_DEVELOPMENT, - internal = 0, - - short_info = "BSnow", - long_info = "BSnow ©2007-2009 Haiku" -}; - -resource vector_icon { - $"6E6369660A010100007503010000020106023D80000000000000003D80004900" - $"004A1000AAFFFFFFFF95BCDD020106023D00000000000000003D000048E00049" - $"2000AAFFFFFFFF95BCDD020106023C40000000000000003C4000492000474000" - $"AAFFFFFFFF95BCDD0387AFD1020106033772203457DEB6B0FC39F52B48F3ED48" - $"7E9B00FFDE069BFFAA00FFF67D06020106043D00000000000000003D000048C0" - $"0048C0005DFF000080C00505AAFF0000FFC00505020116023B00000000000000" - $"003B00004A2000450000005CFF00020106023A40000000000000003A40004480" - $"00448000AAFFFFFFFF95BCDD0C02043E36BA7D36C36A36524A52BF4552C8323E" - $"5EC36A5EBA7D5E2A4A2AC8322ABF4502043E30BB6230C285304E404EBC2E4EC3" - $"513E50C28550BB62502E402EC3512EBC2E02043E26BC4626C1A1264A324AB77E" - $"4ABCD93E3EC1A13EBC463E323232BCD932B77E02033C363C363C3438343A3238" - $"34343A3836383A020244364634423840343E3642320609BABB0349415346524E" - $"5149534856485C4D59495A49C967C2D85D475847594556464B3F4B3F493F060D" - $"F6EFFA023A41423646374436463747374738453A443A443A473B4B3B4B3E4B40" - $"4C404840483C463C423E40483A473D403E3337373C343A393F02024228442840" - $"28482C482E482A06041E3C3E4A3C44405038343C06042E3E50504A4C5054444E" - $"3E3E06042E3E5E5B585162654E524C3E02042822B4D922B786222E282EB4D92E" - $"B786282EB7862EB4D92E222822B78622B4D9160A00010A1001158200040A0101" - $"001001178400040A020100000A01010502BFFFFB30DC88B0DC88BFFFFB4C0172" - $"4B6C250A030109000A010101123FAC9D3D297FBCEE693F67F547B66BC686A701" - $"178400040A030101000A040108000A010104023FD07C3C6897BC68973FD07CC4" - $"8CCB45DE750A010104023FEC8F3B1A4DBB1A4D3FEC8FC5A41F4467140A070106" - $"000A010102123FBBBE3CDF30BC9B533F6386460747C668CA01178400040A0401" - $"02000A05010302C000000000000000004000004B40000000000A060103000A01" - $"0104023FDB50BC1F483C1F483FDB50C52D234631630A010104023C62D23EDA76" - $"BECEB13CF6DB49653CC7C4CB0A010105000A010107301E1E01178C00040A0801" - $"07301E1E01158800040A01010B1001178400040A09010B00" -}; - diff --git a/src/apps/bsnow/Flakes.cpp b/src/apps/bsnow/Flakes.cpp deleted file mode 100644 index c9eeb79fdd..0000000000 --- a/src/apps/bsnow/Flakes.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Flakes.h" - -#define TRAN 0xFF -#define WHIT 0x3F - -const uchar gFlakeBits[NUM_PATTERNS][64] = { -{ -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN -}, -{ -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, -TRAN, WHIT, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, -TRAN, TRAN, WHIT, WHIT, WHIT, TRAN, TRAN, TRAN, -TRAN, WHIT, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, -TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN -} -/* -{ -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, WHIT, TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, -TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, -TRAN, WHIT, WHIT, WHIT, WHIT, WHIT, TRAN, TRAN, -TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, -TRAN, WHIT, TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, -TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN -} -*/ -}; - diff --git a/src/apps/bsnow/Flakes.h b/src/apps/bsnow/Flakes.h deleted file mode 100644 index 3ba4088224..0000000000 --- a/src/apps/bsnow/Flakes.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _FLAKES_H -#define _FLAKES_H -#include - -#define NUM_PATTERNS 2 - -#define PAT_HOTSPOT 3,3 - -extern const uchar gFlakeBits[NUM_PATTERNS][64]; - - -#endif diff --git a/src/apps/bsnow/Jamfile b/src/apps/bsnow/Jamfile deleted file mode 100644 index 604c4011f3..0000000000 --- a/src/apps/bsnow/Jamfile +++ /dev/null @@ -1,18 +0,0 @@ -SubDir HAIKU_TOP src apps bsnow ; - -SetSubDirSupportedPlatformsBeOSCompatible ; - -Application BSnow : - Flakes.cpp - SnowView.cpp - SnowApp.cpp - : be [ TargetLibsupc++ ] localestub - : BSnow.rdef - ; - -DoCatalogs BSnow : - x-vnd.mmu_man.BSnow - : - SnowApp.cpp - SnowView.cpp - ; diff --git a/src/apps/bsnow/README.html b/src/apps/bsnow/README.html deleted file mode 100644 index 22423561d1..0000000000 --- a/src/apps/bsnow/README.html +++ /dev/null @@ -1,38 +0,0 @@ - - - -BSnow - winter weather for BeOS - - - -              *        .                .            .
-  .                         *                             .        *                 -BSnow - winter weather for BeOS,                         *                 .
-              *     .              *               .
- -
-
-
-
-
- -© 2003 François Revol. -
-
-Features: -
    -
  • adapts the number of snow flakes to the CPU frequency to avoid hogging it, -
  • random wind change, -
  • the fallen snow accumulates on the windows and bottom of the screen, -
-
-
-Limitations: -
    -
  • lot of flicker, -
  • it needs to set the desktop view flags to B_DRAW_ON_CHILDREN, which might gives weird drawing with some replicants afterwards, -
-
-Sources released under the MIT licence. - - diff --git a/src/apps/bsnow/SnowApp.cpp b/src/apps/bsnow/SnowApp.cpp deleted file mode 100644 index 1b409d96dd..0000000000 --- a/src/apps/bsnow/SnowApp.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -#include "SnowView.h" - - -int main(int argc, char **argv) -{ - BApplication app(APP_SIG); - BWindow* win; - bool draggersShown = BDragger::AreDraggersDrawn(); - win = new BWindow(BRect(SNOW_VIEW_RECT), B_TRANSLATE_SYSTEM_NAME("BSnow"), - B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_NOT_RESIZABLE); - SnowView* view = new SnowView(); - win->AddChild(view); - win->MoveTo(50, 50); - win->Show(); - win->SetPulseRate(500000); - BDragger::ShowAllDraggers(); - app.Run(); - if (!draggersShown) - BDragger::HideAllDraggers(); - return 0; -} - diff --git a/src/apps/bsnow/SnowView.cpp b/src/apps/bsnow/SnowView.cpp deleted file mode 100644 index 7fdbc6fc31..0000000000 --- a/src/apps/bsnow/SnowView.cpp +++ /dev/null @@ -1,636 +0,0 @@ -#include "SnowView.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Flakes.h" - - -#define FORWARD_TO_PARENT -#undef B_TRANSLATION_CONTEXT -#define B_TRANSLATION_CONTEXT "BSnow" - - -SnowView::SnowView() - : - BView(BRect(SNOW_VIEW_RECT), "BSnow", B_FOLLOW_NONE, - B_WILL_DRAW | B_PULSE_NEEDED) -{ - fAttached = false; - fMsgRunner = NULL; - fCachedParent = NULL; - fFallenBmp = NULL; - fFallenView = NULL; - fFallenReg = NULL; - fInvalidator = -1; - fShowClickMe = false; - for (int i = 0; i < WORKSPACES_COUNT; i++) - fFlakes[i] = NULL; - for (int i = 0; i < NUM_PATTERNS; i++) - fFlakeBitmaps[i] = NULL; - BRect r(Frame()); - r.left = r.right - 7; - r.top = r.bottom - 7; - fDragger = new BDragger(r, this); - AddChild(fDragger); - SetHighColor(255,255,255); -} - -#ifdef DEBUG -filter_result msgfilter(BMessage *message, BHandler **target, BMessageFilter *filter) -{ - switch (message->what) { - case B_MOUSE_DOWN: - case B_MOUSE_UP: - case B_MOUSE_MOVED: - case '_EVP': - case '_UPD': - case '_PUL': - case 'NTCH': - case 'NMDN': - break; - default: - printf("For: %p: %s\n", *target, (*target)->Name()); - message->PrintToStream(); - } - return B_DISPATCH_MESSAGE; -} -#endif - -SnowView::SnowView(BMessage *archive) - : BView(archive) -{ - system_info si; - PRINT(("SnowView()\n")); -#ifdef DEBUG - archive->PrintToStream(); -#endif - fDragger = NULL; - fAttached = false; - fMsgRunner = NULL; - fFallenBmp = NULL; - fFallenView = NULL; - fFallenReg = NULL; - fCachedParent = NULL; - fShowClickMe = false; - SetFlags(Flags() & ~B_PULSE_NEEDED); /* it's only used when in the app */ - get_system_info(&si); - fNumFlakes = 1000 * si.cpu_count / 3; - printf("BSnow: using %ld flakes\n", fNumFlakes); - for (int i = 0; i < WORKSPACES_COUNT; i++) { - fFlakes[i] = new flake[fNumFlakes]; - memset(fFlakes[i], 0, fNumFlakes * sizeof(flake)); - } - for (int i = 0; i < NUM_PATTERNS; i++) { - fFlakeBitmaps[i] = new BBitmap(BRect(0,0,7,7), B_CMAP8); - fFlakeBitmaps[i]->SetBits(gFlakeBits[i], 8*8, 0, B_CMAP8); - } - fCurrentWorkspace = 0; - SetHighColor(255,255,255); - SetDrawingMode(B_OP_OVER); -} - -SnowView::~SnowView() -{ - for (int i = 0; i < WORKSPACES_COUNT; i++) - if (fFlakes[i]) - delete [] fFlakes[i]; - if (fFallenBmp) - delete fFallenBmp; /* the view goes away with it */ -} - -BArchivable *SnowView::Instantiate(BMessage *data) -{ - return new SnowView(data); -} - -status_t SnowView::Archive(BMessage *data, bool deep) const -{ - status_t err; - err = BView::Archive(data, deep); - if (err < B_OK) - return err; - data->AddString("add_on", APP_SIG); - return B_OK; -} - -void SnowView::AttachedToWindow() -{ - BView *p; - rgb_color col; - fAttached = true; -/* if (!fMsgRunner) - fMsgRunner = new BMessageRunner(BMessenger(this), - new BMessage(MSG_PULSE_ME), - INTERVAL); -*/ - p = Parent(); - if (p) - col = B_TRANSPARENT_32_BIT;//Parent()->ViewColor(); - else - col = ui_color(B_PANEL_BACKGROUND_COLOR); - SetViewColor(col); -// BScreen bs; -// fCachedWsWidth = bs.Frame().IntegerWidth(); -// fCachedWsHeight = bs.Frame().IntegerHeight(); - fDragger = dynamic_cast(FindView("_dragger_")); - if (fDragger && p) { - fCachedParent = p; - fCachedWsWidth = p->Frame().IntegerWidth(); - fCachedWsHeight = p->Frame().IntegerHeight(); - fDragger->SetViewColor(col); - if (fDragger->InShelf()) { - p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); -#ifdef B_BEOS_VERSION_DANO - p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED); -#endif - ResizeTo(p->Bounds().Width(), p->Bounds().Height()); - MoveTo(0,0); - fDragger->MoveTo(p->Bounds().Width()-7, p->Bounds().Height()-7); - } - BRect fallenRect(p->Bounds()); - fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT; - fFallenBmp = new BBitmap(fallenRect, B_BITMAP_ACCEPTS_VIEWS, B_CMAP8); - memset(fFallenBmp->Bits(), B_TRANSPARENT_MAGIC_CMAP8, (size_t)(fallenRect.Height()*fFallenBmp->BytesPerRow())); - fFallenView = new BView(fallenRect, "offscreen fallen snow", B_FOLLOW_NONE, 0); - fFallenBmp->AddChild(fFallenView); - fFallenReg = new BRegion; - fInvalidator = spawn_thread(SnowMakerThread, INVALIDATOR_THREAD_NAME, B_LOW_PRIORITY, (void *)this); - resume_thread(fInvalidator); - printf("BSnow: OK: ws = %" B_PRId32 " x %" B_PRId32 "\n", fCachedWsWidth, fCachedWsHeight); -#ifdef DEBUG - Window()->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, msgfilter)); -#endif - } -} - -void SnowView::DetachedFromWindow() -{ - fAttached = false; -/* - if (Parent()) { - Parent()->Invalidate(Parent()->Bounds()); - } -*/ - if (fMsgRunner) - delete fMsgRunner; - fMsgRunner = NULL; - status_t err; - fCachedParent = NULL; - if (fInvalidator > B_OK) - wait_for_thread(fInvalidator, &err); - fInvalidator = -1; - if (fFallenReg) - delete fFallenReg; -} - -void SnowView::MessageReceived(BMessage *msg) -{ - BAlert *info; - //msg->PrintToStream(); - switch (msg->what) { - case MSG_PULSE_ME: - if (Parent()) { - Calc(); - InvalFlakes(); - } - break; - case B_ABOUT_REQUESTED: - info = new BAlert("BSnow info", - "BSnow, just in case you don't have real one...\n" - "" B_UTF8_COPYRIGHT " 2003, François Revol.", - "Where is Santa ??"); - info->SetFeel(B_NORMAL_WINDOW_FEEL); - info->SetLook(B_FLOATING_WINDOW_LOOK); - info->SetFlags(info->Flags()|B_NOT_ZOOMABLE|B_CLOSE_ON_ESCAPE); - info->Go(NULL); - break; - default: -//#ifdef FORWARD_TO_PARENT -/* - if (fAttached && Parent()) - Parent()->MessageReceived(msg); - else -*/ -//#endif - BView::MessageReceived(msg); - } -} - -void SnowView::Draw(BRect ur) -{ - int i; - if (!fCachedParent) { - if (!fShowClickMe) { /* show "drag me" */ - SetLowColor(ViewColor()); - SetHighColor(0,0,0); - SetFontSize(12); - DrawString(B_TRANSLATE("Drag me on your desktop" B_UTF8_ELLIPSIS), - BPoint(15,25)); - BPoint arrowHead(Bounds().RightBottom() + BPoint(-10,-10)); - StrokeLine(arrowHead, arrowHead - BPoint(7,0)); - StrokeLine(arrowHead, arrowHead - BPoint(0,7)); - StrokeLine(arrowHead, arrowHead - BPoint(12,12)); - return; - } else { - SetLowColor(ViewColor()); - SetHighColor(0,0,0); - SetFontSize(12); - DrawString(B_TRANSLATE("Click me to remove BSnow" B_UTF8_ELLIPSIS), - BPoint(15,25)); - return; - } - } - //printf("Draw()\n"); - uint32 cw = fCurrentWorkspace; - if (fFlakes[cw] == NULL) - return; - /* draw the snow already fallen */ -// BRect fallenRect(Bounds()); -// fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT; -// if (ur.Intersects(fallenRect)) { - //if (fFallenBmp->Lock()) { - // DrawBitmap(fFallenBmp, fallenRect); - // fFallenBmp->Unlock(); - //} - int32 cnt = fFallenReg->CountRects(); -// drawing_mode oldmode = DrawingMode(); -// SetDrawingMode(B_OP_ADD); - - for (i=0; iRectAt(i); -// SetHighColor(245, 245, 245, 200); -// FillRect(r); -// SetHighColor(255, 255, 255, 255); -// r.InsetBy(1,1); - FillRect(r); - } -// SetDrawingMode(oldmode); -// } - /* draw our flakes */ - for (i=0; i3)?1:0; - //FillRect(BRect(fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT),fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)+BPoint(7,7)), gFlakePatterns[pat]); -/* - StrokeLine(fFlakes[cw][i].pos+BPoint(-1,-1), - fFlakes[cw][i].pos+BPoint(1,1)); - StrokeLine(fFlakes[cw][i].pos+BPoint(-1,1), - fFlakes[cw][i].pos+BPoint(1,-1)); -*/ - DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)); - } -} - -void SnowView::Pulse() -{ - if (fShowClickMe) - return; /* done */ - if (fCachedParent) - return; /* we are in Tracker! */ - BMessenger msgr("application/x-vnd.Be-TRAK"); - BMessage msg(B_GET_PROPERTY), reply; - msg.AddSpecifier("Frame"); - msg.AddSpecifier("View", "BSnow"); - msg.AddSpecifier("Window", 1); /* 0 is Twitcher */ - if (msgr.SendMessage(&msg, &reply) == B_OK && reply.what == B_REPLY) { - //reply.PrintToStream(); - Invalidate(Bounds()); - fShowClickMe = true; - } -} - -void SnowView::Calc() -{ - int i; - uint32 cw = fCurrentWorkspace; - - /* check if the parent changed size */ - BRect pFrame = fCachedParent->Frame(); - if (fCachedWsWidth != pFrame.Width() || fCachedWsHeight != pFrame.Height()) { - fCachedWsWidth = pFrame.IntegerWidth(); - fCachedWsHeight = pFrame.IntegerHeight(); - printf("BSnow: Parent resized to %" B_PRId32 " %" B_PRId32 "\n", fCachedWsWidth, fCachedWsHeight); - fFallenReg->MakeEmpty(); /* remove all the fallen snow */ - ResizeTo(pFrame.IntegerWidth(), pFrame.IntegerHeight()); - fDragger->MoveTo(pFrame.IntegerWidth()-7, pFrame.IntegerHeight()-7); - } - - /* make new flakes */ - for (i=0; i 0) - fFlakes[cw][i].pos.x = 0; - else - fFlakes[cw][i].pos.x = fCachedWsWidth; - } - if (fFlakes[cw][i].pos.x > fCachedWsWidth+10) { - fFlakes[cw][i].pos.y = fFlakes[cw][i].pos.x - fCachedWsWidth; - if (fWind > 0) - fFlakes[cw][i].pos.x = 0; - else - fFlakes[cw][i].pos.x = fCachedWsWidth; - } - } - } - - /* like a candle in the wind... */ - if (fWindDuration < system_time()) { - fWindDuration = system_time() + ((((bigtime_t)rand())*1000) % WIND_MAX_DURATION); - fWind = (rand() % WIND_SPAN) - WIND_SPAN/2; - printf("BSnow: wind change: %f\n", fWind); - } - - -// if (fFallenView->LockLooperWithTimeout(5000)) { -// if (fFallenBmp) { -// uint8 *fallenBits = (uint8 *)fFallenBmp->Bits(); - - BRegion desktopReg; - GetClippingRegion(&desktopReg); - - /* let's add some gravity and wind */ - for (i=0; i (fCachedWsHeight-FALLEN_HEIGHT)) { - - bool fallen = false; - bool keepfalling = false; - - /* fallen on the flour */ - if (fFlakes[cw][i].pos.y > fCachedWsHeight-2) - fallen = true; - /* fallon on another fallen flake */ - else if (fFallenReg->Intersects(BRect(fFlakes[cw][i].pos - BPoint(0,1), - fFlakes[cw][i].pos + BPoint(0,1)))) { - /* don't accumulate too much */ - if ((fFlakes[cw][i].pos.y > fCachedWsHeight-30) || - !desktopReg.Intersects( - BRect(fFlakes[cw][i].pos + BPoint(0,6), - fFlakes[cw][i].pos + BPoint(0,10)))) - fallen = true; - /* fallen on a window */ - } else if (!desktopReg.Intersects( - BRect(fFlakes[cw][i].pos + BPoint(-1,-1-2), - fFlakes[cw][i].pos + BPoint(1,1-1))) && - desktopReg.Intersects( - BRect(fFlakes[cw][i].pos + BPoint(-1,-1-3), - fFlakes[cw][i].pos + BPoint(1,1-3)))) { - //printf("fallen3 @ %f %f\n", fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y); - fFlakes[cw][i].pos = fFlakes[cw][i].opos; - fallen = true; - keepfalling = true; /* but keep one falling */ - } - -/* else if (fallenBits[ (long)(fFlakes[cw][i].pos.y - * fFallenBmp->BytesPerRow() - + fFlakes[cw][i].pos.y - - (fCachedWsHeight-FALLEN_HEIGHT)) ] != B_TRANSPARENT_MAGIC_CMAP8) { - fallen = true; - }*/ - -// if (fallen) { -// int pat = (fFlakes[cw][i].weight>3)?1:0; -// if (fFlakes[cw][i].pos.y > fCachedWsHeight-1) -// fFlakes[cw][i].pos.y = fCachedWsHeight-(rand()%4); - //fFallenView->DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)); -// fallenBits[ (long)(fFlakes[cw][i].pos.y * fFallenBmp->BytesPerRow() -// + fFlakes[cw][i].pos.y-(fCachedWsHeight-FALLEN_HEIGHT)) ] = 0x56; -// printf("fallen @ %f, %f\n", fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y); -// } - if (fallen) { - if (!keepfalling) - fFlakes[cw][i].weight = 0; - fFallenReg->Include(BRect(fFlakes[cw][i].pos - BPoint(2,0), - fFlakes[cw][i].pos + BPoint(2,2))); - if (keepfalling) { - fFlakes[cw][i].pos += BPoint(0,10); - /* except if under the desktop */ - if (fFlakes[cw][i].pos.y > fCachedWsHeight-1) - fFlakes[cw][i].weight = 0; - } - } - - /* cleanup, when a window hides the snow */ - fFallenReg->IntersectWith(&desktopReg); - - /* cleanup, when a window is moved */ - /* seems to lockup Tracker */ -/* - int32 cnt = fFallenReg->CountRects(); - for (i=0; iRectAt(i); - if (desktopReg.Intersects(r.OffsetByCopy(0,15))) { - fFallenReg->Exclude(r); - cnt--; - } - } -*/ - /* add the effect of the wind */ - fFlakes[cw][i].pos.x += fWind + (rand() % 6 - 3); - if ((fFlakes[cw][i].pos.x > fCachedWsWidth+50)||(fFlakes[cw][i].pos.x < -50)) - fFlakes[cw][i].weight = 0; - } -// fFallenView->UnlockLooper(); -// } -#if 0 - for (i=0; i<10; i++) - printf("f[%d] = {%f, %f}, {%f, %f}, %d\n", i, - fFlakes[cw][i].opos.x, fFlakes[cw][i].opos.y, - fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y, - fFlakes[cw][i].weight); -#endif -} - -void SnowView::InvalFlakes() -{ - int i; - BView *p = Parent(); - if (!p) - return; - //printf("InvalFlakes()\n"); - uint32 cw = fCurrentWorkspace; - - for (i=0; iMouseDown(where); -#endif -} - -void SnowView::MouseUp(BPoint where) -{ -#ifdef FORWARD_TO_PARENT - if (fAttached && Parent()) - Parent()->MouseUp(where); -#endif - if (fCachedParent) - return; /* we are *inside* the Tracker, - * don't even try talking to ourselve - * with the window locked - */ - BMessenger msgr("application/x-vnd.Be-TRAK"); - BMessage msg(B_DELETE_PROPERTY), reply; - msg.AddSpecifier("Replicant", "BSnow"); - msg.AddSpecifier("Shelf"); - msg.AddSpecifier("View", "PoseView"); - msg.AddSpecifier("Window", 1); /* 0 is Tracker Status */ - if ((msgr.SendMessage(&msg, &reply) == B_OK) && - (reply.what == B_NO_REPLY || reply.what == B_REPLY)) { - //reply.PrintToStream(); - fShowClickMe = false; - Invalidate(Bounds()); - } - /* - BMessage: what = JAHA (0x4a414841, or 1245792321) - entry index, type='LONG', c=1, size= 4, data[0]: 0x2 (2, '') - entry when, type='LLNG', c=1, size= 8, data[0]: 0xf6a1b09ac (66204666284, '') - entry source, type='PNTR', c=1, size= 4, - entry be:sender, type='MSNG', c=1, size=24, - */ -} - -void SnowView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message) -{ -#ifdef FORWARD_TO_PARENT - if (fAttached && Parent()) - Parent()->MouseMoved(where, code, a_message); -#endif -} - -void SnowView::KeyDown(const char *bytes, int32 numBytes) -{ -#ifdef FORWARD_TO_PARENT - if (fAttached && Parent()) - Parent()->KeyDown(bytes, numBytes); -#endif -} - -void SnowView::KeyUp(const char *bytes, int32 numBytes) -{ -#ifdef FORWARD_TO_PARENT - if (fAttached && Parent()) - Parent()->KeyUp(bytes, numBytes); -#endif -} - -#define PORTION_GRAN 20 - -int32 SnowView::SnowMakerThread(void *p_this) -{ - SnowView *_this = (SnowView *)p_this; - BView *p = _this->Parent(); - BRect portion(0,0,(_this->fCachedWsWidth/PORTION_GRAN)-1, (_this->fCachedWsHeight/PORTION_GRAN)-1); - int nf = _this->fNumFlakes; - BRegion reg(BRect(-1,-1,-1,-1)); - while (p && _this->fAttached) { - snooze(INTERVAL/(10*(nf?nf:1))); - int32 cw = _this->fCurrentWorkspace; - bool drawThisOne = false; -//printf("processing flake %d...\n", current); - //for (; (current%(fNumFlakes/4); current++) - if (reg.Intersects(portion)) { - for (int i = 0; !drawThisOne && i < nf; i++) { - /* if we find at least one flake in this rect, draw it */ - if ((_this->fFlakes[cw][i].weight) && ( - portion.Intersects(BRect(_this->fFlakes[cw][i].opos - BPoint(4,4), _this->fFlakes[cw][i].opos + BPoint(4,4))) || - portion.Intersects(BRect(_this->fFlakes[cw][i].pos - BPoint(4,4), _this->fFlakes[cw][i].pos + BPoint(4,4))))) { - drawThisOne = true; - } - } - } - //if (!drawThisOne) - //printf("!Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom); - /* avoid deadlock on exit */ - if (drawThisOne && (_this->LockLooperWithTimeout(2000) == B_OK)) { -// printf("Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom); - p->Invalidate(portion); - _this->UnlockLooper(); - } - portion.OffsetBy(_this->fCachedWsWidth/PORTION_GRAN, 0); - if (portion.left >= _this->fCachedWsWidth) { /* right wrap */ - //printf("rigth wrap to %ld\n", _this->fCachedWsWidth); - portion.OffsetTo(0, portion.top+(_this->fCachedWsHeight/PORTION_GRAN)); - } - if (portion.top >= _this->fCachedWsHeight) { - portion.OffsetTo(0,0); - /* avoid deadlock on exit */ - if (_this->LockLooperWithTimeout(5000) == B_OK) { -//printf("calculating flakes...\n"); - _this->Calc(); -//printf("done calculating flakes.\n"); - _this->GetClippingRegion(®); - //printf("Region:\n"); - //reg.PrintToStream(); - _this->UnlockLooper(); - } - } - } -#if 0 - BView *p = _this->Parent(); - while (p && _this->fAttached) { - snooze(INTERVAL/_this->fNumFlakes); -//printf("processing flake %d...\n", current); - //for (; (current%(fNumFlakes/4); current++) - /* avoid deadlock on exit */ - if (_this->LockLooperWithTimeout(2000) == B_OK) { - if (_this->fFlakes[_this->fCurrentWorkspace][current].weight) { - p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].opos - BPoint(4,4), - _this->fFlakes[_this->fCurrentWorkspace][current].opos + BPoint(4,4))); - p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].pos - BPoint(4,4), - _this->fFlakes[_this->fCurrentWorkspace][current].pos + BPoint(4,4))); - } - _this->UnlockLooper(); - current++; - current %= _this->fNumFlakes; - if (!current) { - /* avoid deadlock on exit */ - if (_this->LockLooperWithTimeout(2000) == B_OK) { -printf("calculating flakes...\n"); - _this->Calc(); -printf("done calculating flakes.\n"); - _this->UnlockLooper(); - } - } - } - } -#endif - return B_OK; -} diff --git a/src/apps/bsnow/SnowView.h b/src/apps/bsnow/SnowView.h deleted file mode 100644 index ed688c9d4d..0000000000 --- a/src/apps/bsnow/SnowView.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _SNOW_VIEW_H -#define _SNOW_VIEW_H - - -#include -#include -#include -#include -#include -#include - -#include "Flakes.h" - - -#define APP_SIG "application/x-vnd.mmu_man.BSnow" -#define SNOW_VIEW_RECT 0,0,200,40 -#define NUM_FLAKES 200 -#define INTERVAL 200000 -#define MSG_PULSE_ME 'PulS' -#define MSG_DRAW_ME 'DraW' -#define WORKSPACES_COUNT 32 -#define WEIGHT_SPAN 50 -#define WEIGHT_GRAN 10 -#define WIND_SPAN 25 -#define WIND_MAX_DURATION 10000000 -#define FALLEN_HEIGHT 30 -#define INVALIDATOR_THREAD_NAME "You're Neo? I'm the Snow Maker!" - - -typedef struct flake { - BPoint pos; - BPoint opos; - float weight; -} flake; - - -class SnowView : public BView -{ -public: - SnowView(); - SnowView(BMessage *archive); - ~SnowView(); - static BArchivable *Instantiate(BMessage *data); - virtual status_t Archive(BMessage *data, bool deep = true) const; - void AttachedToWindow(); - void DetachedFromWindow(); - void MessageReceived(BMessage *msg); - void Draw(BRect ur); - void Pulse(); - - virtual void MouseDown(BPoint where); - virtual void MouseUp(BPoint where); - virtual void MouseMoved(BPoint where, uint32 code, - const BMessage *a_message); - virtual void KeyDown(const char *bytes, int32 numBytes); - virtual void KeyUp(const char *bytes, int32 numBytes); - - static int32 SnowMakerThread(void *p_this); - void Calc(); - void InvalFlakes(); - -private: - BMessageRunner *fMsgRunner; - BDragger *fDragger; - long fNumFlakes; - flake *fFlakes[WORKSPACES_COUNT]; - BList *fFallenFlakes[WORKSPACES_COUNT]; - uint32 fCurrentWorkspace; - uint32 fCachedWsWidth; - uint32 fCachedWsHeight; - float fWind; - bigtime_t fWindDuration; - bool fAttached; - BBitmap *fFlakeBitmaps[NUM_PATTERNS]; - thread_id fInvalidator; - BView *fCachedParent; - BBitmap *fFallenBmp; - BView *fFallenView; - BRegion *fFallenReg; - bool fShowClickMe; -}; - -#endif