📄 gdkevents-win32.c
字号:
*/ 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 voidsynthesize_expose_events (GdkWindow *window){ RECT r; HDC hdc; GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl); GList *list = gdk_window_get_children (window); GList *head = list; GdkEvent *event; int k; while (list) { synthesize_expose_events ((GdkWindow *) list->data); list = list->next; } g_list_free (head); if (((GdkWindowObject *) window)->input_only) ; else if (!(hdc = GetDC (impl->handle))) WIN32_GDI_FAILED ("GetDC"); else { if ((k = GetClipBox (hdc, &r)) == ERROR) WIN32_GDI_FAILED ("GetClipBox"); else if (k != NULLREGION) { event = gdk_event_new (GDK_EXPOSE); event->expose.window = window; event->expose.area.x = r.left; event->expose.area.y = r.top; event->expose.area.width = r.right - r.left; event->expose.area.height = r.bottom - r.top; event->expose.region = gdk_region_rectangle (&(event->expose.area)); event->expose.count = 0; append_event (gdk_drawable_get_display (window), event); } if (!ReleaseDC (impl->handle, hdc)) WIN32_GDI_FAILED ("ReleaseDC"); }}static voidupdate_colors (GdkWindow *window, gboolean top){ HDC hdc; GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl); GList *list = gdk_window_get_children (window); GList *head = list; GDK_NOTE (COLORMAP, (top ? g_print ("update_colors:") : (void) 0)); while (list) { update_colors ((GdkWindow *) list->data, FALSE); list = list->next; } g_list_free (head); if (((GdkWindowObject *) window)->input_only || impl->colormap == NULL) return; if (!(hdc = GetDC (impl->handle))) WIN32_GDI_FAILED ("GetDC"); else { GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (impl->colormap); HPALETTE holdpal; gint k; if ((holdpal = SelectPalette (hdc, cmapp->hpal, TRUE)) == NULL) WIN32_GDI_FAILED ("SelectPalette"); else if ((k = RealizePalette (hdc)) == GDI_ERROR) WIN32_GDI_FAILED ("RealizePalette"); else { GDK_NOTE (COLORMAP, (k > 0 ? g_print (" %p pal=%p: realized %d colors\n" "update_colors:", impl->handle, cmapp->hpal, k) : (void) 0, g_print (" %p", impl->handle))); if (!UpdateColors (hdc)) WIN32_GDI_FAILED ("UpdateColors"); SelectPalette (hdc, holdpal, TRUE); RealizePalette (hdc); } if (!ReleaseDC (impl->handle, hdc)) WIN32_GDI_FAILED ("ReleaseDC"); } GDK_NOTE (COLORMAP, (top ? g_print ("\n") : (void) 0));}static voidtranslate_mouse_coords (GdkWindow *window1, GdkWindow *window2, MSG *msg){ POINT pt; pt.x = GET_X_LPARAM (msg->lParam); pt.y = GET_Y_LPARAM (msg->lParam); ClientToScreen (GDK_WINDOW_HWND (window1), &pt); ScreenToClient (GDK_WINDOW_HWND (window2), &pt); msg->lParam = MAKELPARAM (pt.x, pt.y);}/* The check_extended flag controls whether to check if the windows want * events from extended input devices and if the message should be skipped * because an extended input device is active */static gbooleanpropagate (GdkWindow **window, MSG *msg, GdkWindow *grab_window, gboolean grab_owner_events, gint grab_mask, gboolean (*doesnt_want_it) (gint mask, MSG *msg), gboolean check_extended){ gboolean in_propagation = FALSE; if (grab_window != NULL && !grab_owner_events) { /* Event source is grabbed with owner_events FALSE */ /* See if the event should be ignored because an extended input device * is used */ if (check_extended && ((GdkWindowObject *) grab_window)->extension_events != 0 && _gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print (" (ignored for grabber)")); return FALSE; } if ((*doesnt_want_it) (grab_mask, msg)) { GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)")); return FALSE; } else { GDK_NOTE (EVENTS, g_print (" (to grabber)")); assign_object (window, grab_window); return TRUE; } } while (TRUE) { /* See if the event should be ignored because an extended input device * is used */ if (check_extended && ((GdkWindowObject *) *window)->extension_events != 0 && _gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print (" (ignored)")); return FALSE; } if ((*doesnt_want_it) (((GdkWindowObject *) *window)->event_mask, msg)) { /* Owner doesn't want it, propagate to parent. */ GdkWindow *parent = gdk_window_get_parent (*window); if (parent == _gdk_parent_root || parent == NULL) { /* No parent; check if grabbed */ if (grab_window != NULL) { /* Event source is grabbed with owner_events TRUE */ /* See if the event should be ignored because an extended * input device is used */ if (check_extended && ((GdkWindowObject *) grab_window)->extension_events != 0 && _gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print (" (ignored for grabber)")); return FALSE; } if ((*doesnt_want_it) (grab_mask, msg)) { /* Grabber doesn't want it either */ GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)")); return FALSE; } else { /* Grabbed! */ GDK_NOTE (EVENTS, g_print (" (to grabber)")); assign_object (window, grab_window); return TRUE; } } else { GDK_NOTE (EVENTS, g_print (" (undelivered)")); return FALSE; } } else { assign_object (window, parent); in_propagation = TRUE; /* The only branch where we actually continue the loop */ } } else return TRUE; }}static gbooleandoesnt_want_key (gint mask, MSG *msg){ return (((msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) && !(mask & GDK_KEY_RELEASE_MASK)) || ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) && !(mask & GDK_KEY_PRESS_MASK)));}static gbooleandoesnt_want_char (gint mask, MSG *msg){ return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));}static gbooleandoesnt_want_button_press (gint mask, MSG *msg){ return !(mask & GDK_BUTTON_PRESS_MASK);}static gbooleandoesnt_want_button_release (gint mask, MSG *msg){ return !(mask & GDK_BUTTON_RELEASE_MASK);}static gbooleandoesnt_want_button_motion (gint mask, MSG *msg){ return !((mask & GDK_POINTER_MOTION_MASK) || ((msg->wParam & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) && (mask & GDK_BUTTON_MOTION_MASK)) || ((msg->wParam & MK_LBUTTON) && (mask & GDK_BUTTON1_MOTION_MASK)) || ((msg->wParam & MK_MBUTTON) && (mask & GDK_BUTTON2_MOTION_MASK)) || ((msg->wParam & MK_RBUTTON) && (mask & GDK_BUTTON3_MOTION_MASK)));}static gbooleandoesnt_want_scroll (gint mask, MSG *msg){#if 0 return !(mask & GDK_SCROLL_MASK);#else return !(mask & GDK_BUTTON_PRESS_MASK);#endif}static voidhandle_configure_event (MSG *msg, GdkWindow *window){ RECT client_rect; POINT point; GetClientRect (msg->hwnd, &client_rect); point.x = client_rect.left; /* always 0 */ point.y = client_rect.top; /* top level windows need screen coords */ if (gdk_window_get_parent (window) == _gdk_parent_root) { ClientToScreen (msg->hwnd, &point); point.x += _gdk_offset_x; point.y += _gdk_offset_y; } GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->width = client_rect.right - client_rect.left; GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->height = client_rect.bottom - client_rect.top; ((GdkWindowObject *) window)->x = point.x; ((GdkWindowObject *) window)->y = point.y; if (((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK) { GdkEvent *event = gdk_event_new (GDK_CONFIGURE); event->configure.window = window; event->configure.width = client_rect.right - client_rect.left; event->configure.height = client_rect.bottom - client_rect.top; event->configure.x = point.x; event->configure.y = point.y; append_event (gdk_drawable_get_display (window), event); }}static voiderase_background (GdkWindow *window, HDC hdc){ 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)->position_info.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)->position_info.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; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -