gint gdk_selection_owner_set(GdkWindow * owner, GdkAtom selection, guint32 time, gint send_event) { gchar *sel_name; HWND xwindow; GDK_NOTE(DND, (sel_name = gdk_atom_name(selection), g_print("gdk_selection_owner_set: %#x %#x (%s)\n", (owner ? GDK_DRAWABLE_XID(owner) : 0), selection, sel_name), g_free(sel_name))); if (selection != gdk_clipboard_atom) return FALSE; if (owner != NULL) xwindow = GDK_DRAWABLE_XID(owner); else xwindow = NULL; GDK_NOTE(DND, g_print("...OpenClipboard(%#x)\n", xwindow)); if (!OpenClipboard(xwindow)) { WIN32_API_FAILED("OpenClipboard"); return FALSE; } GDK_NOTE(DND, g_print("...EmptyClipboard()\n")); if (!EmptyClipboard()) { WIN32_API_FAILED("EmptyClipboard"); CloseClipboard(); return FALSE; } #if 0 /* No delayed rendering */ if (xwindow != NULL) SetClipboardData(CF_TEXT, NULL); #endif GDK_NOTE(DND, g_print("...CloseClipboard()\n")); if (!CloseClipboard()) { WIN32_API_FAILED("CloseClipboard"); return FALSE; } if (owner != NULL) { /* Send ourselves an ersatz selection request message so that * gdk_property_change will be called to store the clipboard data. */ SendMessage(xwindow, gdk_selection_request_msg, selection, 0); } return TRUE; }
void _gdk_win32_print_dc (HDC hdc) { HGDIOBJ obj; LOGBRUSH logbrush; EXTLOGPEN extlogpen; HRGN hrgn; RECT rect; int flag; g_print ("%p:\n", hdc); obj = GetCurrentObject (hdc, OBJ_BRUSH); GetObject (obj, sizeof (LOGBRUSH), &logbrush); g_print ("brush: %s color=%06lx hatch=%p\n", _gdk_win32_lbstyle_to_string (logbrush.lbStyle), logbrush.lbColor, (gpointer) logbrush.lbHatch); obj = GetCurrentObject (hdc, OBJ_PEN); GetObject (obj, sizeof (EXTLOGPEN), &extlogpen); g_print ("pen: %s %s %s %s w=%d %s\n", _gdk_win32_pstype_to_string (extlogpen.elpPenStyle), _gdk_win32_psstyle_to_string (extlogpen.elpPenStyle), _gdk_win32_psendcap_to_string (extlogpen.elpPenStyle), _gdk_win32_psjoin_to_string (extlogpen.elpPenStyle), extlogpen.elpWidth, _gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle)); g_print ("rop2: %s textcolor=%06lx\n", _gdk_win32_rop2_to_string (GetROP2 (hdc)), GetTextColor (hdc)); hrgn = CreateRectRgn (0, 0, 0, 0); if ((flag = GetClipRgn (hdc, hrgn)) == -1) WIN32_API_FAILED ("GetClipRgn"); else if (flag == 0) g_print ("no clip region\n"); else if (flag == 1) { GetRgnBox (hrgn, &rect); g_print ("clip region: %p bbox: %s\n", hrgn, _gdk_win32_rect_to_string (&rect)); } DeleteObject (hrgn); }
void _gdk_window_move_resize_child (GdkWindow *window, gint x, gint y, gint width, gint height) { GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkWin32PositionInfo new_info; GdkWindowParentPos parent_pos; GList *tmp_list; gint d_xoffset, d_yoffset; gint dx, dy; gboolean is_move; gboolean is_resize; GdkRegion *new_clip_region; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n", _gdk_win32_drawable_description (window), obj->x, obj->y, width, height, x, y)); dx = x - obj->x; dy = y - obj->y; is_move = dx != 0 || dy != 0; is_resize = impl->width != width || impl->height != height; if (!is_move && !is_resize) { GDK_NOTE (MISC, g_print ("... neither move or resize\n")); return; } GDK_NOTE (MISC, g_print ("... %s%s\n", is_move ? "is_move " : "", is_resize ? "is_resize" : "")); obj->x = x; obj->y = y; impl->width = width; impl->height = height; gdk_window_compute_parent_pos (impl, &parent_pos); gdk_window_compute_position (impl, &parent_pos, &new_info); new_clip_region = gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.win32_x += new_info.x; parent_pos.win32_y += new_info.y; parent_pos.clip_rect = new_info.clip_rect; d_xoffset = new_info.x_offset - impl->position_info.x_offset; d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { GDK_NOTE (MISC, g_print ("... d_offset=%+d%+d\n", d_xoffset, d_yoffset)); if (!ScrollWindowEx (GDK_WINDOW_HWND (window), -d_xoffset, -d_yoffset, /* in: scroll offsets */ NULL, /* in: scroll rect, NULL == entire client area */ NULL, /* in: restrict to */ NULL, /* in: update region */ NULL, /* out: update rect */ SW_SCROLLCHILDREN)) WIN32_API_FAILED ("ScrollWindowEx"); if (dx != d_xoffset || dy != d_yoffset || is_resize) { GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d," "NOACTIVATE|NOZORDER%s%s)\n", GDK_WINDOW_HWND (window), new_info.x, new_info.y, new_info.width, new_info.height, (is_move ? "" : "|NOMOVE"), (is_resize ? "" : "|NOSIZE"))); API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL, new_info.x, new_info.y, new_info.width, new_info.height, SWP_NOACTIVATE | SWP_NOZORDER | (is_move ? 0 : SWP_NOMOVE) | (is_resize ? 0 : SWP_NOSIZE))); } if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) { GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_SHOWNA)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA); } impl->position_info = new_info; tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } } else { if (impl->position_info.mapped && !new_info.mapped) { GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_HIDE)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE); } GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d," "NOACTIVATE|NOZORDER%s%s)\n", GDK_WINDOW_HWND (window), new_info.x, new_info.y, new_info.width, new_info.height, (is_move ? "" : "|NOMOVE"), (is_resize ? "" : "|NOSIZE"))); API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL, new_info.x, new_info.y, new_info.width, new_info.height, SWP_NOACTIVATE | SWP_NOZORDER | (is_move ? 0 : SWP_NOMOVE) | (is_resize ? 0 : SWP_NOSIZE))); tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) { GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_SHOWNA)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA); } impl->position_info = new_info; } if (new_clip_region) gdk_window_post_scroll (window, new_clip_region); }
void gdk_window_scroll (GdkWindow *window, gint dx, gint dy) { GdkRegion *invalidate_region; GdkWindowImplWin32 *impl; GdkWindowObject *obj; GList *tmp_list; GdkWindowParentPos parent_pos; HRGN native_invalidate_region; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; GDK_NOTE (EVENTS, g_print ("gdk_window_scroll: %p %d,%d\n", GDK_WINDOW_HWND (window), dx, dy)); 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); gdk_window_compute_parent_pos (impl, &parent_pos); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.win32_x += impl->position_info.x; parent_pos.win32_y += impl->position_info.y; parent_pos.clip_rect = impl->position_info.clip_rect; gdk_window_tmp_unset_bg (window); native_invalidate_region = CreateRectRgn (0, 0, 0, 0); if (native_invalidate_region == NULL) WIN32_API_FAILED ("CreateRectRgn"); API_CALL (ScrollWindowEx, (GDK_WINDOW_HWND (window), dx, dy, NULL, NULL, native_invalidate_region, NULL, SW_SCROLLCHILDREN)); if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); tmp_list = obj->children; while (tmp_list) { GDK_WINDOW_OBJECT(tmp_list->data)->x += dx; GDK_WINDOW_OBJECT(tmp_list->data)->y += dy; gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } if (native_invalidate_region != NULL) { invalidate_region = _gdk_win32_hrgn_to_region (native_invalidate_region); gdk_region_offset (invalidate_region, impl->position_info.x_offset, impl->position_info.y_offset); gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region); GDI_CALL (DeleteObject, (native_invalidate_region)); } }
void gdk_selection_convert(GdkWindow * requestor, GdkAtom selection, GdkAtom target, guint32 time) { HGLOBAL hdata; GdkSelProp *prop; guchar *ptr, *data, *datap, *p; guint i, length, slength; gchar *sel_name, *tgt_name; g_return_if_fail(requestor != NULL); if (GDK_DRAWABLE_DESTROYED(requestor)) return; GDK_NOTE(DND, (sel_name = gdk_atom_name(selection), tgt_name = gdk_atom_name(target), g_print("gdk_selection_convert: %#x %#x (%s) %#x (%s)\n", GDK_DRAWABLE_XID(requestor), selection, sel_name, target, tgt_name), g_free(sel_name), g_free(tgt_name))); if (selection == gdk_clipboard_atom) { /* Converting the CLIPBOARD selection means he wants the * contents of the clipboard. Get the clipboard data, * and store it for later. */ GDK_NOTE(DND, g_print("...OpenClipboard(%#x)\n", GDK_DRAWABLE_XID(requestor))); if (!OpenClipboard(GDK_DRAWABLE_XID(requestor))) { WIN32_API_FAILED("OpenClipboard"); return; } GDK_NOTE(DND, g_print("...GetClipboardData(CF_TEXT)\n")); if ((hdata = GetClipboardData(CF_TEXT)) != NULL) { if ((ptr = GlobalLock(hdata)) != NULL) { length = GlobalSize(hdata); GDK_NOTE(DND, g_print("...got data: %d bytes: %.10s\n", length, ptr)); slength = 0; p = ptr; for (i = 0; i < length; i++) { if (*p == '\0') break; else if (*p != '\r') slength++; p++; } data = datap = g_malloc(slength + 1); p = ptr; for (i = 0; i < length; i++) { if (*p == '\0') break; else if (*p != '\r') *datap++ = *p; p++; } *datap++ = '\0'; gdk_sel_prop_store(requestor, GDK_TARGET_STRING, 8, data, strlen(data) + 1); GlobalUnlock(hdata); } } GDK_NOTE(DND, g_print("...CloseClipboard()\n")); CloseClipboard(); /* Send ourselves an ersatz selection notify message so that we actually * fetch the data. */ SendMessage(GDK_DRAWABLE_XID(requestor), gdk_selection_notify_msg, selection, target); } else if (selection == gdk_win32_dropfiles_atom) { /* This means he wants the names of the dropped files. * gdk_dropfiles_filter already has stored the text/uri-list * data, tempoarily on gdk_root_parent's selection "property". */ GdkSelProp *prop; prop = g_hash_table_lookup(sel_prop_table, &GDK_DRAWABLE_XID(gdk_parent_root)); if (prop != NULL) { g_hash_table_remove(sel_prop_table, &GDK_DRAWABLE_XID(gdk_parent_root)); gdk_sel_prop_store(requestor, prop->type, prop->format, prop->data, prop->length); g_free(prop); SendMessage(GDK_DRAWABLE_XID(requestor), gdk_selection_notify_msg, selection, target); } } else { g_warning("gdk_selection_convert: General case not implemented"); } }