From 1214cc085421bdc06b1d3079c9a2eacd947bf221 Mon Sep 17 00:00:00 2001 From: Nishi Date: Mon, 4 May 2026 00:01:17 +0900 Subject: [PATCH] a little bit better --- include/Mw/LowLevel/Haiku.h | 5 ++++- src/backend/haiku.cc | 44 ++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/Mw/LowLevel/Haiku.h b/include/Mw/LowLevel/Haiku.h index 446dfdd..3a33b38 100644 --- a/include/Mw/LowLevel/Haiku.h +++ b/include/Mw/LowLevel/Haiku.h @@ -42,6 +42,8 @@ class MwView : public BView { void MessageReceived(BMessage* message); void PostMessage(BMessage* message); void PostMessage(uint32 command); + status_t SendMessage(BMessage* message); + status_t SendMessage(uint32 command); void Invalidate(); void AttachedToWindow(); @@ -88,7 +90,8 @@ enum BVIEW_MW_WHAT { BVIEW_MW_POLYGON, BVIEW_MW_LINE, BVIEW_MW_BITMAP, - BVIEW_MW_RENDER + BVIEW_MW_RENDER, + BVIEW_MW_GET_MOUSE }; enum BWIN_MW_WHAT { diff --git a/src/backend/haiku.cc b/src/backend/haiku.cc index 6017a37..e58e160 100644 --- a/src/backend/haiku.cc +++ b/src/backend/haiku.cc @@ -178,6 +178,17 @@ void MwView::MessageReceived(BMessage* message) { this->Invalidate(); break; } + case BVIEW_MW_GET_MOUSE: + { + BPoint* p; + uint32 btn; + + if(message->FindPointer("view-ppoint", (void**)&p) != B_OK) break; + + this->GetMouse(p, &btn); + + break; + } default: { BView::MessageReceived(message); @@ -203,6 +214,24 @@ void MwView::PostMessage(uint32 command) { this->PostMessage(&msg); } +status_t MwView::SendMessage(BMessage* message) { + BMessage copy = *message; + BMessage reply; + MwLL top = this->handle; + + while(top->haiku.parent != NULL) top = top->haiku.parent; + + copy.AddPointer("window-view", this); + + return BMessenger(top->haiku.app->window).SendMessage(©, &reply); +} + +status_t MwView::SendMessage(uint32 command) { + BMessage msg(command); + + return this->SendMessage(&msg); +} + void MwView::Invalidate() { this->Draw(BRect(0, 0, 0, 0)); } @@ -700,7 +729,20 @@ void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {} void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {} -void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {} +void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { + MwLL top = handle; + BMessage msg(BVIEW_MW_GET_MOUSE); + BPoint p; + while(top->haiku.parent != NULL) { + top = top->haiku.parent; + } + + msg.AddPointer("view-ppoint", &p); + top->haiku.view->SendMessage(&msg); + + point->x = p.x; + point->y = p.y; +} void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { BScreen* screen = new BScreen();