diff options
author | Hans Breuer <hans@breuer.org> | 2004-08-06 19:20:42 +0000 |
---|---|---|
committer | Hans Breuer <hans@src.gnome.org> | 2004-08-06 19:20:42 +0000 |
commit | 74051776903510c93434e4c628c26eaeb24de522 (patch) | |
tree | c6af4e770d639acea1778a11c5915c0ff1989c7d /gdk/win32 | |
parent | bec2974410e69ed38da8bb684a5cc98ef3059afd (diff) | |
download | gdk-pixbuf-74051776903510c93434e4c628c26eaeb24de522.tar.gz |
make it compile and more similar to the X11 implementation [backward
2004-08-06 Hans Breuer <hans@breuer.org>
* gdk/win32/gdkwindow-win32.c : make it compile and more
similar to the X11 implementation [backward compatibility
for GDK_WINDOW_TEMP, GDK_INPUT_ONLY (fixes bug #148702),
use the *screen* function variants, dont reparent already
destroyed]
(get_visible_region) : take the win32 part into account
(_gdk_windowing_window_destroy) : remove from handle table
* gdk/win32/gdkdisplay-win32.c : added
gdk_display_(request|supports)_selection_notification ()
with a currently mostly pointless implementation ;-)
* gtk/gtkfilesystemwin32.c (*_to_path) : same changes as on *NIX,
plugs memory leak
(gtk_file_system_win32_render_icon) : use new GTK_STOCK_DIRECTORY
* gtk/makefile.msc.in demos/gtk-demo/makefile.msc.in
gtk/stock-icons/makefile.msc tests/makefile.msc : updated
* gdk/gdk.def gtk/gtk.def : updated externals
* tests/testiconview.c : remove unneeded dirent.h inclusion
Diffstat (limited to 'gdk/win32')
-rw-r--r-- | gdk/win32/gdkdisplay-win32.c | 135 | ||||
-rw-r--r-- | gdk/win32/gdkwindow-win32.c | 114 |
2 files changed, 214 insertions, 35 deletions
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index 28510dd15..34333766a 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -234,3 +234,138 @@ gdk_display_get_default_group (GdkDisplay *display) return NULL; } + +gboolean +gdk_display_supports_selection_notification (GdkDisplay *display) +{ + g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); + + return TRUE; +} + +static HWND _hwnd_next_viewer = NULL; + +/* + * maybe this should be integrated with the default message loop - or maybe not ;-) + */ +static LRESULT CALLBACK +_win32_on_clipboard_change (HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam) +{ + switch (message) + { + case WM_DESTROY : /* remove us from chain */ + { + ChangeClipboardChain (hwnd, _hwnd_next_viewer); + return 0; + } + case WM_CHANGECBCHAIN : + { + HWND hwndRemove = (HWND) wparam; /* handle of window being removed */ + HWND hwndNext = (HWND) lparam; /* handle of next window in chain */ + if (hwndRemove == _hwnd_next_viewer) + _hwnd_next_viewer = hwndNext == hwnd ? NULL : hwndNext; + return 0; + } + case WM_DRAWCLIPBOARD : + { + /* create the appropriate gdk events */ + HWND hwndOwner = GetClipboardOwner (); + UINT nFormat = 0; + int n = 0; + + if (OpenClipboard (hwnd)) + { + for (; 0 != (nFormat = EnumClipboardFormats (nFormat)); ) + { + char sFormat[80]; + if (GetClipboardFormatName (nFormat, sFormat, 80) > 0) + g_print ("%s ", sFormat); + n++; /* do something useful ? */ + } + GDK_NOTE (DND, + g_print ("WM_DRAWCLIPBOARD : formats %d owner %#lx\n", n, hwndOwner)); + + CloseClipboard (); + } + /* XXX: generate the apropriate GdkEventOwnerChange ... */ + + /* don't break the chain */ + return PostMessage (_hwnd_next_viewer, message, wparam, lparam); + } + default : + return DefWindowProc (hwnd, message, wparam, lparam); + } +} + +/* + * Creates a hidden window and adds it to the clipboard chain + */ +HWND +_gdk_win32_register_clipboard_notification (void) +{ + WNDCLASS wclass; + HWND hwnd; + ATOM klass; + + memset (&wclass, 0, sizeof(WNDCLASS)); + wclass.lpszClassName = "GdkClipboardNotification"; + wclass.lpfnWndProc = _win32_on_clipboard_change; + wclass.hInstance = _gdk_app_hmodule; + + klass = RegisterClass (&wclass); + if (!klass) + return NULL; + + hwnd = CreateWindow (MAKEINTRESOURCE(klass), + NULL, WS_POPUP, + 0, 0, 0, 0, NULL, NULL, + _gdk_app_hmodule, NULL); + if (!hwnd) + { + UnregisterClass (MAKEINTRESOURCE(klass), _gdk_app_hmodule); + return NULL; + } + _hwnd_next_viewer = SetClipboardViewer (hwnd); + return hwnd; +} + +/* + * The whole function would only make sense if the gdk/win32 clipboard + * model is rewritten to do delayed rendering. Currently this is only + * testcode and as noted in + * http://mail.gnome.org/archives/gtk-devel-list/2004-May/msg00113.html + * probably not worth bothering ;) + */ +gboolean +gdk_display_request_selection_notification (GdkDisplay *display, + GdkAtom selection) + +{ + static HWND hwndViewer = NULL; + gboolean ret = FALSE; + + GDK_NOTE (DND, + g_print ("gdk_display_request_selection_notification (..., %s)", + gdk_atom_name (selection))); + + if (GDK_SELECTION_CLIPBOARD == selection) + { + if (!hwndViewer) + { + hwndViewer = _gdk_win32_register_clipboard_notification (); + GDK_NOTE (DND, g_print (" registered")); + } + ret = (hwndViewer != NULL); + } + else if (GDK_SELECTION_PRIMARY == selection) + { + /* seems to work by default ? */ + GDK_NOTE (DND, g_print (" by default")); + ret = TRUE; + } + GDK_NOTE (DND, g_print (" -> %s\n", ret ? "TRUE" : "FALSE")); + return ret; +} diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 87942b291..6f839bc92 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -222,7 +222,8 @@ gdk_window_impl_win32_get_colormap (GdkDrawable *drawable) if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only && drawable_impl->colormap == NULL) { - drawable_impl->colormap = gdk_colormap_get_system (); + drawable_impl->colormap = + gdk_screen_get_system_colormap (gdk_drawable_get_screen (drawable)); g_object_ref (drawable_impl->colormap); } @@ -269,6 +270,7 @@ gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable) { GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (drawable); GdkRectangle result_rect; + HDC hdc; result_rect.x = 0; result_rect.y = 0; @@ -277,6 +279,25 @@ gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable) gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect); + /* take this win32 specific part into account (smaller when obscured) */ + hdc = GetDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (impl)); + if (hdc) + { + RECT r; + if (SIMPLEREGION == GetClipBox (hdc, &r)) + { + GdkRectangle gr; + + gr.x = r.left; + gr.y = r.top; + gr.width = r.right - r.left; + gr.height = r.bottom - r.top; + + gdk_rectangle_intersect (&result_rect, &gr, &result_rect); + } + ReleaseDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (drawable), hdc); + } + return gdk_region_rectangle (&result_rect); } @@ -531,7 +552,19 @@ gdk_window_new (GdkWindow *parent, impl->width = (attributes->width > 1) ? (attributes->width) : (1); impl->height = (attributes->height > 1) ? (attributes->height) : (1); impl->extension_events_selected = FALSE; - private->window_type = attributes->window_type; + if (attributes->wclass == GDK_INPUT_ONLY) + { + /* Backwards compatiblity - we've always ignored + * attributes->window_type for input-only windows + * before + */ + if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT) + private->window_type = GDK_WINDOW_TEMP; + else + private->window_type = GDK_WINDOW_CHILD; + } + else + private->window_type = attributes->window_type; if (attributes->wclass == GDK_INPUT_OUTPUT) { @@ -556,11 +589,14 @@ gdk_window_new (GdkWindow *parent, dwExStyle = WS_EX_TRANSPARENT; private->depth = 0; private->input_only = TRUE; - draw_impl->colormap = gdk_colormap_get_system (); + draw_impl->colormap = gdk_screen_get_system_colormap (screen); g_object_ref (draw_impl->colormap); GDK_NOTE (MISC, g_print ("...GDK_INPUT_ONLY, system colormap")); } + gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ? + (attributes->cursor) : + NULL)); switch (private->window_type) { case GDK_WINDOW_TOPLEVEL: @@ -818,6 +854,7 @@ _gdk_windowing_window_destroy (GdkWindow *window, private->destroyed = TRUE; DestroyWindow (GDK_WINDOW_HWND (window)); } + gdk_win32_handle_table_remove (GDK_WINDOW_HWND (window)); } void @@ -1276,6 +1313,12 @@ gdk_window_reparent (GdkWindow *window, g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent)); g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT); + if (GDK_WINDOW_DESTROYED (window) || + (new_parent && GDK_WINDOW_DESTROYED (new_parent))) + { + return; + } + if (!new_parent) new_parent = _gdk_parent_root; @@ -2804,6 +2847,38 @@ gdk_window_set_static_gravities (GdkWindow *window, return TRUE; } +void +gdk_window_begin_resize_drag (GdkWindow *window, + GdkWindowEdge edge, + gint button, + gint root_x, + gint root_y, + guint32 timestamp) +{ + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_WINDOW_DESTROYED (window)) + return; + + /* XXX: isn't all this default on win32 ... */ +} + +void +gdk_window_begin_move_drag (GdkWindow *window, + gint button, + gint root_x, + gint root_y, + guint32 timestamp) +{ + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_WINDOW_DESTROYED (window)) + return; + + /* XXX: isn't all this default on win32 ... */ +} + + /* * Setting window states */ @@ -3189,37 +3264,6 @@ gdk_window_shape_combine_region (GdkWindow *window, /* XXX: even on X implemented conditional ... */ } -void -gdk_window_begin_resize_drag (GdkWindow *window, - GdkWindowEdge edge, - gint button, - gint root_x, - gint root_y, - guint32 timestamp) -{ - g_return_if_fail (GDK_IS_WINDOW (window)); - - if (GDK_WINDOW_DESTROYED (window)) - return; - - /* XXX: isn't all this default on win32 ... */ -} - -void -gdk_window_begin_move_drag (GdkWindow *window, - gint button, - gint root_x, - gint root_y, - guint32 timestamp) -{ - g_return_if_fail (GDK_IS_WINDOW (window)); - - if (GDK_WINDOW_DESTROYED (window)) - return; - - /* XXX: isn't all this default on win32 ... */ -} - GdkWindow * gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid) { @@ -3234,6 +3278,6 @@ gdk_window_enable_synchronized_configure (GdkWindow *window) } void -gdk_window_configure_finished (GdkWindow *window); +gdk_window_configure_finished (GdkWindow *window) { } |