⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkwindow-x11.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 5 页
字号:
    private->window_type = GDK_WINDOW_ROOT;  private->depth = DefaultDepthOfScreen (screen_x11->xscreen);    impl->width = WidthOfScreen (screen_x11->xscreen);  impl->height = HeightOfScreen (screen_x11->xscreen);    _gdk_window_init_position (GDK_WINDOW (private));  _gdk_xid_table_insert (screen_x11->display,			 &screen_x11->xroot_window,			 screen_x11->root_window);}static voidset_wm_protocols (GdkWindow *window){  GdkDisplay *display = gdk_drawable_get_display (window);  Atom protocols[4];  int n = 0;    protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW");  protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");  protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING");#ifdef HAVE_XSYNC  if (GDK_DISPLAY_X11 (display)->use_sync)    protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST");#endif    XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);}static const gchar *get_default_title (void){  const char *title;  title = g_get_application_name ();  if (!title)    title = g_get_prgname ();  return title;}static voidcheck_leader_window_title (GdkDisplay *display){  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);  if (display_x11->leader_window && !display_x11->leader_window_title_set)    {      set_wm_name (display,		   display_x11->leader_window,		   get_default_title ());            display_x11->leader_window_title_set = TRUE;    }}static Windowcreate_focus_window (Display *xdisplay,		     XID      parent){  Window focus_window = XCreateSimpleWindow (xdisplay, parent,					     -1, -1, 1, 1, 0,					     0, 0);    /* FIXME: probably better to actually track the requested event mask for the toplevel   */  XSelectInput (xdisplay, focus_window,		KeyPressMask | KeyReleaseMask | FocusChangeMask);    XMapWindow (xdisplay, focus_window);  return focus_window;}static voidensure_sync_counter (GdkWindow *window){#ifdef HAVE_XSYNC  if (!GDK_WINDOW_DESTROYED (window))    {      GdkDisplay *display = GDK_WINDOW_DISPLAY (window);      GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);      GdkWindowObject *private = (GdkWindowObject *)window;      GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (private->impl);      if (toplevel && impl->use_synchronized_configure &&	  toplevel->update_counter == None &&	  GDK_DISPLAY_X11 (display)->use_sync)	{	  Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);	  XSyncValue value;	  Atom atom;	  XSyncIntToValue (&value, 0);	  	  toplevel->update_counter = XSyncCreateCounter (xdisplay, value);	  	  atom = gdk_x11_get_xatom_by_name_for_display (display,							"_NET_WM_SYNC_REQUEST_COUNTER");	  	  XChangeProperty (xdisplay, GDK_WINDOW_XID (window),			   atom, XA_CARDINAL,			   32, PropModeReplace,			   (guchar *)&toplevel->update_counter, 1);	  	  XSyncIntToValue (&toplevel->current_counter_value, 0);	}    }#endif}static voidsetup_toplevel_window (GdkWindow *window, 		       GdkWindow *parent){  GdkWindowObject *obj = (GdkWindowObject *)window;  GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);  GdkWindowImplX11 *impl = (GdkWindowImplX11 *)obj->impl;  Display *xdisplay = GDK_WINDOW_XDISPLAY (window);  XID xid = GDK_WINDOW_XID (window);  XID xparent = GDK_WINDOW_XID (parent);  GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (GDK_WINDOW_SCREEN (parent));  XSizeHints size_hints;  long pid;      if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_DIALOG)    XSetTransientForHint (xdisplay, xid, xparent);    set_wm_protocols (window);    if (!obj->input_only)    {      /* The focus window is off the visible area, and serves to receive key       * press events so they don't get sent to child windows.       */      toplevel->focus_window = create_focus_window (xdisplay, xid);      _gdk_xid_table_insert (screen_x11->display, &toplevel->focus_window, window);    }    check_leader_window_title (screen_x11->display);    /* FIXME: Is there any point in doing this? Do any WM's pay   * attention to PSize, and even if they do, is this the   * correct value???   */  size_hints.flags = PSize;  size_hints.width = impl->width;  size_hints.height = impl->height;    XSetWMNormalHints (xdisplay, xid, &size_hints);    /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */  XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);    pid = getpid ();  XChangeProperty (xdisplay, xid,		   gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "_NET_WM_PID"),		   XA_CARDINAL, 32,		   PropModeReplace,		   (guchar *)&pid, 1);    XChangeProperty (xdisplay, xid, 		   gdk_x11_get_xatom_by_name_for_display (screen_x11->display, "WM_CLIENT_LEADER"),		   XA_WINDOW, 32, PropModeReplace,		   (guchar *) &GDK_DISPLAY_X11 (screen_x11->display)->leader_window, 1);  if (!obj->focus_on_map)    gdk_x11_window_set_user_time (window, 0);  else if (GDK_DISPLAY_X11 (screen_x11->display)->user_time != 0)    gdk_x11_window_set_user_time (window, GDK_DISPLAY_X11 (screen_x11->display)->user_time);  ensure_sync_counter (window);}/** * gdk_window_new: * @parent: a #GdkWindow, or %NULL to create the window as a child of *   the default root window for the default display. * @attributes: attributes of the new window * @attributes_mask: mask indicating which fields in @attributes are valid *  * Creates a new #GdkWindow using the attributes from * @attributes. See #GdkWindowAttr and #GdkWindowAttributesType for * more details.  Note: to use this on displays other than the default * display, @parent must be specified. *  * Return value: the new #GdkWindow **/GdkWindow*gdk_window_new (GdkWindow     *parent,		GdkWindowAttr *attributes,		gint           attributes_mask){  GdkWindow *window;  GdkWindowObject *private;  GdkWindowImplX11 *impl;  GdkDrawableImplX11 *draw_impl;  GdkScreenX11 *screen_x11;  GdkScreen *screen;    GdkVisual *visual;  Window xparent;  Visual *xvisual;  Display *xdisplay;  Window xid;  XSetWindowAttributes xattributes;  long xattributes_mask;  XClassHint *class_hint;  int x, y, depth;    unsigned int class;  const char *title;  int i;    g_return_val_if_fail (attributes != NULL, NULL);    if (!parent)    {      GDK_NOTE (MULTIHEAD,		g_warning ("gdk_window_new(): no parent specified reverting to parent = default root window"));            screen = gdk_screen_get_default ();      parent = gdk_screen_get_root_window (screen);    }  else    screen = gdk_drawable_get_screen (parent);  screen_x11 = GDK_SCREEN_X11 (screen);  g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);    if (GDK_WINDOW_DESTROYED (parent))    return NULL;    xparent = GDK_WINDOW_XID (parent);    window = g_object_new (GDK_TYPE_WINDOW, NULL);  private = (GdkWindowObject *)window;  impl = GDK_WINDOW_IMPL_X11 (private->impl);  draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);  draw_impl->wrapper = GDK_DRAWABLE (window);    draw_impl->screen = screen;  xdisplay = screen_x11->xdisplay;  /* Windows with a foreign parent are treated as if they are children   * of the root window, except for actual creation.   */  if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_FOREIGN)    parent = gdk_screen_get_root_window (screen);    private->parent = (GdkWindowObject *)parent;  private->accept_focus = TRUE;  private->focus_on_map = TRUE;  xattributes_mask = 0;    if (attributes_mask & GDK_WA_X)    x = attributes->x;  else    x = 0;    if (attributes_mask & GDK_WA_Y)    y = attributes->y;  else    y = 0;    private->x = x;  private->y = y;  impl->width = (attributes->width > 1) ? (attributes->width) : (1);  impl->height = (attributes->height > 1) ? (attributes->height) : (1);  if (attributes->wclass == GDK_INPUT_ONLY)    {      /* Backwards compatiblity - we've always ignored       * attributes->window_type for input-only windows       * before       */      if (GDK_WINDOW_TYPE (parent) == GDK_WINDOW_ROOT)	private->window_type = GDK_WINDOW_TEMP;      else	private->window_type = GDK_WINDOW_CHILD;    }  else    private->window_type = attributes->window_type;  _gdk_window_init_position (GDK_WINDOW (private));  if (impl->position_info.big)    private->guffaw_gravity = TRUE;    if (attributes_mask & GDK_WA_VISUAL)    visual = attributes->visual;  else    visual = gdk_screen_get_system_visual (screen);  xvisual = ((GdkVisualPrivate*) visual)->xvisual;    xattributes.event_mask = StructureNotifyMask | PropertyChangeMask;  for (i = 0; i < _gdk_nenvent_masks; i++)    {      if (attributes->event_mask & (1 << (i + 1)))	xattributes.event_mask |= _gdk_event_mask_table[i];    }  private->event_mask = attributes->event_mask;    if (xattributes.event_mask)    xattributes_mask |= CWEventMask;    if (attributes_mask & GDK_WA_NOREDIR)    {      xattributes.override_redirect =	(attributes->override_redirect == FALSE)?False:True;      xattributes_mask |= CWOverrideRedirect;    }   else    xattributes.override_redirect = False;  impl->override_redirect = xattributes.override_redirect;    if (private->parent && private->parent->guffaw_gravity)    {      xattributes.win_gravity = StaticGravity;      xattributes_mask |= CWWinGravity;    }    /* Sanity checks */  switch (private->window_type)    {    case GDK_WINDOW_TOPLEVEL:    case GDK_WINDOW_DIALOG:    case GDK_WINDOW_TEMP:      if (GDK_WINDOW_TYPE (parent) != GDK_WINDOW_ROOT)	{	  g_warning (G_STRLOC "Toplevel windows must be created as children of\n"		     "of a window of type GDK_WINDOW_ROOT or GDK_WINDOW_FOREIGN");	  xparent = GDK_SCREEN_XROOTWIN (screen);	}    case GDK_WINDOW_CHILD:      break;    default:      g_warning (G_STRLOC "cannot make windows of type %d", private->window_type);      return NULL;    }	    if (attributes->wclass == GDK_INPUT_OUTPUT)    {      class = InputOutput;      depth = visual->depth;      private->input_only = FALSE;      private->depth = depth;            if (attributes_mask & GDK_WA_COLORMAP)        {          draw_impl->colormap = attributes->colormap;          g_object_ref (attributes->colormap);        }      else	{	  if ((((GdkVisualPrivate *)gdk_screen_get_system_visual (screen))->xvisual) ==  xvisual)            {	      draw_impl->colormap = gdk_screen_get_system_colormap (screen);              g_object_ref (draw_impl->colormap);            }	  else            {              draw_impl->colormap = gdk_colormap_new (visual, FALSE);            }	}            private->bg_color.pixel = BlackPixel (xdisplay, screen_x11->screen_num);      xattributes.background_pixel = private->bg_color.pixel;      private->bg_pixmap = NULL;            xattributes.border_pixel = BlackPixel (xdisplay, screen_x11->screen_num);      xattributes_mask |= CWBorderPixel | CWBackPixel;      if (private->guffaw_gravity)	xattributes.bit_gravity = StaticGravity;      else	xattributes.bit_gravity = NorthWestGravity;            xattributes_mask |= CWBitGravity;      xattributes.colormap = GDK_COLORMAP_XCOLORMAP (draw_impl->colormap);      xattributes_mask |= CWColormap;      if (private->window_type == GDK_WINDOW_TEMP)	{	  xattributes.save_under = True;	  xattributes.override_redirect = True;	  xattributes.cursor = None;	  xattributes_mask |= CWSaveUnder | CWOverrideRedirect;	  impl->override_redirect = TRUE;	}    }  else    {      depth = 0;      private->depth = 0;      class = InputOnly;      private->input_only = TRUE;      draw_impl->colormap = gdk_screen_get_system_colormap (screen);      g_object_ref (draw_impl->colormap);    }  xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,					impl->position_info.x, impl->position_info.y,					impl->position_info.width, impl->position_info.height,					0, depth, class, xvisual,					xattributes_mask, &xattributes);  g_object_ref (window);  _gdk_xid_table_insert (screen_x11->display, &draw_impl->xid, window);    gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?				  (attributes->cursor) :				  NULL));    if (private->parent)    private->parent->children = g_list_prepend (private->parent->children, window);    switch (GDK_WINDOW_TYPE (private))    {    case GDK_WINDOW_DIALOG:    case GDK_WINDOW_TOPLEVEL:    case GDK_WINDOW_TEMP:      if (attributes_mask & GDK_WA_TITLE)	title = attributes->title;      else	title = get_default_title ();            gdk_window_set_title (window, title);            if (attributes_mask & GDK_WA_WMCLASS)	{	  class_hint = XAllocClassHint ();	  class_hint->res_name = attributes->wmclass_name;	  class_hint->res_class = attributes->wmclass_class;	  XSetClassHint (xdisplay, xid, class_hint);	  XFree (class_hint);	}        setup_toplevel_window (window, parent);      break;    case GDK_WINDOW_CHILD:      if ((attributes->wclass == GDK_INPUT_OUTPUT) &&	  (draw_impl->colormap != gdk_screen_get_system_colormap (screen)) &&	  (draw_impl->colormap != gdk_drawable_get_colormap (gdk_window_get_toplevel (window))))	{	  GDK_NOTE (MISC, g_message ("adding colormap window\n"));	  gdk_window_add_colormap_windows (window);	}      break;          default:      break;    }  return window;

⌨️ 快捷键说明

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