Skip to content

Commit

Permalink
Only use borderless fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Jan 7, 2025
1 parent 858e402 commit 7446f8c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ void kinc_g4_internal_init_window(int windowId, int depthBufferBits, int stencil

kinc_microsoft_affirm(dx_ctx.dxgiFactory->lpVtbl->CreateSwapChain(dx_ctx.dxgiFactory, (IUnknown *)dx_ctx.dxgiDevice, &swapChainDesc, &window->swapChain));

{
// Prevent exclusive-fullscreen and handle alt+enter manually
dx_ctx.dxgiFactory->lpVtbl->MakeWindowAssociation(dx_ctx.dxgiFactory, window->hwnd, DXGI_MWA_NO_ALT_ENTER);
}

createBackbuffer(window, kinc_g4_antialiasing_samples());
currentRenderTargetViews[0] = window->renderTargetView;
currentDepthStencilView = window->depthStencilView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,12 @@ void kinc_wayland_window_change_mode(int window_index, kinc_window_mode_t mode)
}
switch (mode) {
case KINC_WINDOW_MODE_WINDOW:
if (window->mode == KINC_WINDOW_MODE_FULLSCREEN || window->mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
if (window->mode == KINC_WINDOW_MODE_FULLSCREEN) {
window->mode = KINC_WINDOW_MODE_WINDOW;
xdg_toplevel_unset_fullscreen(window->toplevel);
}
break;
case KINC_WINDOW_MODE_FULLSCREEN:
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
if (window->mode == KINC_WINDOW_MODE_WINDOW) {
window->mode = mode;
struct kinc_wl_display *display = &wl_ctx.displays[window->display_index];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ void kinc_x11_window_change_mode(int window_index, kinc_window_mode_t mode) {
}
break;
case KINC_WINDOW_MODE_FULLSCREEN:
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
if (window->mode == KINC_WINDOW_MODE_WINDOW) {
window->mode = KINC_WINDOW_MODE_FULLSCREEN;
fullscreen = true;
Expand Down
3 changes: 1 addition & 2 deletions armorcore/sources/backends/macos/kinc/backend/system.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static int createWindow(kinc_window_options_t *options) {

[window makeKeyAndOrderFront:nil];

if (options->mode == KINC_WINDOW_MODE_FULLSCREEN || options->mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
if (options->mode == KINC_WINDOW_MODE_FULLSCREEN) {
[window toggleFullScreen:nil];
windows[windowCounter].fullscreen = true;
}
Expand All @@ -144,7 +144,6 @@ void kinc_window_change_window_mode(int window_index, kinc_window_mode_t mode) {
}
break;
case KINC_WINDOW_MODE_FULLSCREEN:
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
if (!windows[window_index].fullscreen) {
[window toggleFullScreen:nil];
windows[window_index].fullscreen = true;
Expand Down
4 changes: 2 additions & 2 deletions armorcore/sources/backends/wasm/kinc/backend/window.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void kinc_window_change_features(int window_index, int features) {}

// In HTML5 fullscreen is activable only from user input.
void kinc_window_change_mode(int window_index, kinc_window_mode_t mode) {
if (mode == KINC_WINDOW_MODE_FULLSCREEN || mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
if (kinc_internal_window_mode == KINC_WINDOW_MODE_FULLSCREEN || kinc_internal_window_mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
if (mode == KINC_WINDOW_MODE_FULLSCREEN) {
if (kinc_internal_window_mode == KINC_WINDOW_MODE_FULLSCREEN) {
kinc_internal_window_mode = mode;
return;
}
Expand Down
2 changes: 0 additions & 2 deletions armorcore/sources/backends/windows/kinc/backend/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ static wchar_t toUnicode(WPARAM wParam, LPARAM lParam) {
return buffer[0];
}

#if !defined(KINC_DIRECT3D9) && !defined(KINC_DIRECT3D11) && !defined(KINC_DIRECT3D12)
#define HANDLE_ALT_ENTER
#endif

static bool cursors_initialized = false;
static int cursor = 0;
Expand Down
30 changes: 3 additions & 27 deletions armorcore/sources/backends/windows/kinc/backend/window.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ int kinc_window_height(int window_index) {

static DWORD getDwStyle(kinc_window_mode_t mode, int features) {
switch (mode) {
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN: {
return WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP;
}
case KINC_WINDOW_MODE_FULLSCREEN:
return WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP;
case KINC_WINDOW_MODE_WINDOW:
Expand All @@ -168,9 +165,6 @@ static DWORD getDwStyle(kinc_window_mode_t mode, int features) {

static DWORD getDwExStyle(kinc_window_mode_t mode, int features) {
switch (mode) {
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN: {
return WS_EX_APPWINDOW;
}
case KINC_WINDOW_MODE_FULLSCREEN:
return WS_EX_APPWINDOW;
case KINC_WINDOW_MODE_WINDOW:
Expand All @@ -195,10 +189,6 @@ static int createWindow(const wchar_t *title, int x, int y, int width, int heigh
WindowRect.top = 0;
WindowRect.bottom = height;

if (windowMode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
kinc_windows_set_display_mode(display_index, width, height, bpp, frequency);
}

AdjustWindowRectEx(&WindowRect, getDwStyle(windowMode, features), FALSE, getDwExStyle(windowMode, features));

kinc_display_mode_t display_mode = kinc_display_current_mode(display_index);
Expand All @@ -219,8 +209,6 @@ static int createWindow(const wchar_t *title, int x, int y, int width, int heigh
dstw = display_mode.width;
dsth = display_mode.height;
break;
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
break;
}

HWND hwnd = CreateWindowExW(getDwExStyle(windowMode, features), windowClassName, title, getDwStyle(windowMode, features), dstx, dsty, dstw, dsth, NULL, NULL,
Expand Down Expand Up @@ -259,13 +247,6 @@ void kinc_window_resize(int window_index, int width, int height) {
SetWindowPos(win->handle, NULL, kinc_window_x(window_index), kinc_window_y(window_index), rect.right - rect.left, rect.bottom - rect.top, 0);
break;
}
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN: {
int display_index = kinc_window_display(window_index);
kinc_display_mode_t display_mode = kinc_display_current_mode(display_index);
kinc_windows_set_display_mode(display_index, width, height, win->bpp, win->frequency);
SetWindowPos(win->handle, NULL, display_mode.x, display_mode.y, display_mode.width, display_mode.height, 0);
break;
}
}
}

Expand Down Expand Up @@ -312,11 +293,12 @@ void kinc_window_change_mode(int window_index, kinc_window_mode_t mode) {
int display_index = kinc_window_display(window_index);
kinc_display_mode_t display_mode = kinc_display_current_mode(display_index);
switch (mode) {
case KINC_WINDOW_MODE_WINDOW:
case KINC_WINDOW_MODE_WINDOW: {
kinc_windows_restore_display(display_index);
kinc_window_change_features(window_index, win->features);
kinc_window_show(window_index);
break;
}
case KINC_WINDOW_MODE_FULLSCREEN: {
kinc_windows_restore_display(display_index);
SetWindowLongW(win->handle, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP);
Expand All @@ -325,15 +307,9 @@ void kinc_window_change_mode(int window_index, kinc_window_mode_t mode) {
kinc_window_show(window_index);
break;
}
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
kinc_windows_set_display_mode(display_index, win->manualWidth, win->manualHeight, win->bpp, win->frequency);
SetWindowLongW(win->handle, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP);
SetWindowLongW(win->handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
SetWindowPos(win->handle, NULL, display_mode.x, display_mode.y, display_mode.width, display_mode.height, 0);
kinc_window_show(window_index);
break;
}
win->mode = mode;
DragAcceptFiles(win->handle, true);
}

kinc_window_mode_t kinc_window_get_mode(int window_index) {
Expand Down
3 changes: 1 addition & 2 deletions armorcore/sources/kinc/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ typedef struct kinc_framebuffer_options {

typedef enum {
KINC_WINDOW_MODE_WINDOW,
KINC_WINDOW_MODE_FULLSCREEN,
KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN // Only relevant for Windows
KINC_WINDOW_MODE_FULLSCREEN
} kinc_window_mode_t;

#define KINC_WINDOW_FEATURE_RESIZEABLE 1
Expand Down

0 comments on commit 7446f8c

Please sign in to comment.