detach works
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-05-06 03:36:57 +09:00
commit e835a9cd60
6 changed files with 123 additions and 40 deletions

View file

@ -264,8 +264,8 @@ void vulkan_setup(MwWidget handle) {
swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh}, swapchainCreateInfo.imageExtent = (VkExtent2D){.width = ow, .height = oh},
swapchainCreateInfo.imageArrayLayers = 1, swapchainCreateInfo.imageArrayLayers = 1,
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT; VK_IMAGE_USAGE_SAMPLED_BIT;
// th is how we specify no transformation. // th is how we specify no transformation.
swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; swapchainCreateInfo.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;

View file

@ -21,8 +21,6 @@ class MwWindow;
class MwApplication : public BApplication { class MwApplication : public BApplication {
public: public:
MwWindow* window;
MwApplication(MwRect rc, MwLL handle); MwApplication(MwRect rc, MwLL handle);
~MwApplication(); ~MwApplication();
@ -70,6 +68,7 @@ typedef BBitmap MwBBitmap;
#else #else
typedef void MwApplication; typedef void MwApplication;
typedef void MwView; typedef void MwView;
typedef void MwWindow;
typedef void MwBBitmap; typedef void MwBBitmap;
#endif #endif
@ -91,11 +90,14 @@ enum BVIEW_MW_WHAT {
BVIEW_MW_LINE, BVIEW_MW_LINE,
BVIEW_MW_BITMAP, BVIEW_MW_BITMAP,
BVIEW_MW_RENDER, BVIEW_MW_RENDER,
BVIEW_MW_RAISE,
BVIEW_MW_GET_MOUSE BVIEW_MW_GET_MOUSE
}; };
enum BWIN_MW_WHAT { enum BWIN_MW_WHAT {
BWIN_MW_SET_TITLE = 0 BWIN_MW_DESTROY = 0,
BWIN_MW_SET_TITLE,
BWIN_MW_SET_TYPE
}; };
enum MwLLHAIKU_EVENT { enum MwLLHAIKU_EVENT {
@ -135,6 +137,8 @@ union _MwLLHaikuEvent {
struct _MwLLHaiku { struct _MwLLHaiku {
struct _MwLLCommon common; struct _MwLLCommon common;
int type;
int x; int x;
int y; int y;
int width; int width;
@ -142,6 +146,7 @@ struct _MwLLHaiku {
MwLL parent; MwLL parent;
MwApplication* app; MwApplication* app;
MwWindow* window;
MwView* view; MwView* view;
thread_id app_thread; thread_id app_thread;
int force_render; int force_render;

View file

@ -19,18 +19,17 @@ MwApplication::MwApplication(MwRect rc, MwLL handle)
rc2 = BRect(rc.x, rc.y, rc.x + rc.width - 1, rc.y + rc.height - 1); rc2 = BRect(rc.x, rc.y, rc.x + rc.width - 1, rc.y + rc.height - 1);
this->window = new MwWindow(rc2, B_TITLED_WINDOW, 0); handle->haiku.window = new MwWindow(rc2, B_TITLED_WINDOW, 0);
this->window->Show(); handle->haiku.window->Show();
handle->haiku.view = new MwView(handle, this->window->Bounds(), B_FOLLOW_ALL_SIDES, B_WILL_DRAW); handle->haiku.view = new MwView(handle, handle->haiku.window->Bounds(), B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
this->window->AddChild(handle->haiku.view); handle->haiku.window->AddChild(handle->haiku.view);
delete scr; delete scr;
} }
MwApplication::~MwApplication() { MwApplication::~MwApplication() {
delete this->window;
} }
void MwApplication::MessageReceived(BMessage* message) { void MwApplication::MessageReceived(BMessage* message) {
@ -76,7 +75,35 @@ void MwView::MessageReceived(BMessage* message) {
} }
case BVIEW_MW_DETACH: case BVIEW_MW_DETACH:
{ {
this->RemoveSelf(); BRect rc;
BPoint point;
if(message->FindPoint("view-point", &point) != B_OK) break;
point = this->ConvertToScreen(this->ConvertFromParent(point));
rc.left = point.x;
rc.top = point.y;
rc.right = rc.left + this->handle->haiku.width - 1;
rc.bottom = rc.top + this->handle->haiku.height - 1;
if(this->Parent() != NULL) {
this->RemoveSelf();
}
this->handle->haiku.parent = NULL;
this->handle->haiku.window = new MwWindow(rc, B_TITLED_WINDOW, 0);
this->handle->haiku.window->Show();
this->MoveTo(0, 0);
this->ResizeTo(this->handle->haiku.width, this->handle->haiku.height);
this->SetResizingMode(B_FOLLOW_ALL_SIDES);
this->handle->haiku.window->AddChild(this);
while(this->Window() != this->handle->haiku.window);
MwLLForceRender(this->handle);
break; break;
} }
case BVIEW_MW_RESIZE: case BVIEW_MW_RESIZE:
@ -86,10 +113,10 @@ void MwView::MessageReceived(BMessage* message) {
if(message->FindInt32("view-width", &width) != B_OK) break; if(message->FindInt32("view-width", &width) != B_OK) break;
if(message->FindInt32("view-height", &height) != B_OK) break; if(message->FindInt32("view-height", &height) != B_OK) break;
if(this->handle->haiku.app == NULL) { if(this->handle->haiku.window == NULL) {
this->ResizeTo(width - 1, height - 1); this->ResizeTo(width - 1, height - 1);
} else { } else {
this->Window()->ResizeTo(width - 1, height - 1); this->handle->haiku.window->ResizeTo(width - 1, height - 1);
this->ResizeTo(width - 1, height - 1); this->ResizeTo(width - 1, height - 1);
} }
this->Draw(BRect(0, 0, 0, 0)); this->Draw(BRect(0, 0, 0, 0));
@ -178,6 +205,14 @@ void MwView::MessageReceived(BMessage* message) {
this->Invalidate(); this->Invalidate();
break; break;
} }
case BVIEW_MW_RAISE:
{
BView* v = this->Parent();
this->RemoveSelf();
v->AddChild(this);
break;
}
case BVIEW_MW_GET_MOUSE: case BVIEW_MW_GET_MOUSE:
{ {
BPoint* p; BPoint* p;
@ -205,7 +240,7 @@ void MwView::PostMessage(BMessage* message) {
copy.AddPointer("window-view", this); copy.AddPointer("window-view", this);
top->haiku.app->window->PostMessage(&copy); top->haiku.window->PostMessage(&copy);
} }
void MwView::PostMessage(uint32 command) { void MwView::PostMessage(uint32 command) {
@ -223,7 +258,7 @@ status_t MwView::SendMessage(BMessage* message) {
copy.AddPointer("window-view", this); copy.AddPointer("window-view", this);
return BMessenger(top->haiku.app->window).SendMessage(&copy, &reply); return BMessenger(top->haiku.window).SendMessage(&copy, &reply);
} }
status_t MwView::SendMessage(uint32 command) { status_t MwView::SendMessage(uint32 command) {
@ -355,6 +390,12 @@ void MwWindow::MessageReceived(BMessage* message) {
} }
switch(message->what) { switch(message->what) {
case BVIEW_MW_DESTROY:
{
this->Quit();
delete this;
break;
}
case BWIN_MW_SET_TITLE: case BWIN_MW_SET_TITLE:
{ {
const char* title; const char* title;
@ -364,6 +405,19 @@ void MwWindow::MessageReceived(BMessage* message) {
this->SetTitle(title); this->SetTitle(title);
break; break;
} }
case BWIN_MW_SET_TYPE:
{
int type;
if(message->FindInt32("window-type", &type) != B_OK) break;
this->SetType((window_type)type);
if(type == B_UNTYPED_WINDOW) {
this->SetLook(B_NO_BORDER_WINDOW_LOOK);
}
break;
}
default: default:
{ {
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
@ -443,23 +497,27 @@ MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
p->rc = mrc; p->rc = mrc;
p->handle = r; p->handle = r;
r->haiku.app = NULL; r->haiku.app = NULL;
r->haiku.view = NULL; r->haiku.window = NULL;
r->haiku.view = NULL;
r->haiku.app_thread = spawn_thread(app_thread, NULL, B_NORMAL_PRIORITY, p); r->haiku.app_thread = spawn_thread(app_thread, NULL, B_NORMAL_PRIORITY, p);
resume_thread(r->haiku.app_thread); resume_thread(r->haiku.app_thread);
while(r->haiku.app == NULL || r->haiku.app->window == NULL || r->haiku.view == NULL) MwTimeSleep(10); while(r->haiku.app == NULL || r->haiku.window == NULL || r->haiku.view == NULL) MwTimeSleep(10);
} else { } else {
MwLL top = r; MwLL top = r;
while(top->haiku.parent != NULL) { while(top->haiku.parent != NULL) {
top = top->haiku.parent; top = top->haiku.parent;
} }
r->haiku.app = NULL; r->haiku.app = NULL;
r->haiku.view = new MwView(r, rc, B_FOLLOW_NONE, B_WILL_DRAW); r->haiku.window = NULL;
r->haiku.view = new MwView(r, rc, B_FOLLOW_NONE, B_WILL_DRAW);
parent->haiku.view->AddChild(r->haiku.view); parent->haiku.view->AddChild(r->haiku.view);
r->haiku.view->SendMessage(BVIEW_MW_RAISE);
} }
r->haiku.x = x; r->haiku.x = x;
@ -482,6 +540,8 @@ void MwLLDestroyImpl(MwLL handle) {
wait_for_thread(handle->haiku.app_thread, &exit_value); wait_for_thread(handle->haiku.app_thread, &exit_value);
delete handle->haiku.app; delete handle->haiku.app;
} else if(handle->haiku.window != NULL) {
handle->haiku.window->PostMessage(BWIN_MW_DESTROY);
} }
free(handle); free(handle);
@ -579,7 +639,7 @@ void MwLLSetTitleImpl(MwLL handle, const char* title) {
msg.AddString("window-title", title); msg.AddString("window-title", title);
handle->haiku.app->window->PostMessage(&msg); handle->haiku.window->PostMessage(&msg);
} }
int MwLLPendingImpl(MwLL handle) { int MwLLPendingImpl(MwLL handle) {
@ -699,7 +759,15 @@ void MwLLForceRenderImpl(MwLL handle) {
void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {} void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {}
void MwLLDetachImpl(MwLL handle, MwPoint* point) {} void MwLLDetachImpl(MwLL handle, MwPoint* point) {
BMessage msg(BVIEW_MW_DETACH);
msg.AddPoint("view-point", BPoint(point->x, point->y));
handle->haiku.view->PostMessage(&msg);
while(handle->haiku.window == NULL);
}
void MwLLShowImpl(MwLL handle, int show) { void MwLLShowImpl(MwLL handle, int show) {
if(show) { if(show) {
@ -713,13 +781,23 @@ void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {} void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {}
void MwLLMakeToolWindowImpl(MwLL handle) {} void MwLLMakeToolWindowImpl(MwLL handle) {
handle->haiku.type = B_UNTYPED_WINDOW;
}
void MwLLMakePopupImpl(MwLL handle, MwLL parent) {} void MwLLMakePopupImpl(MwLL handle, MwLL parent) {}
void MwLLBeginStateChangeImpl(MwLL handle) {} void MwLLBeginStateChangeImpl(MwLL handle) {
handle->haiku.type = handle->haiku.window == NULL ? B_TITLED_WINDOW : handle->haiku.window->Type();
}
void MwLLEndStateChangeImpl(MwLL handle) {} void MwLLEndStateChangeImpl(MwLL handle) {
BMessage msg(BWIN_MW_SET_TYPE);
msg.AddInt32("window-type", handle->haiku.type);
BMessenger(handle->haiku.window).SendMessage(&msg);
}
void MwLLFocusImpl(MwLL handle) {} void MwLLFocusImpl(MwLL handle) {}
@ -766,7 +844,7 @@ MwBool MwLLDoModernImpl(MwLL handle) {
} }
static void MwLLRaiseImpl(MwLL handle) { static void MwLLRaiseImpl(MwLL handle) {
(void)handle; handle->haiku.view->SendMessage(BVIEW_MW_RAISE);
} }
int MwLLHaikuCallInitImpl() { int MwLLHaikuCallInitImpl() {

View file

@ -10,16 +10,16 @@ static int wcreate(MwWidget handle) {
} }
static void draw(MwWidget handle) { static void draw(MwWidget handle) {
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground)); MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor cb = MwParseColor(handle, "#fff"); MwLLColor cb = MwParseColor(handle, "#fff");
MwLLColor cb_g = MwParseColor(handle, "#666"); MwLLColor cb_g = MwParseColor(handle, "#666");
MwLLColor ct = MwParseColor(handle, "#000"); MwLLColor ct = MwParseColor(handle, "#000");
MwRect r, r2, r3; MwRect r, r2, r3;
MwPoint p[4]; MwPoint p[4];
int h = 64; int h = 64;
int pw = h / 16; /* parallelogram width */ int pw = h / 16; /* parallelogram width */
int ph = pw * 3; /* parallelogram height */ int ph = pw * 3; /* parallelogram height */
int gh = h / 32; /* gray area height */ int gh = h / 32; /* gray area height */
char buf[3]; char buf[3];
r.x = 0; r.x = 0;
@ -34,9 +34,9 @@ static void draw(MwWidget handle) {
r2.y = (r.height - r2.height - ph - gh) / 2; r2.y = (r.height - r2.height - ph - gh) / 2;
MwDrawRect(handle, &r2, cb); MwDrawRect(handle, &r2, cb);
r3.x = r2.x; r3.x = r2.x;
r3.y = r2.y + r2.height; r3.y = r2.y + r2.height;
r3.width = r2.width; r3.width = r2.width;
r3.height = ph + gh; r3.height = ph + gh;
MwDrawRect(handle, &r3, cb_g); MwDrawRect(handle, &r3, cb_g);

View file

@ -420,8 +420,8 @@ static void redrawIfNeeded(MwWidget handle, int row) {
static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text) { static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text) {
MwListBox lb = handle->internal; MwListBox lb = handle->internal;
MwListBoxEntry entry; MwListBoxEntry entry;
char* t = text == NULL ? NULL : MwStringDuplicate(text); char* t = text == NULL ? NULL : MwStringDuplicate(text);
int new = 0; int new = 0;
if(row == -1) row = arrlen(lb->list); if(row == -1) row = arrlen(lb->list);
entry.name = NULL; entry.name = NULL;
@ -449,7 +449,7 @@ static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text)
static void mwListBoxSetIconImpl(MwWidget handle, int index, MwLLPixmap icon) { static void mwListBoxSetIconImpl(MwWidget handle, int index, MwLLPixmap icon) {
MwListBox lb = handle->internal; MwListBox lb = handle->internal;
MwListBoxEntry entry; MwListBoxEntry entry;
int new = 0; int new = 0;
if(index == -1) index = arrlen(lb->list); if(index == -1) index = arrlen(lb->list);
entry.name = NULL; entry.name = NULL;

View file

@ -58,9 +58,9 @@ static void draw(MwWidget handle) {
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64); MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
MwScrollBar scr = handle->internal; MwScrollBar scr = handle->internal;
int or ; int or;
int uy, dy, ux, dx; int uy, dy, ux, dx;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap); MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0; r.x = 0;
r.y = 0; r.y = 0;