move some to lowlevel

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@675 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-11-12 18:37:07 +00:00
commit b617d147c3
7 changed files with 73 additions and 65 deletions

View file

@ -134,6 +134,8 @@ MWDECL void MwLLGrabPointer(MwLL handle, int toggle);
MWDECL void MwLLSetClipboard(MwLL handle, const char* text); MWDECL void MwLLSetClipboard(MwLL handle, const char* text);
MWDECL char* MwLLGetClipboard(MwLL handle); MWDECL char* MwLLGetClipboard(MwLL handle);
MWDECL void MwLLMakeToolWindow(MwLL handle);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -691,3 +691,10 @@ char* MwLLGetClipboard(MwLL handle) {
} }
return r; return r;
} }
void MwLLMakeToolWindow(MwLL handle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE) & WS_VISIBLE;
SetWindowLongPtr(handle->hWnd, GWL_STYLE, (LPARAM)lp);
SetWindowLongPtr(handle->hWnd, GWL_EXSTYLE, (LPARAM)WS_EX_TOOLWINDOW);
}

View file

@ -946,3 +946,14 @@ char* MwLLGetClipboard(MwLL handle) {
return r; return r;
} }
void MwLLMakeToolWindow(MwLL handle) {
XSetWindowAttributes xswa;
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
Atom wndmenu = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_MENU", False);
xswa.override_redirect = True;
XChangeWindowAttributes(handle->display, handle->window, CWOverrideRedirect, &xswa);
XChangeProperty(handle->display, handle->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
}

View file

@ -27,8 +27,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
MwCursor MwCursorArrow = { MwCursor MwCursorArrow = {
16, 16, -15, -15, 16, 16, -15, -15, {
{
0, /* ................ */ 0, /* ................ */
6, /* .............##. */ 6, /* .............##. */
30, /* ...........####. */ 30, /* ...........####. */
@ -45,11 +44,9 @@ MwCursor MwCursorArrow = {
28672, /* .###............ */ 28672, /* .###............ */
8192, /* ..#............. */ 8192, /* ..#............. */
0 /* ................ */ 0 /* ................ */
} }};
};
MwCursor MwCursorArrowMask = { MwCursor MwCursorArrowMask = {
16, 16, -15, -15, 16, 16, -15, -15, {
{
7, /* .............### */ 7, /* .............### */
31, /* ...........##### */ 31, /* ...........##### */
127, /* .........####### */ 127, /* .........####### */
@ -66,5 +63,4 @@ MwCursor MwCursorArrowMask = {
63552, /* #####....#...... */ 63552, /* #####....#...... */
28672, /* .###............ */ 28672, /* .###............ */
8192 /* ..#............. */ 8192 /* ..#............. */
} }};
};

View file

@ -20,7 +20,7 @@ static void destroy(MwWidget handle) {
MwComboBox cb = handle->internal; MwComboBox cb = handle->internal;
int i; int i;
for(i = 0; i < arrlen(cb->list); i++){ for(i = 0; i < arrlen(cb->list); i++) {
free(cb->list[i]); free(cb->list[i]);
} }
arrfree(cb->list); arrfree(cb->list);
@ -43,7 +43,7 @@ static void draw(MwWidget handle) {
rc = r; rc = r;
/* draw text */ /* draw text */
if(arrlen(cb->list) > cb->selected){ if(arrlen(cb->list) > cb->selected) {
MwPoint p; MwPoint p;
p.x = MwDefaultBorderWidth(handle) * 2; p.x = MwDefaultBorderWidth(handle) * 2;
@ -80,11 +80,16 @@ static void click(MwWidget handle) {
MwComboBox cb = handle->internal; MwComboBox cb = handle->internal;
cb->opened = cb->opened ? 0 : 1; cb->opened = cb->opened ? 0 : 1;
if(cb->opened) {
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
} else {
MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
}
MwForceRender(handle); MwForceRender(handle);
} }
static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text){ static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text) {
MwComboBox cb = handle->internal; MwComboBox cb = handle->internal;
char* t = MwStringDupliacte(text); char* t = MwStringDupliacte(text);

View file

@ -162,25 +162,12 @@ static void click(MwWidget handle) {
static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) {
int i, w = 0, h = 0; int i, w = 0, h = 0;
#ifdef USE_X11
XSetWindowAttributes xswa;
Atom wndtype = XInternAtom(handle->lowlevel->display, "_NET_WM_WINDOW_TYPE", False);
Atom wndmenu = XInternAtom(handle->lowlevel->display, "_NET_WM_WINDOW_TYPE_MENU", False);
xswa.override_redirect = True;
XChangeWindowAttributes(handle->lowlevel->display, handle->lowlevel->window, CWOverrideRedirect, &xswa);
XChangeProperty(handle->lowlevel->display, handle->lowlevel->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
#endif
handle->internal = menu; handle->internal = menu;
MwLLDetach(handle->lowlevel, point); MwLLDetach(handle->lowlevel, point);
#ifdef USE_GDI MwLLMakeToolWindow(handle->lowlevel);
SetWindowLongPtr(handle->lowlevel->hWnd, GWL_STYLE, (LPARAM)0);
SetWindowLongPtr(handle->lowlevel->hWnd, GWL_EXSTYLE, (LPARAM)WS_EX_TOOLWINDOW);
#endif
MwLLShow(handle->lowlevel, 1); MwLLShow(handle->lowlevel, 1);