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

Add set window focus support to hldx/hlsdl #697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions libs/directx/dx/Window.hx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class Window {
winResize(win, 2);
}

public function focus() {
winSetFocus(win);
}

public function getNextEvent( e : Event ) : Bool {
return winGetNextEvent(win, e);
}
Expand Down Expand Up @@ -322,6 +326,10 @@ class Window {
static function winGetPosition( win : WinPtr, x : hl.Ref<Int>, y : hl.Ref<Int> ) {
}

@:hlNative("?directx", "win_set_focus")
static function winSetFocus( win: WinPtr ) {
}

static function winGetOpacity( win : WinPtr ) : Float {
return 0.0;
}
Expand Down
5 changes: 5 additions & 0 deletions libs/directx/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ HL_PRIM void HL_NAME(win_resize)(dx_window *win, int mode) {
}
}

HL_PRIM void HL_NAME(win_set_focus)(dx_window* win) {
SetFocus(win);
}

HL_PRIM void HL_NAME(win_set_fullscreen)(dx_window *win, bool fs) {
if( fs ) {
MONITORINFO mi = { sizeof(mi) };
Expand Down Expand Up @@ -916,6 +920,7 @@ DEFINE_PRIM(TWIN, win_create_ex, _I32 _I32 _I32 _I32 _I32);
DEFINE_PRIM(TWIN, win_create, _I32 _I32);
DEFINE_PRIM(_VOID, win_set_fullscreen, TWIN _BOOL);
DEFINE_PRIM(_VOID, win_resize, TWIN _I32);
DEFINE_PRIM(_VOID, win_set_focus, TWIN);
DEFINE_PRIM(_VOID, win_set_title, TWIN _BYTES);
DEFINE_PRIM(_VOID, win_set_size, TWIN _I32 _I32);
DEFINE_PRIM(_VOID, win_set_min_size, TWIN _I32 _I32);
Expand Down
5 changes: 5 additions & 0 deletions libs/sdl/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ HL_PRIM void HL_NAME(win_resize)(SDL_Window *win, int mode) {
}
}

HL_PRIM void HL_NAME(win_raise)(SDL_Window *win) {
SDL_RaiseWindow(win);
}


HL_PRIM void HL_NAME(win_swap_window)(SDL_Window *win) {
#if defined(HL_IOS) || defined(HL_TVOS)
Expand Down Expand Up @@ -723,6 +727,7 @@ DEFINE_PRIM(_BOOL, win_set_fullscreen, TWIN _I32);
DEFINE_PRIM(_BOOL, win_set_display_mode, TWIN _I32 _I32 _I32);
DEFINE_PRIM(_I32, win_display_handle, TWIN);
DEFINE_PRIM(_VOID, win_resize, TWIN _I32);
DEFINE_PRIM(_VOID, win_raise, TWIN);
DEFINE_PRIM(_VOID, win_set_title, TWIN _BYTES);
DEFINE_PRIM(_VOID, win_set_position, TWIN _I32 _I32);
DEFINE_PRIM(_VOID, win_get_position, TWIN _REF(_I32) _REF(_I32));
Expand Down
8 changes: 8 additions & 0 deletions libs/sdl/sdl/Window.hx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class Window {
setPosition(SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}

public function raise() {
winRaise( win );
}

public function warpMouse( x : Int, y : Int ) {
warpMouseInWindow(win, x, y);
}
Expand Down Expand Up @@ -369,6 +373,10 @@ class Window {
return 0.0;
}

@:hlNative("?sdl", "win_raise")
static function winRaise( win : WinPtr ) {
}

static function winSetOpacity( win : WinPtr, opacity : Float ) : Bool {
return false;
}
Expand Down
Loading