gdkwindow-x11.c

来自「linux下电话本所依赖的一些图形库」· C语言 代码 · 共 2,336 行 · 第 1/5 页

C
2,336
字号
		   x, y);  window_private->x = x;  window_private->y = y;    /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like   * the root window   */  if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)    new_parent = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (window));    window_private->parent = (GdkWindowObject *)new_parent;  /* Switch the window type as appropriate */  switch (GDK_WINDOW_TYPE (new_parent))    {    case GDK_WINDOW_ROOT:    case GDK_WINDOW_FOREIGN:      was_toplevel = WINDOW_IS_TOPLEVEL (window);            if (impl->toplevel_window_type != -1)	GDK_WINDOW_TYPE (window) = impl->toplevel_window_type;      else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)	GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;      if (WINDOW_IS_TOPLEVEL (window) && !was_toplevel)	setup_toplevel_window (window, new_parent);      break;    case GDK_WINDOW_TOPLEVEL:    case GDK_WINDOW_CHILD:    case GDK_WINDOW_DIALOG:    case GDK_WINDOW_TEMP:      if (WINDOW_IS_TOPLEVEL (window))	{	  /* Save the original window type so we can restore it if the	   * window is reparented back to be a toplevel	   */	  impl->toplevel_window_type = GDK_WINDOW_TYPE (window);	  GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;	  if (impl->toplevel)	    {	      if (impl->toplevel->focus_window)		{		  XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window);		  _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window);		}			      gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), 					      impl->toplevel);	      g_free (impl->toplevel);	      impl->toplevel = NULL;	    }	}    }  if (old_parent_private)    old_parent_private->children = g_list_remove (old_parent_private->children, window);    if ((old_parent_private &&       (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||      (!old_parent_private && parent_private->guffaw_gravity))    gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);    parent_private->children = g_list_prepend (parent_private->children, window);  _gdk_window_init_position (GDK_WINDOW (window_private));}void_gdk_windowing_window_clear_area (GdkWindow *window,				  gint       x,				  gint       y,				  gint       width,				  gint       height){  g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (!GDK_WINDOW_DESTROYED (window))    XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),		x, y, width, height, False);}void_gdk_windowing_window_clear_area_e (GdkWindow *window,				    gint       x,				    gint       y,				    gint       width,				    gint       height){  g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (!GDK_WINDOW_DESTROYED (window))    XClearArea (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),		x, y, width, height, True);}/** * gdk_window_raise: * @window: a #GdkWindow *  * Raises @window to the top of the Z-order (stacking order), so that * other windows with the same parent window appear below @window. * This is true whether or not the windows are visible. * * If @window is a toplevel, the window manager may choose to deny the * request to move the window in the Z-order, gdk_window_raise() only * requests the restack, does not guarantee it. *  **/voidgdk_window_raise (GdkWindow *window){  g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (!GDK_WINDOW_DESTROYED (window))    XRaiseWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));}/** * gdk_window_lower: * @window: a #GdkWindow *  * Lowers @window to the bottom of the Z-order (stacking order), so that * other windows with the same parent window appear above @window. * This is true whether or not the other windows are visible. * * If @window is a toplevel, the window manager may choose to deny the * request to move the window in the Z-order, gdk_window_lower() only * requests the restack, does not guarantee it. * * Note that gdk_window_show() raises the window again, so don't call this * function before gdk_window_show(). (Try gdk_window_show_unraised().) *  **/voidgdk_window_lower (GdkWindow *window){  g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (!GDK_WINDOW_DESTROYED (window))    XLowerWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window));}/** * gdk_window_focus: * @window: a #GdkWindow * @timestamp: timestamp of the event triggering the window focus * * Sets keyboard focus to @window. If @window is not onscreen this * will not work. In most cases, gtk_window_present() should be used on * a #GtkWindow, rather than calling this function. *  **/voidgdk_window_focus (GdkWindow *window,                  guint32    timestamp){  GdkDisplay *display;    g_return_if_fail (GDK_IS_WINDOW (window));  if (GDK_WINDOW_DESTROYED (window))    return;  display = GDK_WINDOW_DISPLAY (window);  if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window),					   gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE)))    {      XEvent xev;      xev.xclient.type = ClientMessage;      xev.xclient.serial = 0;      xev.xclient.send_event = True;      xev.xclient.window = GDK_WINDOW_XWINDOW (window);      xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,									"_NET_ACTIVE_WINDOW");      xev.xclient.format = 32;      xev.xclient.data.l[0] = 1; /* requestor type; we're an app */      xev.xclient.data.l[1] = timestamp;      xev.xclient.data.l[2] = None; /* currently active window */      xev.xclient.data.l[3] = 0;      xev.xclient.data.l[4] = 0;            XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False,                  SubstructureRedirectMask | SubstructureNotifyMask,                  &xev);    }  else    {      XRaiseWindow (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window));      /* There is no way of knowing reliably whether we are viewable;       * _gdk_x11_set_input_focus_safe() traps errors asynchronously.       */      _gdk_x11_set_input_focus_safe (display, GDK_WINDOW_XID (window),				     RevertToParent,				     timestamp);    }}/** * gdk_window_set_hints: * @window: a #GdkWindow * @x: ignored field, does not matter * @y: ignored field, does not matter * @min_width: minimum width hint * @min_height: minimum height hint * @max_width: max width hint * @max_height: max height hint * @flags: logical OR of GDK_HINT_POS, GDK_HINT_MIN_SIZE, and/or GDK_HINT_MAX_SIZE * * This function is broken and useless and you should ignore it. * If using GTK+, use functions such as gtk_window_resize(), gtk_window_set_size_request(), * gtk_window_move(), gtk_window_parse_geometry(), and gtk_window_set_geometry_hints(), * depending on what you're trying to do. * * If using GDK directly, use gdk_window_set_geometry_hints(). *  **/voidgdk_window_set_hints (GdkWindow *window,		      gint       x,		      gint       y,		      gint       min_width,		      gint       min_height,		      gint       max_width,		      gint       max_height,		      gint       flags){  XSizeHints size_hints;    g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (GDK_WINDOW_DESTROYED (window))    return;    size_hints.flags = 0;    if (flags & GDK_HINT_POS)    {      size_hints.flags |= PPosition;      size_hints.x = x;      size_hints.y = y;    }    if (flags & GDK_HINT_MIN_SIZE)    {      size_hints.flags |= PMinSize;      size_hints.min_width = min_width;      size_hints.min_height = min_height;    }    if (flags & GDK_HINT_MAX_SIZE)    {      size_hints.flags |= PMaxSize;      size_hints.max_width = max_width;      size_hints.max_height = max_height;    }    /* FIXME: Would it be better to delete this property if   *        flags == 0? It would save space on the server   */  XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window),		     GDK_WINDOW_XID (window),		     &size_hints);}/** * gdk_window_set_type_hint: * @window: A toplevel #GdkWindow * @hint: A hint of the function this window will have * * The application can use this call to provide a hint to the window * manager about the functionality of a window. The window manager * can use this information when determining the decoration and behaviour * of the window. * * The hint must be set before the window is mapped. **/voidgdk_window_set_type_hint (GdkWindow        *window,			  GdkWindowTypeHint hint){  GdkDisplay *display;  Atom atom;    g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (GDK_WINDOW_DESTROYED (window))    return;  display = gdk_drawable_get_display (window);  switch (hint)    {    case GDK_WINDOW_TYPE_HINT_DIALOG:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DIALOG");      break;    case GDK_WINDOW_TYPE_HINT_MENU:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_MENU");      break;    case GDK_WINDOW_TYPE_HINT_TOOLBAR:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_TOOLBAR");      break;    case GDK_WINDOW_TYPE_HINT_UTILITY:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_UTILITY");      break;    case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_SPLASH");      break;    case GDK_WINDOW_TYPE_HINT_DOCK:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DOCK");      break;    case GDK_WINDOW_TYPE_HINT_DESKTOP:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_DESKTOP");      break;    default:      g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);      /* Fall thru */    case GDK_WINDOW_TYPE_HINT_NORMAL:      atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE_NORMAL");      break;    }  XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),		   gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_WINDOW_TYPE"),		   XA_ATOM, 32, PropModeReplace,		   (guchar *)&atom, 1);}static voidgdk_wmspec_change_state (gboolean   add,			 GdkWindow *window,			 GdkAtom    state1,			 GdkAtom    state2){  GdkDisplay *display = GDK_WINDOW_DISPLAY (window);  XEvent xev;  #define _NET_WM_STATE_REMOVE        0    /* remove/unset property */#define _NET_WM_STATE_ADD           1    /* add/set property */#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */      xev.xclient.type = ClientMessage;  xev.xclient.serial = 0;  xev.xclient.send_event = True;  xev.xclient.window = GDK_WINDOW_XID (window);  xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");  xev.xclient.format = 32;  xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;  xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);  xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);  xev.xclient.data.l[3] = 0;  xev.xclient.data.l[4] = 0;    XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False,	      SubstructureRedirectMask | SubstructureNotifyMask,	      &xev);}/** * gdk_window_set_modal_hint: * @window: A toplevel #GdkWindow * @modal: TRUE if the window is modal, FALSE otherwise. * * The application can use this hint to tell the window manager * that a certain window has modal behaviour. The window manager * can use this information to handle modal windows in a special * way. * * You should only use this on windows for which you have * previously called #gdk_window_set_transient_for() **/voidgdk_window_set_modal_hint (GdkWindow *window,			   gboolean   modal){  GdkWindowObject *private;  g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));    if (GDK_WINDOW_DESTROYED (window))    return;  private = (GdkWindowObject*) window;  private->modal_hint = modal;  if (GDK_WINDOW_IS_MAPPED (window))    gdk_wmspec_change_state (modal, window,			     gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE), 			     NULL);}/** * gdk_window_set_skip_taskbar_hint: * @window: a toplevel #GdkWindow * @skips_taskbar: %TRUE to skip the taskbar *  * Toggles whether a window should appear in a task list or window * list. If a window's semantic type as specified with * gdk_window_set_type_hint() already fully describes the window, this * function should NOT be called in addition, instead you should allow * the window to be treated according to standard policy for its * semantic type. * * Since: 2.2 **/voidgdk_window_set_skip_taskbar_hint (GdkWindow *window,                                  gboolean   skips_taskbar){  GdkToplevelX11 *toplevel;    g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));  g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD);    if (GDK_WINDOW_DESTROYED (window))    return;  toplevel = _gdk_x11_window_get_toplevel (window);  toplevel->skip_taskbar_hint = skips_taskbar;  if (GDK_WINDOW_IS_MAPPED (window))    gdk_wmspec_change_state (skips_taskbar, window,			     gdk_atom_intern ("_NET_WM_STATE_SKIP_TASKBAR", FALSE), 			     NULL);}/** * gdk_window_set_skip_pager_hint: * @window: a toplevel #GdkWindow * @skips_pager: %TRUE to skip the pager *  * Toggles whether a window should appear in a pager (workspace * switcher, or other desktop utility program that displays a small * thumbnail representation of the windows on the desktop). If a * window's semantic type as specified with gdk_window_set_type_hint() * already fully describes the window, this function should NOT be * called in addition, instead you should allow the window to be * treated according to standard policy for its semantic type. * * Since: 2.2 **/voidgdk_window_set_skip_pager_hint (GdkWindow *window,                                gboolean   skips_pager){  GdkToplevelX11 *toplevel;      g_return_if_fail (window != NULL);  g_return_if_fail (GDK_IS_WINDOW (window));  g_return_if_f

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?