- private->dnd_drag_data_type = None;
- private->dnd_drag_data_typesavail =
- private->dnd_drop_data_typesavail = NULL;
- private->dnd_drop_enabled = private->dnd_drag_enabled =
- private->dnd_drag_accepted = private->dnd_drag_datashow =
- private->dnd_drop_data_numtypesavail =
- private->dnd_drag_data_numtypesavail = 0;
- private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0;
-
- private->filters = NULL;
- private->children = NULL;
-
- window->user_data = NULL;
-
- if (attributes_mask & GDK_WA_VISUAL)
- visual = attributes->visual;
- else
- visual = gdk_visual_get_system ();
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
- xattributes.event_mask = StructureNotifyMask;
- for (i = 0; i < nevent_masks; i++)
- {
- if (attributes->event_mask & (1 << (i + 1)))
- xattributes.event_mask |= event_mask_table[i];
- }
-
- 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;
-
- if (attributes->wclass == GDK_INPUT_OUTPUT)
- {
- class = InputOutput;
- depth = visual->depth;
-
- if (attributes_mask & GDK_WA_COLORMAP)
- private->colormap = attributes->colormap;
- else
- private->colormap = gdk_colormap_get_system ();
-
- xattributes.background_pixel = BlackPixel (gdk_display, gdk_screen);
- xattributes.border_pixel = BlackPixel (gdk_display, gdk_screen);
- xattributes_mask |= CWBorderPixel | CWBackPixel;
-
- switch (private->window_type)
- {
- case GDK_WINDOW_TOPLEVEL:
- xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_CHILD:
- xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
- xattributes_mask |= CWColormap;
- break;
-
- case GDK_WINDOW_DIALOG:
- xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_TEMP:
- xattributes.colormap = ((GdkColormapPrivate*) private->colormap)->xcolormap;
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
-
- xattributes.save_under = True;
- xattributes.override_redirect = True;
- xattributes.cursor = None;
- xattributes_mask |= CWSaveUnder | CWOverrideRedirect;
- break;
- case GDK_WINDOW_ROOT:
- g_error ("cannot make windows of type GDK_WINDOW_ROOT");
- break;
- case GDK_WINDOW_PIXMAP:
- g_error ("cannot make windows of type GDK_WINDOW_PIXMAP (use gdk_pixmap_new)");
- break;
- }
- }
- else
- {
- depth = 0;
- class = InputOnly;
- private->colormap = NULL;
- }
-
- private->xwindow = XCreateWindow (private->xdisplay, xparent,
- x, y, private->width, private->height,
- 0, depth, class, xvisual,
- xattributes_mask, &xattributes);
- gdk_window_ref (window);
- gdk_xid_table_insert (&private->xwindow, window);
-
- if (private->colormap)
- gdk_colormap_ref (private->colormap);
-
- gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
- (attributes->cursor) :
- NULL));
-
- switch (private->window_type)
- {
- case GDK_WINDOW_DIALOG:
- XSetTransientForHint (private->xdisplay, private->xwindow, xparent);
- case GDK_WINDOW_TOPLEVEL:
- case GDK_WINDOW_TEMP:
- XSetWMProtocols (private->xdisplay, private->xwindow, gdk_wm_window_protocols, 2);
- break;
- case GDK_WINDOW_CHILD:
- if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
- (private->colormap != gdk_colormap_get_system ()) &&
- (private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
- {
- GDK_NOTE (MISC, g_message ("adding colormap window\n"));
- gdk_window_add_colormap_windows (window);
- }
-
- return window;
- default:
-
- return window;
- }
-
- size_hints.flags = PSize;
- size_hints.width = private->width;
- size_hints.height = private->height;
-
- wm_hints.flags = InputHint | StateHint | WindowGroupHint;
- wm_hints.window_group = gdk_leader_window;
- wm_hints.input = True;
- wm_hints.initial_state = NormalState;
-
- /* 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???
- */
- XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints);
-
- XSetWMHints (private->xdisplay, private->xwindow, &wm_hints);
-
- if (attributes_mask & GDK_WA_TITLE)
- title = attributes->title;
- else
- title = g_get_prgname ();
-
- XmbSetWMProperties (private->xdisplay, private->xwindow,
- title, title,
- NULL, 0,
- NULL, NULL, NULL);
-
- if (attributes_mask & GDK_WA_WMCLASS)
- {
- class_hint = XAllocClassHint ();
- class_hint->res_name = attributes->wmclass_name;
- class_hint->res_class = attributes->wmclass_class;
- XSetClassHint (private->xdisplay, private->xwindow, class_hint);
- XFree (class_hint);
- }
-
-
- return window;
-}
-
-GdkWindow *
-gdk_window_foreign_new (guint32 anid)
-{
- GdkWindow *window;
- GdkWindowPrivate *private;
- GdkWindowPrivate *parent_private;
- XWindowAttributes attrs;
- Window root, parent;
- Window *children = NULL;
- guint nchildren;
-
- if(!XGetWindowAttributes (gdk_display, anid, &attrs)) {
- g_warning("XGetWindowAttributes failed on window ID %d\n", anid);
- return NULL;
- }
-
- private = g_new (GdkWindowPrivate, 1);
- window = (GdkWindow*) private;
-
- /* FIXME: This is pretty expensive. Maybe the caller should supply
- * the parent */
- XQueryTree (gdk_display, anid, &root, &parent, &children, &nchildren);
-
- if (children)
- XFree (children);
- private->parent = gdk_xid_table_lookup (parent);
-
- parent_private = (GdkWindowPrivate *)private->parent;