# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1003102057 0 # Node ID 360bc6a5f1c99e93c89c4699f6980d2b407f394b # Parent cddb02f847e1c015a7d437d02d5fac87c3b096db Sync with latest Dynamic Windows code. diff -r cddb02f847e1 -r 360bc6a5f1c9 compat.c --- a/compat.c Mon Sep 17 09:15:40 2001 +0000 +++ b/compat.c Sun Oct 14 23:27:37 2001 +0000 @@ -16,6 +16,23 @@ #endif #endif +#ifdef __UNIX__ +void msleep(long period) +{ +#ifdef __sun__ + /* usleep() isn't threadsafe on Solaris */ + struct timespec req; + + req.tv_sec = 0; + req.tv_nsec = period * 1000000; + + nanosleep(&req, NULL); +#else + usleep(period * 1000); +#endif +} +#endif + int sockread (int a, void *b, int c, int d) { #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) @@ -69,6 +86,21 @@ #endif } +void block(int fd) +{ +#ifdef __IBMC__ + static int _nonblock = 0; + + ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); +#elif defined(__WIN32__) && !defined(__CYGWIN32__) + static unsigned long _nonblock = 0; + + ioctlsocket(fd, FIONBIO, &_nonblock); +#else + fcntl(fd, F_SETFL, 0); +#endif +} + int socksprintf(int fd, char *format, ...) { va_list args; @@ -435,7 +467,7 @@ /* No snprintf() on OS/2 ??? */ sprintf(buf, "Drive %c", (char)drive + 'A' - 1); #else - snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); + _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); #endif } diff -r cddb02f847e1 -r 360bc6a5f1c9 dw.def --- a/dw.def Mon Sep 17 09:15:40 2001 +0000 +++ b/dw.def Sun Oct 14 23:27:37 2001 +0000 @@ -21,6 +21,7 @@ dw_user_dir @20 dw_flush @21 dw_free @22 + dw_main_sleep @23 dw_box_new @40 dw_groupbox_new @41 diff -r cddb02f847e1 -r 360bc6a5f1c9 dwcompat.def --- a/dwcompat.def Mon Sep 17 09:15:40 2001 +0000 +++ b/dwcompat.def Sun Oct 14 23:27:37 2001 +0000 @@ -23,6 +23,7 @@ isdrive @24 drivesize @25 getfsname @26 + block @27 opendir @30 openxdir @31 diff -r cddb02f847e1 -r 360bc6a5f1c9 dwcompatw.def --- a/dwcompatw.def Mon Sep 17 09:15:40 2001 +0000 +++ b/dwcompatw.def Sun Oct 14 23:27:37 2001 +0000 @@ -18,6 +18,7 @@ isdrive @24 drivesize @25 getfsname @26 + block @27 opendir @30 openxdir @31 diff -r cddb02f847e1 -r 360bc6a5f1c9 dww.def --- a/dww.def Mon Sep 17 09:15:40 2001 +0000 +++ b/dww.def Sun Oct 14 23:27:37 2001 +0000 @@ -18,6 +18,7 @@ dw_user_dir @20 dw_flush @21 dw_free @22 + dw_main_sleep @23 dw_box_new @40 dw_groupbox_new @41 diff -r cddb02f847e1 -r 360bc6a5f1c9 gtk/dw.c --- a/gtk/dw.c Mon Sep 17 09:15:40 2001 +0000 +++ b/gtk/dw.c Sun Oct 14 23:27:37 2001 +0000 @@ -53,6 +53,8 @@ int _dw_file_active = 0, _dw_ignore_click = 0; pthread_t _dw_thread = (pthread_t)-1; int _dw_mutex_locked = FALSE; +/* Use default border size for the default enlightenment theme */ +int _dw_border_width = 12, _dw_border_height = 28; #define DW_MUTEX_LOCK { if(pthread_self() != _dw_thread && _dw_mutex_locked == FALSE) { gdk_threads_enter(); _dw_mutex_locked = TRUE; _locked_by_me = TRUE; } } #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked = FALSE; _locked_by_me = FALSE; } } @@ -84,6 +86,8 @@ void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); +void msleep(long period); + typedef struct { void *func; @@ -469,6 +473,7 @@ int dw_int_init(DWResources *res, int newthread, int argc, char *argv[]) { int z; + char *tmp; if(res) { @@ -487,6 +492,14 @@ _dw_cmap = gdk_colormap_get_system(); for(z=0;z<16;z++) gdk_color_alloc(_dw_cmap, &_colors[z]); + + tmp = getenv("DW_BORDER_WIDTH"); + if(tmp) + _dw_border_width = atoi(tmp); + tmp = getenv("DW_BORDER_HEIGHT"); + if(tmp) + _dw_border_height = atoi(tmp); + return TRUE; } @@ -506,6 +519,31 @@ } /* + * Runs a message loop for Dynamic Windows, for a period of seconds. + * Parameters: + * seconds: Number of seconds to run the loop for. + */ +void dw_main_sleep(int seconds) +{ + time_t start = time(NULL); + + if(_dw_thread == (pthread_t)-1 || _dw_thread == pthread_self()) + { + while(time(NULL) - start <= seconds) + { + gdk_threads_enter(); + if(gtk_events_pending()) + gtk_main_iteration(); + else + msleep(1); + gdk_threads_leave(); + } + } + else + msleep(seconds * 1000); +} + +/* * Free's memory allocated by dynamic windows. * Parameters: * ptr: Pointer to dynamic windows allocated @@ -998,7 +1036,7 @@ int _locked_by_me = FALSE; DW_MUTEX_LOCK; - gdk_pointer_grab(handle->window, TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK, NULL, NULL, GDK_CURRENT_TIME); + gdk_pointer_grab(handle->window, TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, NULL, NULL, GDK_CURRENT_TIME); DW_MUTEX_UNLOCK; } @@ -1100,7 +1138,22 @@ */ HWND dw_groupbox_new(int type, int pad, char *title) { - return dw_box_new(type, pad); + GtkWidget *tmp, *frame; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); + gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL); + tmp = gtk_table_new(1, 1, FALSE); + gtk_object_set_data(GTK_OBJECT(tmp), "boxtype", (gpointer)type); + gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad); + gtk_object_set_data(GTK_OBJECT(frame), "boxhandle", (gpointer)tmp); + gtk_container_add(GTK_CONTAINER(frame), tmp); + gtk_widget_show(tmp); + gtk_widget_show(frame); + DW_MUTEX_UNLOCK; + return frame; } /* @@ -1535,6 +1588,7 @@ gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); gtk_widget_show(tmp); gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); DW_MUTEX_UNLOCK; return tmp; } @@ -3612,12 +3666,16 @@ void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) { int _locked_by_me = FALSE; + GtkWidget *tmp; if(!box) return; DW_MUTEX_LOCK; + if((tmp = gtk_object_get_data(GTK_OBJECT(box), "boxhandle"))) + box = tmp; + if(!item) { item = gtk_label_new(""); @@ -3771,7 +3829,7 @@ _size_allocate(GTK_WINDOW(handle)); gtk_widget_set_uposition(handle, x, y); - gtk_window_set_default_size(GTK_WINDOW(handle), width, height); + gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height); } else if(handle && handle->window) { @@ -3805,10 +3863,20 @@ *x = gx; if(y) *y = gy; - if(width) - *width = gwidth; - if(height) - *height = gheight; + if(GTK_IS_WINDOW(handle)) + { + if(width) + *width = gwidth + _dw_border_width; + if(height) + *height = gheight + _dw_border_height; + } + else + { + if(width) + *width = gwidth; + if(height) + *height = gheight; + } DW_MUTEX_UNLOCK; } } @@ -3841,17 +3909,22 @@ } if(GTK_IS_LABEL(handle2)) { - gfloat x, y; - - x = y = DW_LEFT; - - if(style & DW_DT_CENTER) - x = DW_CENTER; - - if(style & DW_DT_VCENTER) - y = DW_CENTER; - - gtk_misc_set_alignment(GTK_MISC(handle2), x, y); + if(style & DW_DT_CENTER || style & DW_DT_VCENTER) + { + gfloat x, y; + + x = y = DW_LEFT; + + if(style & DW_DT_CENTER) + x = DW_CENTER; + + if(style & DW_DT_VCENTER) + y = DW_CENTER; + + gtk_misc_set_alignment(GTK_MISC(handle2), x, y); + } + if(style & DW_DT_WORDBREAK) + gtk_label_set_line_wrap(GTK_LABEL(handle), TRUE); } DW_MUTEX_UNLOCK; } @@ -4429,12 +4502,16 @@ void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) { int _locked_by_me = FALSE; + GtkWidget *tmp; if(!box) return; DW_MUTEX_LOCK; + if((tmp = gtk_object_get_data(GTK_OBJECT(box), "boxhandle"))) + box = tmp; + if(!item) { item = gtk_label_new(""); @@ -4738,7 +4815,12 @@ */ void dw_window_function(HWND handle, void *function, void *data) { - /* TODO */ + void (* windowfunc)(void *); + + windowfunc = function; + + if(windowfunc) + windowfunc(data); } #ifndef NO_SIGNALS @@ -4788,7 +4870,7 @@ { thisname = "select_child"; } - else if(GTK_IS_WINDOW(thiswindow) && strcmp(signame, "set-focus") == 0) + else if(strcmp(signame, "set-focus") == 0) { thisname = "focus-in-event"; } diff -r cddb02f847e1 -r 360bc6a5f1c9 os2/dw.c --- a/os2/dw.c Mon Sep 17 09:15:40 2001 +0000 +++ b/os2/dw.c Sun Oct 14 23:27:37 2001 +0000 @@ -21,10 +21,13 @@ #include #include #include +#include #include "dw.h" #define QWP_USER 0 +MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); + char ClassName[] = "dynamicwindows"; char SplitbarClassName[] = "dwsplitbar"; char DefaultFont[] = "9.WarpSans"; @@ -215,6 +218,9 @@ if(!handle) return 0; + if(!WinIsWindowEnabled(handle)) + return 0; + WinQueryClassName(handle, 99, tmpbuf); /* These are the window classes which can @@ -923,7 +929,7 @@ if(boxinfo && boxinfo->grouphwnd) WinSetWindowPos(boxinfo->grouphwnd, HWND_TOP, 0, 0, - width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); + width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE /*| SWP_ZORDER*/); } @@ -1201,6 +1207,21 @@ switch(msg) { + case WM_BUTTON1DOWN: + case WM_BUTTON2DOWN: + case WM_BUTTON3DOWN: + { + char tmpbuf[100]; + + WinQueryClassName(hWnd, 99, tmpbuf); + + if(strncmp(tmpbuf, "#32", 3)==0) + _run_event(hWnd, WM_SETFOCUS, FALSE, TRUE); + } + break; + case WM_SETFOCUS: + _run_event(hWnd, msg, mp1, mp2); + break; case WM_CHAR: if(SHORT1FROMMP(mp2) == '\t') { @@ -2162,6 +2183,9 @@ switch(msg) { #ifndef NO_SIGNALS + case WM_SETFOCUS: + _wndproc(hwnd, msg, mp1, mp2); + break; case WM_BUTTON1UP: { SignalHandler *tmp = Root; @@ -2432,6 +2456,28 @@ } /* + * Runs a message loop for Dynamic Windows, for a period of seconds. + * Parameters: + * seconds: Number of seconds to run the loop for. + */ +void dw_main_sleep(int seconds) +{ + QMSG qmsg; + time_t start = time(NULL); + + while(time(NULL) - start <= seconds) + { + if(WinPeekMsg(dwhab, &qmsg, 0, 0, 0, PM_NOREMOVE)) + { + WinGetMsg(dwhab, &qmsg, 0, 0, 0); + WinDispatchMsg(dwhab, &qmsg); + } + else + DosSleep(1); + } +} + +/* * Free's memory allocated by dynamic windows. * Parameters: * ptr: Pointer to dynamic windows allocated @@ -3746,9 +3792,9 @@ thisbox->count++; - /* Don't set the ownership if it's an entryfield or combobox */ + /* Don't set the ownership if it's an entryfield or spinbutton */ WinQueryClassName(item, 99, tmpbuf); - if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) + if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 3)!=0) { if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) WinSetOwner(item, boxowner); @@ -5847,8 +5893,8 @@ thisbox->count++; WinQueryClassName(item, 99, tmpbuf); - /* Don't set the ownership if it's an entryfield or combobox */ - if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) + /* Don't set the ownership if it's an entryfield or spinbutton */ + if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 3)!=0) { if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) WinSetOwner(item, boxowner); diff -r cddb02f847e1 -r 360bc6a5f1c9 win/dw.c --- a/win/dw.c Mon Sep 17 09:15:40 2001 +0000 +++ b/win/dw.c Sun Oct 14 23:27:37 2001 +0000 @@ -14,6 +14,7 @@ #include #include #include +#include #include "dw.h" /* this is the callback handle for the window procedure */ @@ -1350,6 +1351,67 @@ case WM_NOTIFY: _wndproc(hWnd, msg, mp1, mp2); break; +#if 0 + case WM_ERASEBKGND: + { + ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); + + if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) + return FALSE; + } + break; +#endif + case WM_PAINT: + { + ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA); + + if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) + { + PAINTSTRUCT ps; + HDC hdcPaint = BeginPaint(hWnd, &ps); + int success = FALSE; + + if(thiscinfo->fore > -1 && thiscinfo->back > -1 && + thiscinfo->fore < 18 && thiscinfo->back < 18) + { + SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore], + _green[thiscinfo->fore], + _blue[thiscinfo->fore])); + SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back], + _green[thiscinfo->back], + _blue[thiscinfo->back])); + SelectObject(hdcPaint, thiscinfo->hbrush); + Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1); + success = TRUE; + } + if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR && (thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR) + { + SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore), + DW_GREEN_VALUE(thiscinfo->fore), + DW_BLUE_VALUE(thiscinfo->fore))); + SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + DeleteObject(thiscinfo->hbrush); + thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back), + DW_GREEN_VALUE(thiscinfo->back), + DW_BLUE_VALUE(thiscinfo->back))); + SelectObject(hdcPaint, thiscinfo->hbrush); + Rectangle(hdcPaint, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); + success = TRUE; + } + + EndPaint(hWnd, &ps); + if(success) + return FALSE; + } + + } + break; } return DefWindowProc(hWnd, msg, mp1, mp2); } @@ -1448,6 +1510,9 @@ { switch( msg ) { + case WM_SETFOCUS: + _wndproc(hWnd, msg, mp1, mp2); + break; case WM_CHAR: if(LOWORD(mp1) == '\t') { @@ -1969,6 +2034,9 @@ switch(msg) { #ifndef NO_SIGNALS + case WM_SETFOCUS: + _wndproc(hwnd, msg, mp1, mp2); + break; case WM_LBUTTONUP: { SignalHandler *tmp = Root; @@ -2309,7 +2377,8 @@ /* Setup the filter function */ filterfunc = func; - while (GetMessage(&msg,NULL,0,0)) { + while (GetMessage(&msg, NULL, 0, 0)) + { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -2320,6 +2389,29 @@ } /* + * Runs a message loop for Dynamic Windows, for a period of seconds. + * Parameters: + * seconds: Number of seconds to run the loop for. + */ +void dw_main_sleep(int seconds) +{ + MSG msg; + time_t start = time(NULL); + + while(time(NULL) - start <= seconds) + { + if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) + { + GetMessage(&msg, NULL, 0, 0); + TranslateMessage(&msg); + DispatchMessage(&msg); + } + else + Sleep(1); + } +} + +/* * Free's memory allocated by dynamic windows. * Parameters: * ptr: Pointer to dynamic windows allocated @@ -2565,9 +2657,6 @@ GetClassName(handle, tmpbuf, 99); - if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME))==0) - return FALSE; - if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) { ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), @@ -4162,22 +4251,30 @@ */ unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) { - char *tmpbuf = malloc(MLE_MAX+1); + char *tmpbuf = calloc(1, MLE_MAX+1); int len; + if(strlen(buffer) < 1) + return startpoint; + + startpoint++; + if(startpoint < 0) startpoint = 0; GetWindowText(handle, tmpbuf, MLE_MAX); - tmpbuf[MLE_MAX] = 0; len = strlen(tmpbuf); - if(len) - memcpy(&tmpbuf[startpoint+strlen(buffer)], &tmpbuf[startpoint], (len-startpoint)); + if(len) + { + char *dest = &tmpbuf[startpoint+strlen(buffer)-1], *start = &tmpbuf[startpoint]; + int copylen = len - startpoint; + + if(copylen > 0) + memcpy(dest, start, copylen); + } memcpy(&tmpbuf[startpoint], buffer, strlen(buffer)); - tmpbuf[len+strlen(buffer)] = 0; - SetWindowText(handle, tmpbuf); free(tmpbuf); @@ -5830,6 +5927,9 @@ if(window && signame && sigfunc) { + if(stricmp(signame, "set-focus") == 0) + window = _normalize_handle(window); + if((message = _findsigmessage(signame)) != 0) _new_signal(message, window, sigfunc, data); }