diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 02dbfc2..f96c196 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -134,6 +134,8 @@ MWDECL void MwLLGrabPointer(MwLL handle, int toggle); MWDECL void MwLLSetClipboard(MwLL handle, const char* text); MWDECL char* MwLLGetClipboard(MwLL handle); +MWDECL void MwLLMakeToolWindow(MwLL handle); + #ifdef __cplusplus } #endif diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index 5e94b0e..093a179 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -132,8 +132,8 @@ struct _MwListBox { struct _MwComboBox { char** list; - int opened; - int selected; + int opened; + int selected; }; struct _MwDirectoryEntry { diff --git a/src/backend/gdi.c b/src/backend/gdi.c index b650de2..119d39f 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -691,3 +691,10 @@ char* MwLLGetClipboard(MwLL handle) { } 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); +} diff --git a/src/backend/x11.c b/src/backend/x11.c index e6ca620..40ce480 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -946,3 +946,14 @@ char* MwLLGetClipboard(MwLL handle) { 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); +} diff --git a/src/cursor/arrow.c b/src/cursor/arrow.c index 3f50e35..e587ef9 100644 --- a/src/cursor/arrow.c +++ b/src/cursor/arrow.c @@ -27,44 +27,40 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ MwCursor MwCursorArrow = { - 16, 16, -15, -15, - { - 0, /* ................ */ - 6, /* .............##. */ - 30, /* ...........####. */ - 124, /* .........#####.. */ - 508, /* .......#######.. */ - 2040, /* .....########... */ - 8184, /* ...##########... */ - 496, /* .......#####.... */ - 1008, /* ......######.... */ - 1888, /* .....###.##..... */ - 3680, /* ....###..##..... */ - 7232, /* ...###...#...... */ - 14400, /* ..###....#...... */ - 28672, /* .###............ */ - 8192, /* ..#............. */ - 0 /* ................ */ - } -}; + 16, 16, -15, -15, { + 0, /* ................ */ + 6, /* .............##. */ + 30, /* ...........####. */ + 124, /* .........#####.. */ + 508, /* .......#######.. */ + 2040, /* .....########... */ + 8184, /* ...##########... */ + 496, /* .......#####.... */ + 1008, /* ......######.... */ + 1888, /* .....###.##..... */ + 3680, /* ....###..##..... */ + 7232, /* ...###...#...... */ + 14400, /* ..###....#...... */ + 28672, /* .###............ */ + 8192, /* ..#............. */ + 0 /* ................ */ + }}; MwCursor MwCursorArrowMask = { - 16, 16, -15, -15, - { - 7, /* .............### */ - 31, /* ...........##### */ - 127, /* .........####### */ - 510, /* .......########. */ - 2046, /* .....##########. */ - 8188, /* ...###########.. */ - 16380, /* ..############.. */ - 8184, /* ...##########... */ - 2040, /* .....########... */ - 4080, /* ....########.... */ - 8176, /* ...#########.... */ - 16096, /* ..#####.###..... */ - 31968, /* .#####..###..... */ - 63552, /* #####....#...... */ - 28672, /* .###............ */ - 8192 /* ..#............. */ - } -}; + 16, 16, -15, -15, { + 7, /* .............### */ + 31, /* ...........##### */ + 127, /* .........####### */ + 510, /* .......########. */ + 2046, /* .....##########. */ + 8188, /* ...###########.. */ + 16380, /* ..############.. */ + 8184, /* ...##########... */ + 2040, /* .....########... */ + 4080, /* ....########.... */ + 8176, /* ...#########.... */ + 16096, /* ..#####.###..... */ + 31968, /* .#####..###..... */ + 63552, /* #####....#...... */ + 28672, /* .###............ */ + 8192 /* ..#............. */ + }}; diff --git a/src/widget/combobox.c b/src/widget/combobox.c index c7d201f..98c7aeb 100644 --- a/src/widget/combobox.c +++ b/src/widget/combobox.c @@ -6,9 +6,9 @@ static int create(MwWidget handle) { MwComboBox cb = malloc(sizeof(*cb)); - cb->list = NULL; + cb->list = NULL; cb->opened = 0; - cb->selected = 0; + cb->selected = 0; handle->internal = cb; MwSetDefault(handle); @@ -18,9 +18,9 @@ static int create(MwWidget handle) { static void destroy(MwWidget handle) { 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]); } arrfree(cb->list); @@ -43,7 +43,7 @@ static void draw(MwWidget handle) { rc = r; /* draw text */ - if(arrlen(cb->list) > cb->selected){ + if(arrlen(cb->list) > cb->selected) { MwPoint p; p.x = MwDefaultBorderWidth(handle) * 2; @@ -80,13 +80,18 @@ static void click(MwWidget handle) { MwComboBox cb = handle->internal; cb->opened = cb->opened ? 0 : 1; + if(cb->opened) { + MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask); + } else { + MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask); + } 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; - char* t = MwStringDupliacte(text); + char* t = MwStringDupliacte(text); if(index == -1) index = arrlen(cb->list); @@ -98,8 +103,8 @@ static void mwComboBoxAddImpl(MwWidget handle, int index, const char* text){ static void func_handler(MwWidget handle, const char* name, void* out, va_list va) { (void)out; if(strcmp(name, "mwComboBoxAdd") == 0) { - int index = va_arg(va, int); - const char* text = va_arg(va, const char*); + int index = va_arg(va, int); + const char* text = va_arg(va, const char*); mwComboBoxAddImpl(handle, index, text); } } diff --git a/src/widget/submenu.c b/src/widget/submenu.c index ce8dfb4..09938d5 100644 --- a/src/widget/submenu.c +++ b/src/widget/submenu.c @@ -162,25 +162,12 @@ static void click(MwWidget handle) { static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point) { 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; MwLLDetach(handle->lowlevel, point); -#ifdef USE_GDI - SetWindowLongPtr(handle->lowlevel->hWnd, GWL_STYLE, (LPARAM)0); - SetWindowLongPtr(handle->lowlevel->hWnd, GWL_EXSTYLE, (LPARAM)WS_EX_TOOLWINDOW); -#endif + MwLLMakeToolWindow(handle->lowlevel); MwLLShow(handle->lowlevel, 1);