git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@403 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-17 19:44:55 +00:00
parent f9b061aac8
commit b608931b21
10 changed files with 79 additions and 80 deletions

View File

@@ -91,7 +91,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
p.x = LOWORD(lp);
p.y = HIWORD(lp);
if(u->ll->grabbed){
if(u->ll->grabbed) {
RECT rc;
GetClientRect(hWnd, &rc);
@@ -101,8 +101,8 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
MwLLDispatch(u->ll, move, &p);
if(u->ll->grabbed && (p.x != 0 || p.y != 0)){
RECT rc;
if(u->ll->grabbed && (p.x != 0 || p.y != 0)) {
RECT rc;
POINT p;
GetClientRect(hWnd, &rc);
@@ -130,9 +130,9 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
int n = wp;
MwLLDispatch(u->ll, key, &n);
}else if(msg == WM_SETFOCUS){
} else if(msg == WM_SETFOCUS) {
MwLLDispatch(u->ll, focus_in, NULL);
}else if(msg == WM_KILLFOCUS){
} else if(msg == WM_KILLFOCUS) {
MwLLDispatch(u->ll, focus_out, NULL);
} else if(msg == WM_KEYDOWN || msg == WM_KEYUP) {
int n = -1;
@@ -212,7 +212,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
RegisterClassEx(&wc);
r->grabbed = 0;
r->grabbed = 0;
r->copy_buffer = 1;
r->hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->hWnd, 0, wc.hInstance, NULL);
r->hInstance = wc.hInstance;
@@ -589,14 +589,14 @@ long MwLLGetTick(void) {
return GetTickCount();
}
void MwLLFocus(MwLL handle){
void MwLLFocus(MwLL handle) {
SetFocus(handle->hWnd);
}
void MwLLGrabPointer(MwLL handle, int toggle){
if(toggle){
void MwLLGrabPointer(MwLL handle, int toggle) {
if(toggle) {
POINT p;
RECT rc;
RECT rc;
GetClientRect(handle->hWnd, &rc);
@@ -616,7 +616,7 @@ void MwLLGrabPointer(MwLL handle, int toggle){
ClipCursor(&rc);
SetCursorPos(p.x, p.y);
}else{
} else {
handle->grabbed = 0;
ClipCursor(NULL);
}

View File

@@ -286,12 +286,12 @@ void MwLLNextEvent(MwLL handle) {
if(ev.xclient.data.l[0] == (long)handle->wm_delete) {
MwLLDispatch(handle, close, NULL);
}
} else if(ev.type == FocusIn){
} else if(ev.type == FocusIn) {
MwLLDispatch(handle, focus_in, NULL);
} else if(ev.type == FocusOut){
} else if(ev.type == FocusOut) {
MwLLDispatch(handle, focus_out, NULL);
} else if(ev.type == MotionNotify) {
MwPoint p;
MwPoint p;
XWindowAttributes attr;
XGetWindowAttributes(handle->display, handle->window, &attr);
@@ -299,13 +299,13 @@ void MwLLNextEvent(MwLL handle) {
p.x = ev.xmotion.x;
p.y = ev.xmotion.y;
if(handle->grabbed){
if(handle->grabbed) {
p.x -= attr.width / 2;
p.y -= attr.height / 2;
}
MwLLDispatch(handle, move, &p);
if(handle->grabbed && (p.x != 0 || p.y != 0)){
if(handle->grabbed && (p.x != 0 || p.y != 0)) {
XWarpPointer(handle->display, None, handle->window, 0, 0, 0, 0, attr.width / 2, attr.height / 2);
}
} else if(ev.type == KeyPress || ev.type == KeyRelease) {
@@ -343,13 +343,13 @@ void MwLLNextEvent(MwLL handle) {
n = MwLLKeyUp;
} else if(strcmp(str, "Down") == 0) {
n = MwLLKeyDown;
} else if(strcmp(str, "Return") == 0){
} else if(strcmp(str, "Return") == 0) {
n = MwLLKeyEnter;
} else if(strcmp(str, "Escape") == 0){
} else if(strcmp(str, "Escape") == 0) {
n = MwLLKeyEscape;
}else if(strcmp(str, "Shift_L") == 0){
} else if(strcmp(str, "Shift_L") == 0) {
n = MwLLKeyLeftShift;
}else if(strcmp(str, "Shift_R") == 0){
} else if(strcmp(str, "Shift_R") == 0) {
n = MwLLKeyRightShift;
}
@@ -690,20 +690,20 @@ long MwLLGetTick(void) {
return n;
}
void MwLLFocus(MwLL handle){
void MwLLFocus(MwLL handle) {
XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime);
}
void MwLLGrabPointer(MwLL handle, int toggle){
void MwLLGrabPointer(MwLL handle, int toggle) {
XWindowAttributes attr;
XGetWindowAttributes(handle->display, handle->window, &attr);
if(toggle){
if(toggle) {
handle->grabbed = 1;
XWarpPointer(handle->display, None, handle->window, 0, 0, 0, 0, attr.width / 2, attr.height / 2);
}else{
} else {
handle->grabbed = 0;
}
}