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

@ -132,8 +132,8 @@ struct _MwListBox {
struct _MwComboBox { struct _MwComboBox {
char** list; char** list;
int opened; int opened;
int selected; int selected;
}; };
struct _MwDirectoryEntry { struct _MwDirectoryEntry {

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,44 +27,40 @@
* 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, /* ...........####. */ 124, /* .........#####.. */
124, /* .........#####.. */ 508, /* .......#######.. */
508, /* .......#######.. */ 2040, /* .....########... */
2040, /* .....########... */ 8184, /* ...##########... */
8184, /* ...##########... */ 496, /* .......#####.... */
496, /* .......#####.... */ 1008, /* ......######.... */
1008, /* ......######.... */ 1888, /* .....###.##..... */
1888, /* .....###.##..... */ 3680, /* ....###..##..... */
3680, /* ....###..##..... */ 7232, /* ...###...#...... */
7232, /* ...###...#...... */ 14400, /* ..###....#...... */
14400, /* ..###....#...... */ 28672, /* .###............ */
28672, /* .###............ */ 8192, /* ..#............. */
8192, /* ..#............. */ 0 /* ................ */
0 /* ................ */ }};
}
};
MwCursor MwCursorArrowMask = { MwCursor MwCursorArrowMask = {
16, 16, -15, -15, 16, 16, -15, -15, {
{ 7, /* .............### */
7, /* .............### */ 31, /* ...........##### */
31, /* ...........##### */ 127, /* .........####### */
127, /* .........####### */ 510, /* .......########. */
510, /* .......########. */ 2046, /* .....##########. */
2046, /* .....##########. */ 8188, /* ...###########.. */
8188, /* ...###########.. */ 16380, /* ..############.. */
16380, /* ..############.. */ 8184, /* ...##########... */
8184, /* ...##########... */ 2040, /* .....########... */
2040, /* .....########... */ 4080, /* ....########.... */
4080, /* ....########.... */ 8176, /* ...#########.... */
8176, /* ...#########.... */ 16096, /* ..#####.###..... */
16096, /* ..#####.###..... */ 31968, /* .#####..###..... */
31968, /* .#####..###..... */ 63552, /* #####....#...... */
63552, /* #####....#...... */ 28672, /* .###............ */
28672, /* .###............ */ 8192 /* ..#............. */
8192 /* ..#............. */ }};
}
};

View file

@ -6,9 +6,9 @@
static int create(MwWidget handle) { static int create(MwWidget handle) {
MwComboBox cb = malloc(sizeof(*cb)); MwComboBox cb = malloc(sizeof(*cb));
cb->list = NULL; cb->list = NULL;
cb->opened = 0; cb->opened = 0;
cb->selected = 0; cb->selected = 0;
handle->internal = cb; handle->internal = cb;
MwSetDefault(handle); MwSetDefault(handle);
@ -18,9 +18,9 @@ static int create(MwWidget handle) {
static void destroy(MwWidget handle) { 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,13 +80,18 @@ 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);
if(index == -1) index = arrlen(cb->list); 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) { static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
(void)out; (void)out;
if(strcmp(name, "mwComboBoxAdd") == 0) { if(strcmp(name, "mwComboBoxAdd") == 0) {
int index = va_arg(va, int); int index = va_arg(va, int);
const char* text = va_arg(va, const char*); const char* text = va_arg(va, const char*);
mwComboBoxAddImpl(handle, index, text); mwComboBoxAddImpl(handle, index, 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);