fix some broken stuff

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@232 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-08 18:13:13 +00:00
parent 7b0173e7c4
commit 9d2b51402d
3 changed files with 25 additions and 8 deletions

View File

@@ -46,6 +46,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
p.y = HIWORD(lp); p.y = HIWORD(lp);
SetCapture(hWnd); SetCapture(hWnd);
SetFocus(hWnd);
MwLLDispatch(u->ll, down, &p); MwLLDispatch(u->ll, down, &p);
} else if(msg == WM_LBUTTONUP) { } else if(msg == WM_LBUTTONUP) {
MwPoint p; MwPoint p;
@@ -71,6 +72,10 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
PostQuitMessage(0); PostQuitMessage(0);
} else if(msg == WM_CLOSE) { } else if(msg == WM_CLOSE) {
DestroyWindow(hWnd); DestroyWindow(hWnd);
} else if(msg == WM_CHAR) {
int n = wp;
MwLLDispatch(u->ll, key, &n);
} else { } else {
return (u->old == NULL) ? DefWindowProc(hWnd, msg, wp, lp) : CallWindowProc(u->old, hWnd, msg, wp, lp); return (u->old == NULL) ? DefWindowProc(hWnd, msg, wp, lp) : CallWindowProc(u->old, hWnd, msg, wp, lp);
} }
@@ -389,3 +394,8 @@ void MwLLDetach(MwLL handle, MwPoint* point) {
SetWindowLongPtr(handle->hWnd, GWL_STYLE, style); SetWindowLongPtr(handle->hWnd, GWL_STYLE, style);
} }
void MwLLShow(MwLL handle, int show) {
ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE);
if(show) SetFocus(handle->hWnd);
}

View File

@@ -185,6 +185,8 @@ void MwLLNextEvent(MwLL handle) {
int n; int n;
KeySym sym = XLookupKeysym(&ev.xkey, 0); KeySym sym = XLookupKeysym(&ev.xkey, 0);
char* str = XKeysymToString(sym); char* str = XKeysymToString(sym);
/* HACK: this is bad, you can guess why */
if(strlen(str) == 1) {
char s = str == NULL ? 0 : str[0]; char s = str == NULL ? 0 : str[0];
if(ev.xkey.state & (ShiftMask | LockMask)) { if(ev.xkey.state & (ShiftMask | LockMask)) {
@@ -195,6 +197,7 @@ void MwLLNextEvent(MwLL handle) {
MwLLDispatch(handle, key, &n); MwLLDispatch(handle, key, &n);
} }
}
if(render) { if(render) {
int x, y; int x, y;
unsigned int w, h; unsigned int w, h;

View File

@@ -24,6 +24,10 @@ static void draw(MwWidget handle) {
MwLLFreeColor(base); MwLLFreeColor(base);
} }
static void key(MwWidget handle, int code) {
printf("%c\n", code);
}
MwClassRec MwTextClassRec = { MwClassRec MwTextClassRec = {
create, /* create */ create, /* create */
NULL, /* destroy */ NULL, /* destroy */
@@ -34,7 +38,7 @@ MwClassRec MwTextClassRec = {
NULL, /* mouse_move */ NULL, /* mouse_move */
MwForceRender, /* mouse_up */ MwForceRender, /* mouse_up */
MwForceRender, /* mouse_down */ MwForceRender, /* mouse_down */
NULL, /* key */ key, /* key */
NULL, NULL,
NULL, NULL,
NULL, NULL,