From ba2e44a4d1e991dad0064bed72ffa2279a217694 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 25 Sep 2003 18:42:15 +0000 Subject: [PATCH] Don't use hardcoded DEMOCODEDIR on Windows. 2003-09-25 Tor Lillqvist * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. 2003-09-21 Tor Lillqvist * gdk/win32/gdkevents-win32.c (handle_wm_paint): New function. Code split out from gdk_event_translate(). Needed because gdk_event_get_graphics_expose() couldn't do anything sensible otherwise. (Not that I think graphics exposes work anyway in gdk/win32, but at least now the code could work.) (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of gdk_event_translate(), which couldn't have worked as it doesn't take any pre-allocated GdkEvent parameter any longer. (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) --- ChangeLog | 19 +++ ChangeLog.pre-2-10 | 19 +++ ChangeLog.pre-2-4 | 19 +++ ChangeLog.pre-2-6 | 19 +++ ChangeLog.pre-2-8 | 19 +++ demos/gtk-demo/main.c | 25 ++++ gdk/win32/gdkevents-win32.c | 226 +++++++++++++++++++----------------- 7 files changed, 240 insertions(+), 106 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c2a8c98c7..088e7fe25c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-09-25 Tor Lillqvist + + * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. + +2003-09-21 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (handle_wm_paint): New + function. Code split out from gdk_event_translate(). Needed + because gdk_event_get_graphics_expose() couldn't do anything + sensible otherwise. (Not that I think graphics exposes work anyway + in gdk/win32, but at least now the code could work.) + + (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of + gdk_event_translate(), which couldn't have worked as it doesn't + take any pre-allocated GdkEvent parameter any longer. + + (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let + GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) + 2003-09-20 Tor Lillqvist * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9c2a8c98c7..088e7fe25c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +2003-09-25 Tor Lillqvist + + * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. + +2003-09-21 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (handle_wm_paint): New + function. Code split out from gdk_event_translate(). Needed + because gdk_event_get_graphics_expose() couldn't do anything + sensible otherwise. (Not that I think graphics exposes work anyway + in gdk/win32, but at least now the code could work.) + + (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of + gdk_event_translate(), which couldn't have worked as it doesn't + take any pre-allocated GdkEvent parameter any longer. + + (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let + GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) + 2003-09-20 Tor Lillqvist * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9c2a8c98c7..088e7fe25c 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +2003-09-25 Tor Lillqvist + + * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. + +2003-09-21 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (handle_wm_paint): New + function. Code split out from gdk_event_translate(). Needed + because gdk_event_get_graphics_expose() couldn't do anything + sensible otherwise. (Not that I think graphics exposes work anyway + in gdk/win32, but at least now the code could work.) + + (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of + gdk_event_translate(), which couldn't have worked as it doesn't + take any pre-allocated GdkEvent parameter any longer. + + (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let + GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) + 2003-09-20 Tor Lillqvist * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9c2a8c98c7..088e7fe25c 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +2003-09-25 Tor Lillqvist + + * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. + +2003-09-21 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (handle_wm_paint): New + function. Code split out from gdk_event_translate(). Needed + because gdk_event_get_graphics_expose() couldn't do anything + sensible otherwise. (Not that I think graphics exposes work anyway + in gdk/win32, but at least now the code could work.) + + (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of + gdk_event_translate(), which couldn't have worked as it doesn't + take any pre-allocated GdkEvent parameter any longer. + + (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let + GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) + 2003-09-20 Tor Lillqvist * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9c2a8c98c7..088e7fe25c 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +2003-09-25 Tor Lillqvist + + * demos/gtk-demo/main.c: Don't use hardcoded DEMOCODEDIR on Windows. + +2003-09-21 Tor Lillqvist + + * gdk/win32/gdkevents-win32.c (handle_wm_paint): New + function. Code split out from gdk_event_translate(). Needed + because gdk_event_get_graphics_expose() couldn't do anything + sensible otherwise. (Not that I think graphics exposes work anyway + in gdk/win32, but at least now the code could work.) + + (gdk_event_get_graphics_expose): Call handle_wm_paint() instead of + gdk_event_translate(), which couldn't have worked as it doesn't + take any pre-allocated GdkEvent parameter any longer. + + (gdk_event_translate): Handle WM_MOUSEACTIVATE: Don't let + GDK_WINDOW_TEMP windows be activated. (#122578, John Ehresman) + 2003-09-20 Tor Lillqvist * gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index 4b50287597..8d05561f21 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -28,6 +28,31 @@ struct _CallbackData GtkTreePath *path; }; +#ifdef G_OS_WIN32 + +#undef DEMOCODEDIR + +static char * +get_democodedir (void) +{ + static char *result = NULL; + + if (result == NULL) + { + result = g_win32_get_package_installation_directory (NULL, NULL); + if (result == NULL) + result = "unknown-location"; + + result = g_strconcat (result, "\\share\\gtk-2.0\\demo", NULL); + } + + return result; +} + +#define DEMOCODEDIR get_democodedir () + +#endif + /** * demo_find_file: * @base: base filename diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 18d984eb46..a8563cf294 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -86,6 +86,10 @@ static gboolean gdk_event_translate (GdkDisplay *display, MSG *msg, gint *ret_valp, gboolean return_exposes); +static void handle_wm_paint (MSG *msg, + GdkWindow *window, + gboolean return_exposes, + GdkEvent **event); static gboolean gdk_event_prepare (GSource *source, gint *timeout); @@ -435,7 +439,7 @@ GdkEvent* gdk_event_get_graphics_expose (GdkWindow *window) { MSG msg; - GdkEvent *event; + GdkEvent *event = NULL; g_return_val_if_fail (window != NULL, NULL); @@ -443,16 +447,12 @@ gdk_event_get_graphics_expose (GdkWindow *window) if (PeekMessage (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE)) { - event = gdk_event_new (GDK_NOTHING); - - if (gdk_event_translate (gdk_drawable_get_display (window), - &msg, NULL, TRUE)) + handle_wm_paint (&msg, window, TRUE, &event); + if (event != NULL) { GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose: got it!\n")); return event; } - else - gdk_event_free (event); } GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose: nope\n")); @@ -1881,6 +1881,108 @@ adjust_drag (LONG *drag, *drag = curr - ((curr - *drag + inc/2) / inc) * inc; } +static void +handle_wm_paint (MSG *msg, + GdkWindow *window, + gboolean return_exposes, + GdkEvent **event) +{ + HRGN hrgn = CreateRectRgn (0, 0, 0, 0); + HDC hdc; + PAINTSTRUCT paintstruct; + GdkRegion *update_region; + gint xoffset, yoffset; + + if (GetUpdateRgn (msg->hwnd, hrgn, FALSE) == ERROR) + { + WIN32_GDI_FAILED ("GetUpdateRgn"); + return; + } + + hdc = BeginPaint (msg->hwnd, &paintstruct); + + GDK_NOTE (EVENTS, g_print ("WM_PAINT: %p %s %s dc %p%s\n", + msg->hwnd, + _gdk_win32_rect_to_string (&paintstruct.rcPaint), + (paintstruct.fErase ? "erase" : ""), + hdc, + (return_exposes ? " return_exposes" : ""))); + + EndPaint (msg->hwnd, &paintstruct); + + /* HB: don't generate GDK_EXPOSE events for InputOnly + * windows -> backing store now works! + */ + if (((GdkWindowObject *) window)->input_only) + { + DeleteObject (hrgn); + return; + } + + if (!(((GdkWindowObject *) window)->event_mask & GDK_EXPOSURE_MASK)) + { + GDK_NOTE (EVENTS, g_print ("...ignored\n")); + DeleteObject (hrgn); + return; + } + +#if 0 /* we need to process exposes even with GDK_NO_BG + * Otherwise The GIMP canvas update is broken .... + */ + if (((GdkWindowObject *) window)->bg_pixmap == GDK_NO_BG) + break; +#endif + + if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) || + (paintstruct.rcPaint.bottom == paintstruct.rcPaint.top)) + { + GDK_NOTE (EVENTS, g_print ("...empty paintstruct, ignored\n")); + DeleteObject (hrgn); + return; + } + + if (return_exposes) + { + if (!GDK_WINDOW_DESTROYED (window)) + { + GList *list = gdk_drawable_get_display (window)->queued_events; + + *event = gdk_event_new (GDK_EXPOSE); + (*event)->expose.window = window; + (*event)->expose.area.x = paintstruct.rcPaint.left; + (*event)->expose.area.y = paintstruct.rcPaint.top; + (*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left; + (*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top; + (*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn); + (*event)->expose.count = 0; + + while (list != NULL) + { + GdkEventPrivate *evp = list->data; + + if (evp->event.any.type == GDK_EXPOSE && + evp->event.any.window == window && + !(evp->flags & GDK_EVENT_PENDING)) + evp->event.expose.count++; + + list = list->next; + } + } + + return; + } + + update_region = _gdk_win32_hrgn_to_region (hrgn); + + _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset); + gdk_region_offset (update_region, xoffset, yoffset); + + _gdk_window_process_expose (window, update_region); + gdk_region_destroy (update_region); + + DeleteObject (hrgn); +} + static gboolean gdk_event_translate (GdkDisplay *display, MSG *msg, @@ -1889,14 +1991,11 @@ gdk_event_translate (GdkDisplay *display, { DWORD pidActWin; DWORD pidThis; - PAINTSTRUCT paintstruct; - HDC hdc; RECT rect, *drag, orig_drag; POINT point; MINMAXINFO *mmi; HWND hwnd; HCURSOR hcursor; - HRGN hrgn; CHARSETINFO charset_info; BYTE key_state[256]; HIMC himc; @@ -2283,10 +2382,6 @@ gdk_event_translate (GdkDisplay *display, API_CALL (GetKeyboardState, (key_state)); - /* Note that for this message we always return FALSE from - * gdk_event_translate(), so any events we want have to be - * created and appended to the queue here. - */ for (i = 0; i < ccount; i++) { if (((GdkWindowObject *) window)->event_mask & GDK_KEY_PRESS_MASK) @@ -2392,7 +2487,6 @@ gdk_event_translate (GdkDisplay *display, _gdk_event_button_generate (display, event); return_val = TRUE; - break; case WM_LBUTTONUP: @@ -2586,6 +2680,7 @@ gdk_event_translate (GdkDisplay *display, } return_val = TRUE; break; + case WM_MOUSEWHEEL: GDK_NOTE (EVENTS, g_print ("WM_MOUSEWHEEL: %p %d\n", msg->hwnd, HIWORD (msg->wParam))); @@ -2678,6 +2773,15 @@ gdk_event_translate (GdkDisplay *display, update_colors (window, TRUE); break; + case WM_MOUSEACTIVATE: + GDK_NOTE (EVENTS, g_print ("WM_MOUSEACTIVATE: %p\n", msg->hwnd)); + if (gdk_window_get_window_type (window) == GDK_WINDOW_TEMP) + { + *ret_valp = MA_NOACTIVATE; + return_val = TRUE; + } + break; + case WM_SETFOCUS: case WM_KILLFOCUS: GDK_NOTE (EVENTS, g_print ("WM_%sFOCUS: %p\n", @@ -2713,97 +2817,7 @@ gdk_event_translate (GdkDisplay *display, break; case WM_PAINT: - hrgn = CreateRectRgn (0, 0, 0, 0); - if (GetUpdateRgn (msg->hwnd, hrgn, FALSE) == ERROR) - { - WIN32_GDI_FAILED ("GetUpdateRgn"); - break; - } - - hdc = BeginPaint (msg->hwnd, &paintstruct); - - GDK_NOTE (EVENTS, g_print ("WM_PAINT: %p %s %s dc %p%s\n", - msg->hwnd, - _gdk_win32_rect_to_string (&paintstruct.rcPaint), - (paintstruct.fErase ? "erase" : ""), - hdc, - (return_exposes ? " return_exposes" : ""))); - - EndPaint (msg->hwnd, &paintstruct); - - /* HB: don't generate GDK_EXPOSE events for InputOnly - * windows -> backing store now works! - */ - if (((GdkWindowObject *) window)->input_only) - { - DeleteObject (hrgn); - break; - } - - if (!(((GdkWindowObject *) window)->event_mask & GDK_EXPOSURE_MASK)) - { - GDK_NOTE (EVENTS, g_print ("...ignored\n")); - DeleteObject (hrgn); - break; - } - -#if 0 /* we need to process exposes even with GDK_NO_BG - * Otherwise The GIMP canvas update is broken .... - */ - if (((GdkWindowObject *) window)->bg_pixmap == GDK_NO_BG) - break; -#endif - - if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) || - (paintstruct.rcPaint.bottom == paintstruct.rcPaint.top)) - { - GDK_NOTE (EVENTS, g_print ("...empty paintstruct, ignored\n")); - DeleteObject (hrgn); - break; - } - - if (return_exposes) - { - if (!GDK_WINDOW_DESTROYED (window)) - { - GList *list = display->queued_events; - - event = gdk_event_new (GDK_EXPOSE); - event->expose.window = window; - event->expose.area.x = paintstruct.rcPaint.left; - event->expose.area.y = paintstruct.rcPaint.top; - event->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left; - event->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top; - event->expose.region = _gdk_win32_hrgn_to_region (hrgn); - event->expose.count = 0; - - while (list != NULL) - { - GdkEventPrivate *event = list->data; - - if (event->event.any.type == GDK_EXPOSE && - event->event.any.window == window && - !(event->flags & GDK_EVENT_PENDING)) - event->event.expose.count++; - - list = list->next; - } - append_event (display, event); - } - - return_val = TRUE; - } - else - { - GdkRegion *update_region = _gdk_win32_hrgn_to_region (hrgn); - - _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset); - gdk_region_offset (update_region, xoffset, yoffset); - - _gdk_window_process_expose (window, update_region); - gdk_region_destroy (update_region); - } - DeleteObject (hrgn); + handle_wm_paint (msg, window, FALSE, NULL); break; case WM_SETCURSOR: