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);
SetCapture(hWnd);
SetFocus(hWnd);
MwLLDispatch(u->ll, down, &p);
} else if(msg == WM_LBUTTONUP) {
MwPoint p;
@@ -71,6 +72,10 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
PostQuitMessage(0);
} else if(msg == WM_CLOSE) {
DestroyWindow(hWnd);
} else if(msg == WM_CHAR) {
int n = wp;
MwLLDispatch(u->ll, key, &n);
} else {
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);
}
void MwLLShow(MwLL handle, int show) {
ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE);
if(show) SetFocus(handle->hWnd);
}

View File

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

View File

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