Skip to content

Commit

Permalink
device: add --hidden CLI option
Browse files Browse the repository at this point in the history
Part-of: #162
  • Loading branch information
dbartolini committed Jan 27, 2024
1 parent 666fa2b commit 41162c2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changelog
**Runtime**

* Fixed intra-frame button press/release detection.
* Added ``--hidden`` CLI option.

**Tools**

Expand Down
3 changes: 3 additions & 0 deletions src/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ void Device::run()
_window->set_title(_boot_config.window_title.c_str());
_window->set_fullscreen(_boot_config.fullscreen);

if (!_options._hidden)
_window->show();

_bgfx_allocator = CE_NEW(_allocator, BgfxAllocator)(default_allocator());
_bgfx_callback = CE_NEW(_allocator, BgfxCallback)();

Expand Down
3 changes: 3 additions & 0 deletions src/device/device_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void help(const char *msg = NULL)
" --parent-window <handle> Set the parent window <handle> of the main window.\n"
" --server Run the engine in server mode.\n"
" --pumped Do not advance the renderer unless explicitly requested via console.\n"
" --hidden Make the main window initially invisible.\n"
" --window-rect <x y w h> Sets the main window's position and size.\n"
"\n"
"Complete documentation available at https://docs.crownengine.org/html/v" CROWN_VERSION "\n"
Expand All @@ -72,6 +73,7 @@ DeviceOptions::DeviceOptions(Allocator &a, int argc, const char **argv)
, _do_bundle(false)
, _server(false)
, _pumped(false)
, _hidden(false)
, _parent_window(0)
, _console_port(CROWN_DEFAULT_CONSOLE_PORT)
, _window_x(0)
Expand Down Expand Up @@ -155,6 +157,7 @@ int DeviceOptions::parse(bool *quit)
}

_pumped = cl.has_option("pumped");
_hidden = cl.has_option("hidden");

if (!_data_dir.value().empty()) {
if (!path::is_absolute(_data_dir.value().c_str())) {
Expand Down
1 change: 1 addition & 0 deletions src/device/device_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct DeviceOptions
Option<bool> _do_bundle;
Option<bool> _server;
Option<bool> _pumped;
Option<bool> _hidden;
Option<u32> _parent_window;
Option<u16> _console_port;
Option<u16> _window_x;
Expand Down
2 changes: 0 additions & 2 deletions src/device/main_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,6 @@ struct WindowX11 : public Window
CE_ASSERT(s_linux_device->_x11_window != None, "XCreateWindow: error");

XSetWMProtocols(s_linux_device->_x11_display, s_linux_device->_x11_window, &s_linux_device->_wm_delete_window, 1);

XMapRaised(s_linux_device->_x11_display, s_linux_device->_x11_window);
}

void close() override
Expand Down
2 changes: 1 addition & 1 deletion src/device/main_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ struct WindowsDevice
wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassExA(&wnd);

DWORD style = WS_VISIBLE;
DWORD style = 0;
DWORD exstyle = 0;
if (_options->_parent_window == 0) {
style |= WS_OVERLAPPEDWINDOW;
Expand Down

0 comments on commit 41162c2

Please sign in to comment.