[gtk+/client-side-windows] Make win32 backend build and minimally work
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-windows] Make win32 backend build and minimally work
- Date: Wed, 1 Jul 2009 11:46:40 +0000 (UTC)
commit 5341efd4d481f8cb478e0f6d48d534ae83813d45
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jul 1 10:26:37 2009 +0200
Make win32 backend build and minimally work
gdk/win32/gdkevents-win32.c | 500 +++++--------------------------------------
gdk/win32/gdkinput-win32.h | 1 -
gdk/win32/gdkwindow-win32.c | 355 +++++++-----------------------
tests/testwindows.c | 2 +
4 files changed, 132 insertions(+), 726 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 67217e3..c919f60 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -127,7 +127,7 @@ static GSourceFuncs event_funcs = {
GPollFD event_poll_fd;
-static GdkWindow *current_window = NULL;
+static GdkWindow *current_toplevel = NULL;
static gint current_x, current_y;
static gint current_root_x, current_root_y;
static UINT client_message;
@@ -477,36 +477,16 @@ event_mask_string (GdkEventMask mask)
}
GdkGrabStatus
-gdk_pointer_grab (GdkWindow *window,
- gboolean owner_events,
- GdkEventMask event_mask,
- GdkWindow *confine_to,
- GdkCursor *cursor,
- guint32 time)
-{
- GdkWindow *native;
-
- g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
- g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
-
- native = gdk_window_get_toplevel (window);
-
- if (!GDK_IS_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (native)->impl))
- return GDK_GRAB_SUCCESS;
-
- if (!_gdk_window_has_impl (window) &&
- !gdk_window_is_viewable (window))
- return GDK_GRAB_NOT_VIEWABLE;
-
- _gdk_display_add_pointer_grab (_gdk_display,
- window,
- native,
- owner_events,
- event_mask,
- 0,
- time,
- FALSE);
-
+_gdk_windowing_pointer_grab (GdkWindow *window,
+ GdkWindow *native_window,
+ gboolean owner_events,
+ GdkEventMask event_mask,
+ GdkWindow *confine_to,
+ GdkCursor *cursor,
+ guint32 time)
+{
+ SetCapture (GDK_WINDOW_HWND (native_window));
+ /* TODO_CSW: grab brokens, confine window, cursor, input_grab */
return GDK_GRAB_SUCCESS;
}
@@ -518,61 +498,13 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
info = _gdk_display_get_last_pointer_grab (display);
if (info)
- info->serial_end = 0;
-
- _gdk_display_pointer_grab_update (display, 0);
-}
-
-static GdkWindow *
-find_real_window_for_grabbed_mouse_event (GdkWindow* reported_window,
- MSG* msg)
-{
- HWND hwnd;
- POINTS points;
- POINT pt;
- GdkWindow* other_window = NULL;
-
- points = MAKEPOINTS (msg->lParam);
- pt.x = points.x;
- pt.y = points.y;
- ClientToScreen (msg->hwnd, &pt);
-
- hwnd = WindowFromPoint (pt);
-
- if (hwnd != NULL)
{
- RECT rect;
-
- GetClientRect (hwnd, &rect);
- ScreenToClient (hwnd, &pt);
- if (!PtInRect (&rect, pt))
- {
- g_print ("find_real_window_for_grabbed_mouse_event(), PtInRect() failed\n");
- return _gdk_root;
- }
-
- other_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
- }
-
- if (other_window == NULL)
- {
- g_print ("find_real_window_for_grabbed_mouse_event(), other_window == NULL\n");
- return _gdk_root;
+ info->serial_end = 0;
+ ReleaseCapture ();
}
+ /* TODO_CSW: cursor, confines, etc */
- return other_window;
-}
-
-static GdkWindow*
-find_window_for_mouse_event (GdkWindow* reported_window,
- MSG* msg)
-{
- GdkPointerGrabInfo *info = _gdk_display_get_last_pointer_grab (_gdk_display);
-
- if (!info || !info->window || !info->owner_events)
- return reported_window;
- else
- return find_real_window_for_grabbed_mouse_event (reported_window, msg);
+ _gdk_display_pointer_grab_update (display, 0);
}
GdkGrabStatus
@@ -975,8 +907,11 @@ fixup_event (GdkEvent *event)
static void
append_event (GdkEvent *event)
{
+ GList *link;
+
fixup_event (event);
- _gdk_event_queue_append (_gdk_display, event);
+ link = _gdk_event_queue_append (_gdk_display, event);
+ _gdk_windowing_got_event (_gdk_display, link, event, 0);
GDK_NOTE (EVENTS, print_event (event));
}
@@ -1200,18 +1135,20 @@ synthesize_enter_or_leave_event (GdkWindow *window,
MSG *msg,
GdkEventType type,
GdkCrossingMode mode,
- GdkNotifyType detail,
- gint x,
- gint y)
+ GdkNotifyType detail)
{
GdkEvent *event;
+ POINT pt;
+
+ pt = msg->pt;
+ ScreenToClient (GDK_WINDOW_HWND (window), &pt);
event = gdk_event_new (type);
event->crossing.window = window;
event->crossing.subwindow = NULL;
event->crossing.time = _gdk_win32_get_next_tick (msg->time);
- event->crossing.x = x;
- event->crossing.y = y;
+ event->crossing.x = pt.x;
+ event->crossing.y = pt.y;
event->crossing.x_root = msg->pt.x + _gdk_offset_x;
event->crossing.y_root = msg->pt.y + _gdk_offset_y;
event->crossing.mode = mode;
@@ -1225,183 +1162,8 @@ synthesize_enter_or_leave_event (GdkWindow *window,
((GdkWindowObject *) window)->extension_events != 0)
_gdk_input_enter_event (window);
}
-
-static void
-synthesize_leave_event (GdkWindow *window,
- MSG *msg,
- GdkCrossingMode mode,
- GdkNotifyType detail)
-{
- POINT pt;
- GdkPointerGrabInfo *grab;
-
- grab = _gdk_display_get_last_pointer_grab (_gdk_display);
-
- if (grab && grab->window != NULL && !grab->owner_events && !(grab->event_mask & GDK_LEAVE_NOTIFY_MASK))
- return;
-
- if (!(((GdkWindowObject *) window)->event_mask & GDK_LEAVE_NOTIFY_MASK))
- return;
-
- /* Leave events are at (current_x,current_y) in current_window */
-
- if (current_window != window)
- {
- pt.x = current_x;
- pt.y = current_y;
- ClientToScreen (GDK_WINDOW_HWND (current_window), &pt);
- ScreenToClient (GDK_WINDOW_HWND (window), &pt);
- synthesize_enter_or_leave_event (window, msg, GDK_LEAVE_NOTIFY, mode, detail, pt.x, pt.y);
- }
- else
- synthesize_enter_or_leave_event (window, msg, GDK_LEAVE_NOTIFY, mode, detail, current_x, current_y);
-
- /* This would only make sense if the WM_MOUSEMOVE messages would come
- * before the respective WM_MOUSELEAVE message, which apparently they
- * do not.
- track_mouse_event (TME_CANCEL, msg->hwnd);
- */
-}
-
-static void
-synthesize_enter_event (GdkWindow *window,
- MSG *msg,
- GdkCrossingMode mode,
- GdkNotifyType detail)
-{
- POINT pt;
- GdkPointerGrabInfo *grab;
-
- grab = _gdk_display_get_last_pointer_grab (_gdk_display);
-
- if (grab && grab->window != NULL && !grab->owner_events && !(grab->event_mask & GDK_ENTER_NOTIFY_MASK))
- return;
-
- if (!(((GdkWindowObject *) window)->event_mask & GDK_ENTER_NOTIFY_MASK))
- return;
-
- /* Enter events are at GET_X_LPARAM (msg->lParam), GET_Y_LPARAM
- * (msg->lParam) in msg->hwnd
- */
-
- pt.x = GET_X_LPARAM (msg->lParam);
- pt.y = GET_Y_LPARAM (msg->lParam);
- if (msg->hwnd != GDK_WINDOW_HWND (window))
- {
- ClientToScreen (msg->hwnd, &pt);
- ScreenToClient (GDK_WINDOW_HWND (window), &pt);
- }
- synthesize_enter_or_leave_event (window, msg, GDK_ENTER_NOTIFY, mode, detail, pt.x, pt.y);
-
- track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (window));
-}
-
-static void
-synthesize_enter_events (GdkWindow *from,
- GdkWindow *to,
- MSG *msg,
- GdkCrossingMode mode,
- GdkNotifyType detail)
-{
- GdkWindow *prev = gdk_window_get_parent (to);
-
- if (prev != from)
- synthesize_enter_events (from, prev, msg, mode, detail);
-
- synthesize_enter_event (to, msg, mode, detail);
-}
-
-static void
-synthesize_leave_events (GdkWindow *from,
- GdkWindow *to,
- MSG *msg,
- GdkCrossingMode mode,
- GdkNotifyType detail)
-{
- GdkWindow *next = gdk_window_get_parent (from);
-
- synthesize_leave_event (from, msg, mode, detail);
-
- if (next != to)
- synthesize_leave_events (next, to, msg, mode, detail);
-}
static void
-synthesize_crossing_events (GdkWindow *window,
- GdkCrossingMode mode,
- MSG *msg)
-{
- GdkWindow *intermediate, *tem, *common_ancestor;
-
- if (gdk_window_is_ancestor (current_window, window))
- {
- /* Pointer has moved to an inferior window. */
- synthesize_leave_event (current_window, msg, mode, GDK_NOTIFY_INFERIOR);
-
- /* If there are intermediate windows, generate ENTER_NOTIFY
- * events for them
- */
- intermediate = gdk_window_get_parent (window);
- if (intermediate != current_window)
- {
- synthesize_enter_events (current_window, intermediate, msg, mode, GDK_NOTIFY_VIRTUAL);
- }
-
- synthesize_enter_event (window, msg, mode, GDK_NOTIFY_ANCESTOR);
- }
- else if (gdk_window_is_ancestor (window, current_window))
- {
- /* Pointer has moved to an ancestor window. */
- synthesize_leave_event (current_window, msg, mode, GDK_NOTIFY_ANCESTOR);
-
- /* If there are intermediate windows, generate LEAVE_NOTIFY
- * events for them
- */
- intermediate = gdk_window_get_parent (current_window);
- if (intermediate != window)
- {
- synthesize_leave_events (intermediate, window, msg, mode, GDK_NOTIFY_VIRTUAL);
- }
-
- synthesize_enter_event (window, msg, mode, GDK_NOTIFY_INFERIOR);
- }
- else if (current_window)
- {
- /* Find least common ancestor of current_window and window */
- tem = current_window;
- do {
- common_ancestor = gdk_window_get_parent (tem);
- tem = common_ancestor;
- } while (common_ancestor &&
- !gdk_window_is_ancestor (common_ancestor, window));
- if (common_ancestor)
- {
- synthesize_leave_event (current_window, msg, mode, GDK_NOTIFY_NONLINEAR);
- intermediate = gdk_window_get_parent (current_window);
- if (intermediate != common_ancestor)
- {
- synthesize_leave_events (intermediate, common_ancestor,
- msg, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
- }
- intermediate = gdk_window_get_parent (window);
- if (intermediate != common_ancestor)
- {
- synthesize_enter_events (common_ancestor, intermediate,
- msg, mode, GDK_NOTIFY_NONLINEAR_VIRTUAL);
- }
- synthesize_enter_event (window, msg, mode, GDK_NOTIFY_NONLINEAR);
- }
- }
- else
- {
- /* Dunno where we are coming from */
- synthesize_enter_event (window, msg, mode, GDK_NOTIFY_UNKNOWN);
- }
-
- assign_object (¤t_window, window);
-}
-
-static void
synthesize_expose_events (GdkWindow *window)
{
RECT r;
@@ -1917,15 +1679,12 @@ static void
generate_button_event (GdkEventType type,
gint button,
GdkWindow *window,
- GdkWindow *orig_window,
MSG *msg)
{
GdkEvent *event = gdk_event_new (type);
event->button.window = window;
event->button.time = _gdk_win32_get_next_tick (msg->time);
- if (window != orig_window)
- translate_mouse_coords (orig_window, window, msg);
event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
event->button.x_root = msg->pt.x + _gdk_offset_x;
@@ -1936,9 +1695,6 @@ generate_button_event (GdkEventType type,
event->button.device = _gdk_display->core_pointer;
append_event (event);
-
- if (type == GDK_BUTTON_PRESS)
- _gdk_event_button_generate (_gdk_display, event);
}
static void
@@ -2102,7 +1858,7 @@ gdk_event_translate (MSG *msg,
GdkWindow *window = NULL;
GdkWindowImplWin32 *impl;
- GdkWindow *orig_window, *new_window;
+ GdkWindow *orig_window, *new_window, *toplevel;
GdkPointerGrabInfo *grab = NULL;
GdkWindow *grab_window = NULL;
@@ -2480,57 +2236,11 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
- assign_object (&window, find_window_for_mouse_event (window, msg));
-
- grab = _gdk_display_get_last_pointer_grab (_gdk_display);
- if (grab)
- {
- grab_window = grab->window;
- grab_mask = grab->event_mask;
- grab_owner_events = grab->owner_events;
- }
-
- if (grab_window != NULL)
- {
- GdkWindow *real_window = find_real_window_for_grabbed_mouse_event (window, msg);
-
- if (real_window != current_window)
- {
- synthesize_crossing_events (real_window, GDK_CROSSING_NORMAL, msg);
- }
- }
- else
- {
- if (window != current_window)
- {
- synthesize_crossing_events (window, GDK_CROSSING_NORMAL, msg);
- }
- }
-
- if (!propagate (&window, msg, grab_window, grab_owner_events, grab_mask,
- doesnt_want_button_press, TRUE))
- break;
-
if (GDK_WINDOW_DESTROYED (window))
break;
- /* Emulate X11's automatic active grab */
- /* XXX: Do we still want this with CSW? -- Cody */
- if (!grab_window)
- {
- /* No explicit active grab, let's start one automatically */
- GDK_NOTE (EVENTS, g_print (" (automatic grab)"));
- gdk_pointer_grab (window,
- FALSE,
- ((GdkWindowObject *) window)->event_mask,
- NULL, NULL, 0);
- p_grab_automatic = TRUE;
- }
-
- g_print ("generate_button_event()\n");
-
generate_button_event (GDK_BUTTON_PRESS, button,
- window, orig_window, msg);
+ window, msg);
return_val = TRUE;
break;
@@ -2558,29 +2268,6 @@ gdk_event_translate (MSG *msg,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
- assign_object (&window, find_window_for_mouse_event (window, msg));
-
- grab = _gdk_display_get_last_pointer_grab (_gdk_display);
- if (grab != NULL)
- {
- grab_window = grab->window;
- grab_owner_events = grab->owner_events;
- grab_mask = grab->event_mask;
- }
-
- if (grab_window != NULL)
- {
- GdkWindow *real_window = find_real_window_for_grabbed_mouse_event (window, msg);
-
- if (real_window != current_window)
- synthesize_crossing_events (real_window, GDK_CROSSING_NORMAL, msg);
- }
- else
- {
- if (window != current_window)
- synthesize_crossing_events (window, GDK_CROSSING_NORMAL, msg);
- }
-
#if 0
if (((GdkWindowObject *) window)->extension_events != 0 &&
_gdk_input_ignore_core)
@@ -2590,21 +2277,8 @@ gdk_event_translate (MSG *msg,
}
#endif
- if (!propagate (&window, msg, grab_window, grab_owner_events,
- grab_mask, doesnt_want_button_release, TRUE))
- {
- }
- else if (!GDK_WINDOW_DESTROYED (window))
- {
- generate_button_event (GDK_BUTTON_RELEASE, button,
- window, orig_window, msg);
- }
-
- if (grab_window != NULL && p_grab_automatic &&
- (msg->wParam && (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)
- {
- gdk_pointer_ungrab (0);
- }
+ generate_button_event (GDK_BUTTON_RELEASE, button,
+ window, msg);
return_val = TRUE;
break;
@@ -2615,6 +2289,18 @@ gdk_event_translate (MSG *msg,
(gpointer) msg->wParam,
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
+ toplevel = gdk_window_get_toplevel (window);
+ if (current_toplevel != toplevel)
+ {
+ if (current_toplevel)
+ synthesize_enter_or_leave_event (current_toplevel, msg,
+ GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
+ synthesize_enter_or_leave_event (toplevel, msg,
+ GDK_ENTER_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
+ assign_object (¤t_toplevel, toplevel);
+ track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (toplevel));
+ }
+
/* If we haven't moved, don't create any GDK event. Windows
* sends WM_MOUSEMOVE messages after a new window is shows under
* the mouse, even if the mouse hasn't moved. This disturbs gtk.
@@ -2626,65 +2312,6 @@ gdk_event_translate (MSG *msg,
current_root_x = msg->pt.x + _gdk_offset_x;
current_root_y = msg->pt.y + _gdk_offset_y;
- assign_object (&window, find_window_for_mouse_event (window, msg));
-
- if (window != current_window)
- synthesize_crossing_events (window, GDK_CROSSING_NORMAL, msg);
-
- GdkPointerGrabInfo *grab = _gdk_display_get_last_pointer_grab (_gdk_display);
- if (grab != NULL)
- {
- grab_window = grab->window;
- grab_owner_events = grab->owner_events;
- grab_mask = grab->event_mask;
- }
-
- if (grab_window != NULL)
- {
- GdkWindow *real_window = find_real_window_for_grabbed_mouse_event (window, msg);
-
- if (real_window != current_window)
- {
- if (grab_owner_events)
- {
- synthesize_crossing_events (real_window, GDK_CROSSING_NORMAL, msg);
- }
- else if (current_window == grab_window)
- {
- synthesize_leave_event (grab_window, msg, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
- assign_object (¤t_window, _gdk_root);
- }
- else if (real_window == grab_window)
- {
- synthesize_enter_event (grab_window, msg, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
- assign_object (¤t_window, grab_window);
- }
- }
- }
- else
- {
- if (window != current_window)
- {
- synthesize_crossing_events (window, GDK_CROSSING_NORMAL, msg);
- }
- }
-
-#if 0 // XXX - this seems to always block us from creating motion notify events -- Cody
- if (!propagate (&window, msg, grab_window, grab_owner_events, grab_mask,
- doesnt_want_button_motion, TRUE))
- {
- break;
- }
-#endif
-
- if (GDK_WINDOW_DESTROYED (window))
- break;
-
- if (window != orig_window)
- {
- translate_mouse_coords (orig_window, window, msg);
- }
-
event = gdk_event_new (GDK_MOTION_NOTIFY);
event->motion.window = window;
event->motion.time = _gdk_win32_get_next_tick (msg->time);
@@ -2706,11 +2333,6 @@ gdk_event_translate (MSG *msg,
GDK_NOTE (EVENTS,
g_print (" (%d,%d)",
GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
- if (current_window != NULL &&
- (((GdkWindowObject *) current_window)->event_mask & GDK_LEAVE_NOTIFY_MASK))
- {
- synthesize_crossing_events (_gdk_root, GDK_CROSSING_NORMAL, msg);
- }
break;
@@ -2720,23 +2342,17 @@ gdk_event_translate (MSG *msg,
if (!gdk_win32_handle_table_lookup ((GdkNativeWindow) WindowFromPoint (msg->pt)))
{
- GdkNotifyType detail;
-
- if (GDK_WINDOW_TYPE (current_window) != GDK_WINDOW_CHILD)
- detail = GDK_NOTIFY_ANCESTOR;
- else
- detail = GDK_NOTIFY_UNKNOWN;
-
/* we are only interested if we don't know the new window */
- synthesize_enter_or_leave_event (current_window, msg,
- GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, detail,
- current_x, current_y);
- assign_object (¤t_window, _gdk_root);
+ if (current_toplevel)
+ synthesize_enter_or_leave_event (current_toplevel, msg,
+ GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
+ assign_object (¤t_toplevel, NULL);
}
else
{
GDK_NOTE (EVENTS, g_print (" (ignored)"));
}
+
return_val = TRUE;
break;
@@ -2763,24 +2379,6 @@ gdk_event_translate (MSG *msg,
assign_object (&window, new_window);
}
- grab = _gdk_display_get_last_pointer_grab (_gdk_display);
- if (grab != NULL)
- {
- grab_window = grab->window;
- grab_mask = grab->event_mask;
- grab_owner_events = grab->owner_events;
- }
-
- if (!propagate (&window, msg, grab_window,
- grab_owner_events,
- grab_mask,
- doesnt_want_scroll,
- TRUE))
- break;
-
- if (GDK_WINDOW_DESTROYED (window))
- break;
-
ScreenToClient (msg->hwnd, &point);
event = gdk_event_new (GDK_SCROLL);
@@ -2939,6 +2537,7 @@ gdk_event_translate (MSG *msg,
GDK_NOTE (EVENTS, g_print (" %#x %#x",
LOWORD (msg->lParam), HIWORD (msg->lParam)));
+#ifdef TODO_CSW
grab = _gdk_display_get_last_pointer_grab (_gdk_display);
if (grab != NULL)
{
@@ -2962,6 +2561,8 @@ gdk_event_translate (MSG *msg,
return_val = TRUE;
*ret_valp = TRUE;
}
+#endif
+
break;
case WM_SHOWWINDOW:
@@ -3480,9 +3081,6 @@ gdk_event_translate (MSG *msg,
break;
case WM_DESTROY:
- if (window == current_window)
- assign_object (¤t_window, _gdk_root);
-
grab = _gdk_display_get_last_pointer_grab (_gdk_display);
if (grab != NULL)
{
diff --git a/gdk/win32/gdkinput-win32.h b/gdk/win32/gdkinput-win32.h
index 1f402ad..3d168e1 100644
--- a/gdk/win32/gdkinput-win32.h
+++ b/gdk/win32/gdkinput-win32.h
@@ -32,7 +32,6 @@
typedef struct _GdkAxisInfo GdkAxisInfo;
typedef struct _GdkDevicePrivate GdkDevicePrivate;
-typedef struct _GdkInputWindow GdkInputWindow;
/* information about a device axis */
struct _GdkAxisInfo
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index d220da1..96f89e8 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -972,7 +972,7 @@ show_window_internal (GdkWindow *window,
GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s%s\n",
GDK_WINDOW_HWND (window),
_gdk_win32_window_state_to_string (private->state),
- //(raise ? " raise" : ""),
+ (raise ? " raise" : ""),
(deiconify ? " deiconify" : "")));
/* If asked to show (not deiconify) an withdrawn and iconified
@@ -1102,7 +1102,8 @@ show_window_internal (GdkWindow *window,
}
static void
-gdk_win32_window_show (GdkWindow *window)
+gdk_win32_window_show (GdkWindow *window,
+ gboolean already_mapped)
{
show_window_internal (window, FALSE, FALSE);
}
@@ -1432,195 +1433,6 @@ gdk_win32_window_reparent (GdkWindow *window,
}
static void
-erase_background (GdkWindow *window,
- HDC hdc)
-{
-#if 0
- HDC bgdc = NULL;
- HBRUSH hbr = NULL;
- HPALETTE holdpal = NULL;
- RECT rect;
- COLORREF bg;
- GdkColormap *colormap;
- GdkColormapPrivateWin32 *colormap_private;
- int x, y;
- int x_offset, y_offset;
-
- if (((GdkWindowObject *) window)->input_only ||
- ((GdkWindowObject *) window)->bg_pixmap == GDK_NO_BG ||
- GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->no_bg)
- {
- return;
- }
-
- colormap = gdk_drawable_get_colormap (window);
-
- if (colormap &&
- (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
- colormap->visual->type == GDK_VISUAL_STATIC_COLOR))
- {
- int k;
-
- colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
-
- if (!(holdpal = SelectPalette (hdc, colormap_private->hpal, FALSE)))
- WIN32_GDI_FAILED ("SelectPalette");
- else if ((k = RealizePalette (hdc)) == GDI_ERROR)
- WIN32_GDI_FAILED ("RealizePalette");
- else if (k > 0)
- GDK_NOTE (COLORMAP, g_print ("erase_background: realized %p: %d colors\n",
- colormap_private->hpal, k));
- }
-
- x_offset = y_offset = 0;
- while (window && ((GdkWindowObject *) window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
- {
- /* If this window should have the same background as the parent,
- * fetch the parent. (And if the same goes for the parent, fetch
- * the grandparent, etc.)
- */
- x_offset += ((GdkWindowObject *) window)->x;
- y_offset += ((GdkWindowObject *) window)->y;
- window = GDK_WINDOW (((GdkWindowObject *) window)->parent);
- }
-
- if (GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->no_bg)
- {
- /* Improves scolling effect, e.g. main buttons of testgtk */
- return;
- }
-
- GetClipBox (hdc, &rect);
-
- if (((GdkWindowObject *) window)->bg_pixmap == NULL)
- {
- bg = _gdk_win32_colormap_color (GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->colormap,
- ((GdkWindowObject *) window)->bg_color.pixel);
-
- if (!(hbr = CreateSolidBrush (bg)))
- WIN32_GDI_FAILED ("CreateSolidBrush");
- else if (!FillRect (hdc, &rect, hbr))
- WIN32_GDI_FAILED ("FillRect");
- if (hbr != NULL)
- DeleteObject (hbr);
- }
- else if (((GdkWindowObject *) window)->bg_pixmap != GDK_NO_BG)
- {
- GdkPixmap *pixmap = ((GdkWindowObject *) window)->bg_pixmap;
- GdkPixmapImplWin32 *pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
-
- if (x_offset == 0 && y_offset == 0 &&
- pixmap_impl->width <= 8 && pixmap_impl->height <= 8)
- {
- if (!(hbr = CreatePatternBrush (GDK_PIXMAP_HBITMAP (pixmap))))
- WIN32_GDI_FAILED ("CreatePatternBrush");
- else if (!FillRect (hdc, &rect, hbr))
- WIN32_GDI_FAILED ("FillRect");
- if (hbr != NULL)
- DeleteObject (hbr);
- }
- else
- {
- HGDIOBJ oldbitmap;
-
- if (!(bgdc = CreateCompatibleDC (hdc)))
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- return;
- }
- if (!(oldbitmap = SelectObject (bgdc, GDK_PIXMAP_HBITMAP (pixmap))))
- {
- WIN32_GDI_FAILED ("SelectObject");
- DeleteDC (bgdc);
- return;
- }
- x = -x_offset;
- while (x < rect.right)
- {
- if (x + pixmap_impl->width >= rect.left)
- {
- y = -y_offset;
- while (y < rect.bottom)
- {
- if (y + pixmap_impl->height >= rect.top)
- {
- if (!BitBlt (hdc, x, y,
- pixmap_impl->width, pixmap_impl->height,
- bgdc, 0, 0, SRCCOPY))
- {
- WIN32_GDI_FAILED ("BitBlt");
- SelectObject (bgdc, oldbitmap);
- DeleteDC (bgdc);
- return;
- }
- }
- y += pixmap_impl->height;
- }
- }
- x += pixmap_impl->width;
- }
- SelectObject (bgdc, oldbitmap);
- DeleteDC (bgdc);
- }
- }
-#endif
-}
-
-static void
-gdk_win32_window_clear_area (GdkWindow *window,
- gint x,
- gint y,
- gint width,
- gint height,
- gboolean send_expose)
-{
- GdkWindowImplWin32 *impl;
- GdkWindowObject *obj;
-
- obj = GDK_WINDOW_OBJECT (window);
- impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
-
- if (!GDK_WINDOW_DESTROYED (window))
- {
- HDC hdc;
- RECT rect;
-
- hdc = GetDC (GDK_WINDOW_HWND (window));
-
- if (!send_expose)
- {
- if (width == 0)
- width = obj->width - x;
- if (height == 0)
- height = obj->height - y;
- GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area: %p: "
- "%dx%d %+d%+d\n",
- GDK_WINDOW_HWND (window),
- width, height, x, y));
- IntersectClipRect (hdc, x, y, x + width, y + height);
- erase_background (window, hdc);
- GDI_CALL (ReleaseDC, (GDK_WINDOW_HWND (window), hdc));
- }
- else
- {
- /* The background should be erased before the expose event is
- generated */
- IntersectClipRect (hdc, x, y, x + width, y + height);
- erase_background (window, hdc);
- GDI_CALL (ReleaseDC, (GDK_WINDOW_HWND (window), hdc));
-
- rect.left = x;
- rect.right = x + width;
- rect.top = y;
- rect.bottom = y + height;
-
- GDI_CALL (InvalidateRect, (GDK_WINDOW_HWND (window), &rect, TRUE));
- UpdateWindow (GDK_WINDOW_HWND (window));
- }
- }
-}
-
-static void
gdk_win32_window_raise (GdkWindow *window)
{
if (!GDK_WINDOW_DESTROYED (window))
@@ -2263,37 +2075,32 @@ gdk_win32_window_get_geometry (GdkWindow *window,
}
static gint
-gdk_win32_window_get_origin (GdkWindow *window,
- gint *x,
- gint *y)
-{
- gint return_val;
- gint tx = 0;
- gint ty = 0;
-
- if (!GDK_WINDOW_DESTROYED (window))
- {
- POINT pt;
-
- pt.x = 0;
- pt.y = 0;
- ClientToScreen (GDK_WINDOW_HWND (window), &pt);
- tx = pt.x;
- ty = pt.y;
- return_val = 1;
- }
- else
- return_val = 0;
+gdk_win32_window_get_root_coords (GdkWindow *window,
+ gint x,
+ gint y,
+ gint *root_x,
+ gint *root_y)
+{
+ gint tx;
+ gint ty;
+ POINT pt;
+
+ pt.x = x;
+ pt.y = y;
+ ClientToScreen (GDK_WINDOW_HWND (window), &pt);
+ tx = pt.x;
+ ty = pt.y;
if (x)
- *x = tx + _gdk_offset_x;
+ *root_x = tx + _gdk_offset_x;
if (y)
- *y = ty + _gdk_offset_y;
+ *root_y = ty + _gdk_offset_y;
- GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %p: %+d%+d\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_get_root_coords: %p: %+d%+d %+d%+d\n",
GDK_WINDOW_HWND (window),
+ x, y,
tx, ty));
- return return_val;
+ return 1;
}
static gboolean
@@ -2301,7 +2108,7 @@ gdk_win32_window_get_deskrelative_origin (GdkWindow *window,
gint *x,
gint *y)
{
- return gdk_window_get_origin (window, x, y);
+ return gdk_win32_window_get_root_coords (window, 0, 0, x, y);
}
static void
@@ -2373,24 +2180,50 @@ gdk_window_get_frame_extents (GdkWindow *window,
r.left, r.top));
}
-GdkWindow*
-_gdk_windowing_window_get_pointer (GdkDisplay *display,
- GdkWindow *window,
- gint *x,
- gint *y,
- GdkModifierType *mask)
-{
- GdkWindow *return_val;
- POINT screen_point, point;
- HWND hwnd, hwndc;
+
+static GdkModifierType
+get_current_mask (void)
+{
+ GdkModifierType mask;
BYTE kbd[256];
- g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+ GetKeyboardState (kbd);
+ mask = 0;
+ if (kbd[VK_SHIFT] & 0x80)
+ mask |= GDK_SHIFT_MASK;
+ if (kbd[VK_CAPITAL] & 0x80)
+ mask |= GDK_LOCK_MASK;
+ if (kbd[VK_CONTROL] & 0x80)
+ mask |= GDK_CONTROL_MASK;
+ if (kbd[VK_MENU] & 0x80)
+ mask |= GDK_MOD1_MASK;
+ if (kbd[VK_LBUTTON] & 0x80)
+ mask |= GDK_BUTTON1_MASK;
+ if (kbd[VK_MBUTTON] & 0x80)
+ mask |= GDK_BUTTON2_MASK;
+ if (kbd[VK_RBUTTON] & 0x80)
+ mask |= GDK_BUTTON3_MASK;
+
+ return mask;
+}
+
+static gboolean
+gdk_window_win32_get_pointer (GdkWindow *window,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
+{
+ gboolean return_val;
+ POINT point;
+ HWND hwnd, hwndc;
+
+ g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), FALSE);
- return_val = NULL;
- GetCursorPos (&screen_point);
- point = screen_point;
- ScreenToClient (GDK_WINDOW_HWND (window), &point);
+ return_val = TRUE;
+
+ hwnd = GDK_WINDOW_HWND (window);
+ GetCursorPos (&point);
+ ScreenToClient (hwnd, &point);
*x = point.x;
*y = point.y;
@@ -2401,45 +2234,12 @@ _gdk_windowing_window_get_pointer (GdkDisplay *display,
*y += _gdk_offset_y;
}
- hwnd = WindowFromPoint (screen_point);
- if (hwnd != NULL)
- {
- gboolean done = FALSE;
-
- while (!done)
- {
- point = screen_point;
- ScreenToClient (hwnd, &point);
- hwndc = ChildWindowFromPoint (hwnd, point);
- if (hwndc == NULL)
- done = TRUE;
- else if (hwndc == hwnd)
- done = TRUE;
- else
- hwnd = hwndc;
- }
-
- return_val = gdk_window_lookup ((GdkNativeWindow) hwnd);
- }
- else
- return_val = NULL;
-
- GetKeyboardState (kbd);
- *mask = 0;
- if (kbd[VK_SHIFT] & 0x80)
- *mask |= GDK_SHIFT_MASK;
- if (kbd[VK_CAPITAL] & 0x80)
- *mask |= GDK_LOCK_MASK;
- if (kbd[VK_CONTROL] & 0x80)
- *mask |= GDK_CONTROL_MASK;
- if (kbd[VK_MENU] & 0x80)
- *mask |= GDK_MOD1_MASK;
- if (kbd[VK_LBUTTON] & 0x80)
- *mask |= GDK_BUTTON1_MASK;
- if (kbd[VK_MBUTTON] & 0x80)
- *mask |= GDK_BUTTON2_MASK;
- if (kbd[VK_RBUTTON] & 0x80)
- *mask |= GDK_BUTTON3_MASK;
+ hwndc = ChildWindowFromPoint (hwnd, point);
+ if (hwndc != NULL && hwndc != hwnd &&
+ !gdk_win32_handle_table_lookup ((GdkNativeWindow) hwndc))
+ return_val = FALSE; /* Direct child unknown to gdk */
+
+ *mask = get_current_mask ();
return return_val;
}
@@ -2451,10 +2251,16 @@ _gdk_windowing_get_pointer (GdkDisplay *display,
gint *y,
GdkModifierType *mask)
{
+ POINT point;
+
g_return_if_fail (display == _gdk_display);
*screen = _gdk_screen;
- _gdk_windowing_window_get_pointer (_gdk_display, _gdk_root, x, y, mask);
+ GetCursorPos (&point);
+ *x = point.x + _gdk_offset_x;
+ *y = point.y + _gdk_offset_y;
+
+ *mask = get_current_mask ();
}
void
@@ -3706,7 +3512,7 @@ gdk_window_configure_finished (GdkWindow *window)
}
void
-gdk_window_beep (GdkWindow *window)
+_gdk_windowing_window_beep (GdkWindow *window)
{
gdk_display_beep (_gdk_display);
}
@@ -3848,7 +3654,8 @@ gdk_window_impl_iface_init (GdkWindowImplIface *iface)
iface->reparent = gdk_win32_window_reparent;
iface->set_cursor = gdk_win32_window_set_cursor;
iface->get_geometry = gdk_win32_window_get_geometry;
- iface->get_origin = gdk_win32_window_get_origin;
+ iface->get_pointer = gdk_window_win32_get_pointer;
+ iface->get_root_coords = gdk_win32_window_get_root_coords;
iface->shape_combine_region = gdk_win32_window_shape_combine_region;
iface->input_shape_combine_region = gdk_win32_input_shape_combine_region;
iface->get_deskrelative_origin = gdk_win32_window_get_deskrelative_origin;
diff --git a/tests/testwindows.c b/tests/testwindows.c
index ca8d8e5..06a0ef4 100644
--- a/tests/testwindows.c
+++ b/tests/testwindows.c
@@ -1,5 +1,7 @@
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
#include <X11/Xlib.h>
+#endif
static GtkWidget *darea;
static GtkTreeStore *window_store = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]