-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-#include <X11/extensions/shape.h>
-#include <netinet/in.h>
-#include "gdk.h"
-#include "../config.h"
-#include "gdkinput.h"
-#include "gdkprivate.h"
-#include <stdlib.h>
-
-int nevent_masks = 16;
-int event_mask_table[18] =
-{
- ExposureMask,
- PointerMotionMask,
- PointerMotionHintMask,
- ButtonMotionMask,
- Button1MotionMask,
- Button2MotionMask,
- Button3MotionMask,
- ButtonPressMask | OwnerGrabButtonMask,
- ButtonReleaseMask | OwnerGrabButtonMask,
- KeyPressMask,
- KeyReleaseMask,
- EnterWindowMask,
- LeaveWindowMask,
- FocusChangeMask,
- StructureNotifyMask,
- PropertyChangeMask,
- 0, /* PROXIMITY_IN */
- 0 /* PROXIMTY_OUT */
-};
-
-
-void
-gdk_window_init ()
-{
- XWindowAttributes xattributes;
- unsigned int width;
- unsigned int height;
- unsigned int border_width;
- unsigned int depth;
- int x, y;
-
- XGetGeometry (gdk_display, gdk_root_window, &gdk_root_window,
- &x, &y, &width, &height, &border_width, &depth);
- XGetWindowAttributes (gdk_display, gdk_root_window, &xattributes);
-
- gdk_root_parent.xdisplay = gdk_display;
- gdk_root_parent.xwindow = gdk_root_window;
- gdk_root_parent.window_type = GDK_WINDOW_ROOT;
- gdk_root_parent.window.user_data = NULL;
-}
-
-GdkWindow*
-gdk_window_new (GdkWindow *parent,
- GdkWindowAttr *attributes,
- gint attributes_mask)
-{
- GdkWindow *window;
- GdkWindowPrivate *private;
- GdkWindowPrivate *parent_private;
- GdkVisual *visual;
- GdkColormap *colormap;
- Display *parent_display;
- Window xparent;
- Visual *xvisual;
- XSetWindowAttributes xattributes;
- long xattributes_mask;
- XSizeHints size_hints;
- XWMHints wm_hints;
- XClassHint *class_hint;
- int x, y, depth;
- unsigned int class;
- char *title;
- int i;
-
- g_return_val_if_fail (attributes != NULL, NULL);
-
- if (!parent)
- parent = (GdkWindow*) &gdk_root_parent;
-
- parent_private = (GdkWindowPrivate*) parent;
- xparent = parent_private->xwindow;
- parent_display = parent_private->xdisplay;
-
- private = g_new (GdkWindowPrivate, 1);
- window = (GdkWindow*) private;
-
- private->parent = parent;
- private->xdisplay = parent_display;
- private->destroyed = FALSE;
- private->resize_count = 0;
- private->ref_count = 1;
- 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;
- private->width = (attributes->width > 1) ? (attributes->width) : (1);
- private->height = (attributes->height > 1) ? (attributes->height) : (1);
- private->window_type = attributes->window_type;
- private->extension_events = FALSE;
- 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;
-
- 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->wclass == GDK_INPUT_OUTPUT)
- {
- class = InputOutput;
- depth = visual->depth;
-
- if (attributes_mask & GDK_WA_COLORMAP)
- colormap = attributes->colormap;
- else
- 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*) colormap)->xcolormap;
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_CHILD:
- xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
- xattributes_mask |= CWColormap;
- break;
-
- case GDK_WINDOW_DIALOG:
- xattributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
- xattributes_mask |= CWColormap;
-
- xparent = gdk_root_window;
- break;
-
- case GDK_WINDOW_TEMP:
- xattributes.colormap = ((GdkColormapPrivate*) 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 = 1;
- class = InputOnly;
- colormap = NULL;
- }
-
- private->xwindow = XCreateWindow (private->xdisplay, xparent,
- x, y, private->width, private->height,
- 0, depth, class, xvisual,
- xattributes_mask, &xattributes);
- gdk_xid_table_insert (&private->xwindow, window);
-
- 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) &&
- (colormap != gdk_colormap_get_system ()) &&
- (colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window))))
- {
- g_print ("adding colormap window\n");
- gdk_window_add_colormap_windows (window);
- }
- break;
- default:
- break;
- }
-
- size_hints.flags = PSize | PBaseSize;
- size_hints.width = private->width;
- size_hints.height = private->height;
- size_hints.base_width = private->width;
- size_hints.base_height = private->height;