/** * mate_bg_crossfade_start: * @fade: a #MateBGCrossfade * @window: The #GdkWindow to draw crossfade on * * This function initiates a quick crossfade between two pixmaps on * the background of @window. Before initiating the crossfade both * mate_bg_crossfade_start() and mate_bg_crossfade_end() need to * be called. If animations are disabled, the crossfade is skipped, * and the window background is set immediately to the end pixmap. **/ void mate_bg_crossfade_start (MateBGCrossfade *fade, GdkWindow *window) { GSource *source; GMainContext *context; g_return_if_fail (MATE_IS_BG_CROSSFADE (fade)); g_return_if_fail (window != NULL); g_return_if_fail (fade->priv->fading_pixmap != NULL); g_return_if_fail (fade->priv->end_pixmap != NULL); g_return_if_fail (!mate_bg_crossfade_is_started (fade)); g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN); source = g_timeout_source_new (1000 / 60.0); g_source_set_callback (source, (GSourceFunc) on_tick, fade, (GDestroyNotify) on_finished); context = g_main_context_default (); fade->priv->timeout_id = g_source_attach (source, context); g_source_unref (source); fade->priv->window = window; gdk_window_set_back_pixmap (fade->priv->window, fade->priv->fading_pixmap, FALSE); draw_background (fade); fade->priv->is_first_frame = TRUE; fade->priv->total_duration = .75; fade->priv->start_time = get_current_time (); }
void _gdk_win32_window_tmp_unset_parent_bg (GdkWindow *window) { if (GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_ROOT) return; window = _gdk_window_get_impl_window (window->parent); _gdk_win32_window_tmp_unset_bg (window, FALSE); }
static void draw_background (MateBGCrossfade *fade) { if (GDK_WINDOW_TYPE (fade->priv->window) == GDK_WINDOW_ROOT) { GdkDisplay *display; display = gdk_drawable_get_display (fade->priv->window); gdk_window_clear (fade->priv->window); gdk_flush (); } else { gdk_window_invalidate_rect (fade->priv->window, NULL, FALSE); gdk_window_process_updates (fade->priv->window, FALSE); } }
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 void draw_background (MateBGCrossfade *fade) { if (GDK_WINDOW_TYPE (fade->priv->window) == GDK_WINDOW_ROOT) { XClearArea (GDK_WINDOW_XDISPLAY (fade->priv->window), GDK_WINDOW_XID (fade->priv->window), 0, 0, gdk_window_get_width (fade->priv->window), gdk_window_get_height (fade->priv->window), False); gdk_flush (); } else { gdk_window_invalidate_rect (fade->priv->window, NULL, FALSE); gdk_window_process_updates (fade->priv->window, FALSE); } }
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_window_compute_position (GdkWindowImplWin32 *window, GdkWindowParentPos *parent_pos, GdkWin32PositionInfo *info) { GdkWindowObject *wrapper; int parent_x_offset; int parent_y_offset; g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (window)); wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_WIN32 (window)->wrapper); info->big = FALSE; if (window->width <= SIZE_LIMIT) { info->width = window->width; info->x = parent_pos->x + wrapper->x - parent_pos->win32_x; } else { info->big = TRUE; info->width = SIZE_LIMIT; if (parent_pos->x + wrapper->x < -(SIZE_LIMIT/2)) { if (parent_pos->x + wrapper->x + window->width < (SIZE_LIMIT/2)) info->x = parent_pos->x + wrapper->x + window->width - info->width - parent_pos->win32_x; else info->x = -(SIZE_LIMIT/2) - parent_pos->win32_x; } else info->x = parent_pos->x + wrapper->x - parent_pos->win32_x; } if (window->height <= SIZE_LIMIT) { info->height = window->height; info->y = parent_pos->y + wrapper->y - parent_pos->win32_y; } else { info->big = TRUE; info->height = SIZE_LIMIT; if (parent_pos->y + wrapper->y < -(SIZE_LIMIT/2)) { if (parent_pos->y + wrapper->y + window->height < (SIZE_LIMIT/2)) info->y = parent_pos->y + wrapper->y + window->height - info->height - parent_pos->win32_y; else info->y = -(SIZE_LIMIT/2) - parent_pos->win32_y; } else info->y = parent_pos->y + wrapper->y - parent_pos->win32_y; } parent_x_offset = parent_pos->win32_x - parent_pos->x; parent_y_offset = parent_pos->win32_y - parent_pos->y; info->x_offset = parent_x_offset + info->x - wrapper->x; info->y_offset = parent_y_offset + info->y - wrapper->y; /* We don't considering the clipping of toplevel windows and their immediate children * by their parents, and simply always map those windows. */ if (parent_pos->clip_rect.width == G_MAXINT) info->mapped = TRUE; /* Check if the window would wrap around into the visible space in either direction */ else if (info->x + parent_x_offset < parent_pos->clip_rect.x + parent_pos->clip_rect.width - 65536 || info->x + info->width + parent_x_offset > parent_pos->clip_rect.x + 65536 || info->y + parent_y_offset < parent_pos->clip_rect.y + parent_pos->clip_rect.height - 65536 || info->y + info->height + parent_y_offset > parent_pos->clip_rect.y + 65536) info->mapped = FALSE; else info->mapped = TRUE; info->no_bg = FALSE; if (GDK_WINDOW_TYPE (wrapper) == GDK_WINDOW_CHILD) { info->clip_rect.x = wrapper->x; info->clip_rect.y = wrapper->y; info->clip_rect.width = window->width; info->clip_rect.height = window->height; gdk_rectangle_intersect (&info->clip_rect, &parent_pos->clip_rect, &info->clip_rect); info->clip_rect.x -= wrapper->x; info->clip_rect.y -= wrapper->y; } else { info->clip_rect.x = 0; info->clip_rect.y = 0; info->clip_rect.width = G_MAXINT; info->clip_rect.height = G_MAXINT; } }
void gdk_window_move_region (GdkWindow *window, GdkRegion *region, gint dx, gint dy) { GdkRegion *invalidate_region; GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkRectangle src_rect, dest_rect; HRGN hrgn; RECT clipRect, destRect; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); if (dx == 0 && dy == 0) return; /* Move the current invalid region */ if (obj->update_area) gdk_region_offset (obj->update_area, dx, dy); /* impl->position_info.clip_rect isn't meaningful for toplevels */ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) src_rect = impl->position_info.clip_rect; else { src_rect.x = 0; src_rect.y = 0; src_rect.width = impl->width; src_rect.height = impl->height; } invalidate_region = gdk_region_rectangle (&src_rect); dest_rect = src_rect; dest_rect.x += dx; dest_rect.y += dy; gdk_rectangle_intersect (&dest_rect, &src_rect, &dest_rect); if (dest_rect.width > 0 && dest_rect.height > 0) { GdkRegion *tmp_region; tmp_region = gdk_region_rectangle (&dest_rect); gdk_region_subtract (invalidate_region, tmp_region); gdk_region_destroy (tmp_region); } /* no guffaw scroll on win32 */ hrgn = _gdk_win32_gdkregion_to_hrgn(invalidate_region, 0, 0); gdk_region_destroy (invalidate_region); destRect.left = dest_rect.y; destRect.top = dest_rect.x; destRect.right = dest_rect.x + dest_rect.width; destRect.bottom = dest_rect.y + dest_rect.height; clipRect.left = src_rect.y; clipRect.top = src_rect.x; clipRect.right = src_rect.x + src_rect.width; clipRect.bottom = src_rect.y + src_rect.height; g_print ("ScrollWindowEx(%d, %d, ...) - if you see this work, remove trace;)\n", dx, dy); API_CALL(ScrollWindowEx, (GDK_WINDOW_HWND (window), dx, dy, /* in: scroll offsets */ NULL, /* in: scroll rect, NULL == entire client area */ &clipRect, /* in: restrict to */ hrgn, /* in: update region */ NULL, /* out: update rect */ SW_INVALIDATE)); API_CALL(DeleteObject, (hrgn)); }