Skip to content

Commit

Permalink
expose new API to render the display at the bottom (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyGharbi authored Oct 11, 2022
1 parent 9de3f82 commit dce8b75
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Napi::Value createWindowJS(const Napi::CallbackInfo& info)
std::string name = info[0].ToString().Utf8Value();
Napi::Buffer<void *> bufferData = info[1].As<Napi::Buffer<void*>>();

window->createWindow(name, bufferData.Data());
bool renderAtBottom = false;
if(info.Length() > 2)
renderAtBottom = info[2].ToBoolean().Value();

window->createWindow(name, bufferData.Data(), renderAtBottom);
return info.Env().Undefined();
}

Expand Down
4 changes: 2 additions & 2 deletions src/window-osx-int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ WindowInt::~WindowInt(void)
if (_impl) { delete _impl; _impl = nullptr; }
}

void WindowInt::createWindow(std::string name, void **handle)
void WindowInt::createWindow(std::string name, void **handle, bool renderAtBottom)
{
_impl->createWindow(name, handle);
_impl->createWindow(name, handle, renderAtBottom);
}

void WindowInt::destroyWindow(std::string name)
Expand Down
2 changes: 1 addition & 1 deletion src/window-osx-int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WindowInt
~WindowInt(void);

void init(void);
void createWindow(std::string name, void **handle);
void createWindow(std::string name, void **handle, bool renderAtBottom);
void destroyWindow(std::string name);
void connectIOSurfaceJS(std::string name, uint32_t surfaceID);
void destroyIOSurface(std::string name);
Expand Down
2 changes: 1 addition & 1 deletion src/window-osx-obj-c-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class WindowObjCInt
~WindowObjCInt(void);

void init(void);
void createWindow(std::string name, void **handle);
void createWindow(std::string name, void **handle, bool renderAtBottom);
void destroyWindow(std::string name);
void connectIOSurfaceJS(std::string name, uint32_t surfaceID);
void destroyIOSurface(std::string name);
Expand Down
14 changes: 11 additions & 3 deletions src/window-osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ @implementation WindowImplObj
self = [[WindowImplObj alloc] init];
}

void WindowObjCInt::createWindow(std::string name, void **handle)
void WindowObjCInt::createWindow(std::string name, void **handle, bool renderAtBottom)
{
WindowInfo* wi = new WindowInfo();

Expand All @@ -401,10 +401,18 @@ @implementation WindowImplObj
];
[winParent addChildWindow:wi->window ordered:NSWindowAbove];
wi->window.ignoresMouseEvents = true;
[wi->window.contentView addSubview:wi->view];

if (renderAtBottom)
[wi->window.contentView addSubview:wi->view];
else
[wi->window.contentView addSubview:wi->view positioned:NSWindowBelow relativeTo:nil];
} else {
[winParent.contentView addSubview:wi->view];
if (renderAtBottom)
[winParent.contentView addSubview:wi->view positioned:NSWindowBelow relativeTo:nil];
else
[winParent.contentView addSubview:wi->view];
}

windows.emplace(name, wi);
}

Expand Down

0 comments on commit dce8b75

Please sign in to comment.