static GdkWindow * gdk_device_win32_window_at_position (GdkDevice *device, gint *win_x, gint *win_y, GdkModifierType *mask, gboolean get_toplevel) { GdkWindow *window; POINT point, pointc; HWND hwnd, hwndc; RECT rect; GetCursorPos (&pointc); point = pointc; hwnd = WindowFromPoint (point); if (hwnd == NULL) { window = _gdk_root; *win_x = pointc.x + _gdk_offset_x; *win_y = pointc.y + _gdk_offset_y; return window; } ScreenToClient (hwnd, &point); do { if (get_toplevel && (window = gdk_win32_handle_table_lookup (hwnd)) != NULL && GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) break; hwndc = ChildWindowFromPoint (hwnd, point); ClientToScreen (hwnd, &point); ScreenToClient (hwndc, &point); } while (hwndc != hwnd && (hwnd = hwndc, 1)); window = gdk_win32_handle_table_lookup (hwnd); if (window && (win_x || win_y)) { GetClientRect (hwnd, &rect); *win_x = point.x - rect.left; *win_y = point.y - rect.top; } return window; }
static GdkWindow * gdk_device_win32_window_at_position (GdkDevice *device, gdouble *win_x, gdouble *win_y, GdkModifierType *mask, gboolean get_toplevel) { GdkWindow *window = NULL; POINT screen_pt, client_pt; HWND hwnd, hwndc; RECT rect; GetCursorPos (&screen_pt); if (get_toplevel) { /* Only consider visible children of the desktop to avoid the various * non-visible windows you often find on a running Windows box. These * might overlap our windows and cause our walk to fail. As we assume * WindowFromPoint() can find our windows, we follow similar logic * here, and ignore invisible and disabled windows. */ hwnd = GetDesktopWindow (); do { window = gdk_win32_handle_table_lookup (hwnd); if (window != NULL && GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT && GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) break; screen_to_client (hwnd, screen_pt, &client_pt); hwndc = ChildWindowFromPointEx (hwnd, client_pt, CWP_SKIPDISABLED | CWP_SKIPINVISIBLE); /* Verify that we're really inside the client area of the window */ if (hwndc != hwnd) { GetClientRect (hwndc, &rect); screen_to_client (hwndc, screen_pt, &client_pt); if (!PtInRect (&rect, client_pt)) hwndc = hwnd; } } while (hwndc != hwnd && (hwnd = hwndc, 1)); } else { hwnd = WindowFromPoint (screen_pt); /* Verify that we're really inside the client area of the window */ GetClientRect (hwnd, &rect); screen_to_client (hwnd, screen_pt, &client_pt); if (!PtInRect (&rect, client_pt)) hwnd = NULL; /* If we didn't hit any window at that point, return the desktop */ if (hwnd == NULL) { if (win_x) *win_x = screen_pt.x + _gdk_offset_x; if (win_y) *win_y = screen_pt.y + _gdk_offset_y; return _gdk_root; } window = gdk_win32_handle_table_lookup (hwnd); } if (window && (win_x || win_y)) { if (win_x) *win_x = client_pt.x; if (win_y) *win_y = client_pt.y; } return window; }
static void gdk_device_win32_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, GdkWindow **child_window, gdouble *root_x, gdouble *root_y, gdouble *win_x, gdouble *win_y, GdkModifierType *mask) { POINT point; HWND hwnd, hwndc; hwnd = GDK_WINDOW_HWND (window); GetCursorPos (&point); if (root_x) *root_x = point.x; if (root_y) *root_y = point.y; ScreenToClient (hwnd, &point); if (win_x) *win_x = point.x; if (win_y) *win_y = point.y; if (window == _gdk_root) { if (win_x) *win_x += _gdk_offset_x; if (win_y) *win_y += _gdk_offset_y; if (root_x) *root_x += _gdk_offset_x; if (root_y) *root_y += _gdk_offset_y; } if (child_window) { hwndc = ChildWindowFromPoint (hwnd, point); if (hwndc && hwndc != hwnd) *child_window = gdk_win32_handle_table_lookup (hwndc); else *child_window = NULL; /* Direct child unknown to gdk */ } if (root_window) { GdkScreen *screen; screen = gdk_window_get_screen (window); *root_window = gdk_screen_get_root_window (screen); } if (mask) *mask = get_current_mask (); }
static void gdk_device_wintab_query_state (GdkDevice *device, GdkSurface *window, GdkSurface **child_window, gdouble *root_x, gdouble *root_y, gdouble *win_x, gdouble *win_y, GdkModifierType *mask) { GdkDeviceWintab *device_wintab; POINT point; HWND hwnd, hwndc; int scale; device_wintab = GDK_DEVICE_WINTAB (device); if (window) { scale = GDK_SURFACE_IMPL_WIN32 (window->impl)->surface_scale; hwnd = GDK_SURFACE_HWND (window); } else { GdkDisplay *display = gdk_device_get_display (device); scale = GDK_WIN32_DISPLAY (display)->surface_scale; hwnd = NULL; } GetCursorPos (&point); if (root_x) *root_x = point.x / scale; if (root_y) *root_y = point.y / scale; if (hwnd) ScreenToClient (hwnd, &point); if (win_x) *win_x = point.x / scale; if (win_y) *win_y = point.y / scale; if (!window) { if (win_x) *win_x += _gdk_offset_x; if (win_y) *win_y += _gdk_offset_y; } if (hwnd && child_window) { hwndc = ChildWindowFromPoint (hwnd, point); if (hwndc && hwndc != hwnd) *child_window = gdk_win32_handle_table_lookup (hwndc); else *child_window = NULL; /* Direct child unknown to gdk */ } if (mask) { *mask = get_current_mask (); *mask &= 0xFF; /* Mask away core pointer buttons */ *mask |= ((device_wintab->button_state << 8) & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK)); } }
/** * matecomponent_control_set_transient_for: * @control: a control with associated control frame * @window: a window upon which to set the transient window. * * Attempts to make the @window transient for the toplevel * of any associated controlframe the MateComponentControl may have. **/ void matecomponent_control_set_transient_for (MateComponentControl *control, GtkWindow *window, CORBA_Environment *opt_ev) { CORBA_char *id; GdkDisplay *display; GdkWindow *win; GdkNativeWindow window_id; CORBA_Environment *ev = NULL, tmp_ev; MateComponent_ControlFrame frame; gpointer local_win; g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (MATECOMPONENT_IS_CONTROL (control)); /* FIXME: special case the local case ! * we can only do this if set_transient is virtualized * and thus we can catch it in MateComponentSocket and chain up * again if we are embedded inside an embedded thing. */ frame = control->priv->frame; if (frame == CORBA_OBJECT_NIL) return; if (opt_ev) ev = opt_ev; else { CORBA_exception_init (&tmp_ev); ev = &tmp_ev; } id = MateComponent_ControlFrame_getToplevelId (frame, ev); g_return_if_fail (!MATECOMPONENT_EX (ev) && id != NULL); window_id = matecomponent_control_x11_from_window_id (id); #ifdef TRANSIENT_DEBUG g_warning ("Got id '%s' -> %d", id, window_id); #endif CORBA_free (id); display = gtk_widget_get_display (GTK_WIDGET (window)); #if defined (GDK_WINDOWING_X11) local_win = gdk_xid_table_lookup_for_display (display, window_id); #elif defined (GDK_WINDOWING_WIN32) local_win = gdk_win32_handle_table_lookup (window_id); #endif if (local_win == NULL) win = gdk_window_foreign_new_for_display (display, window_id); else { win = GDK_WINDOW (local_win); g_object_ref (win); } g_return_if_fail (win != NULL); window_set_transient_for_gdk (window, win); if (!opt_ev) CORBA_exception_free (&tmp_ev); }