Skip to content

Commit

Permalink
Merge branch 'main' of ssh://github.com/Kode/Kinc
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 15, 2023
2 parents ff3d281 + 54d2b01 commit 9363790
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ static bool cmd = false;
static int getMouseX(NSEvent *event) {
// TODO (DK) map [theEvent window] to window id instead of 0
NSWindow *window = [[NSApplication sharedApplication] mainWindow];
return (int)([event locationInWindow].x);
float scale = [window backingScaleFactor];
return (int)([event locationInWindow].x * scale);
}

static int getMouseY(NSEvent *event) {
// TODO (DK) map [theEvent window] to window id instead of 0
NSWindow *window = [[NSApplication sharedApplication] mainWindow];
return (int)(kinc_height() - [event locationInWindow].y);
float scale = [window backingScaleFactor];
return (int)(kinc_height() - [event locationInWindow].y * scale);
}

static bool controlKeyMouseButton = false;
Expand Down
10 changes: 6 additions & 4 deletions Backends/System/macOS/Sources/kinc/backend/system.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void swapBuffersMac(int windowId) {
}

static int createWindow(kinc_window_options_t *options) {
int width = options->width;
int height = options->height;
int width = options->width / [[NSScreen mainScreen] backingScaleFactor];
int height = options->height / [[NSScreen mainScreen] backingScaleFactor];
int styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable;
if ((options->window_features & KINC_WINDOW_FEATURE_RESIZEABLE) || (options->window_features & KINC_WINDOW_FEATURE_MAXIMIZABLE)) {
styleMask |= NSWindowStyleMaskResizable;
Expand Down Expand Up @@ -213,12 +213,14 @@ int kinc_init(const char *name, int width, int height, kinc_window_options_t *wi

int kinc_window_width(int window_index) {
NSWindow *window = windows[window_index].handle;
return [[window contentView] frame].size.width;
float scale = [window backingScaleFactor];
return [[window contentView] frame].size.width * scale;
}

int kinc_window_height(int window_index) {
NSWindow *window = windows[window_index].handle;
return [[window contentView] frame].size.height;
float scale = [window backingScaleFactor];
return [[window contentView] frame].size.height * scale;
}

NSWindow *kinc_get_mac_window_handle(int window_index) {
Expand Down
2 changes: 1 addition & 1 deletion Tools/freebsd_x64
Submodule freebsd_x64 updated 1 files
+ kmake
2 changes: 1 addition & 1 deletion Tools/linux_arm
Submodule linux_arm updated 1 files
+ kmake
2 changes: 1 addition & 1 deletion Tools/linux_arm64
Submodule linux_arm64 updated 1 files
+ kmake
2 changes: 1 addition & 1 deletion Tools/linux_x64
Submodule linux_x64 updated 1 files
+ kmake
2 changes: 1 addition & 1 deletion Tools/macos
Submodule macos updated 1 files
+ kmake
2 changes: 1 addition & 1 deletion Tools/windows_x64
Submodule windows_x64 updated 1 files
+ kmake.exe

0 comments on commit 9363790

Please sign in to comment.