Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Windows): ensure WS_CAPTION is set on undecorated windows #862

Merged
merged 5 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Core/App.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let quit = (~askNicely=false, ~code=0, app: t) => {
};

if (Hashtbl.length(app.windows) == 0 || !askNicely) {
Revery_Native.uninit();
Revery_Native.uninitApp();

// Verify [quit] wasn't called recursively from a beforeQuit handler
if (!app.isQuitting) {
Expand Down Expand Up @@ -253,7 +253,7 @@ let start = init => {
let dispatchFileOpen = Event.dispatch(appInstance.onFileOpen);
Callback.register("revery_dispatchFileOpen", dispatchFileOpen);

Revery_Native.init();
Revery_Native.initApp();

let appLoop = () => {
_flushEvents();
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Window.re
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ let create = (name: string, options: WindowCreateOptions.t) => {

Internal.updateMetrics(window);

Revery_Native.initWindow(sdlWindow);

window;
};

Expand Down
8 changes: 6 additions & 2 deletions src/Native/Initialization.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
external init: unit => unit = "revery_initialize";
external initApp: unit => unit = "revery_initializeApp";
external uninitApp: unit => unit = "revery_uninitializeApp";

external uninit: unit => unit = "revery_uninitialize";
external _initWindow: Sdl2.Window.nativeWindow => unit =
"revery_initializeWindow";
let initWindow = (w: Sdl2.Window.t) =>
_initWindow(w |> Sdl2.Window.getNativeWindow);
19 changes: 17 additions & 2 deletions src/Native/Revery_Native.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
#ifdef WIN32
#include "ReveryWin32.h"
#include <combaseapi.h>
#include <windows.h>
#elif __APPLE__
#include "ReveryCocoa.h"
#import "ReveryAppDelegate.h"
#else
#include "ReveryGtk.h"
#endif

CAMLprim value revery_initialize() {
CAMLprim value revery_initializeApp() {
#ifdef __APPLE__
SDLAppDelegate *sdlDelegate = [NSApp delegate];
ReveryAppDelegate *delegate = [ReveryAppDelegate newWithSDLDelegate:sdlDelegate];
Expand All @@ -32,9 +33,23 @@ CAMLprim value revery_initialize() {
return Val_unit;
}

CAMLprim value revery_uninitialize() {
CAMLprim value revery_uninitializeApp() {
#ifdef WIN32
CoUninitialize();
#endif
return Val_unit;
}


CAMLprim value revery_initializeWindow(value vWin) {
CAMLparam1(vWin);
void *win = (void *)vWin;
#ifdef WIN32
HWND window = (HWND)win;
int current_style = GetWindowLong(window, GWL_STYLE);
SetWindowLong(window, GWL_STYLE, current_style | WS_CAPTION);
Comment on lines +52 to +54
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#else
UNUSED(win);
#endif
CAMLreturn(Val_unit);
}