const int gdk_nevent_masks = sizeof (gdk_event_mask_table) / sizeof (int);
/* Forward declarations */
-static gboolean gdk_window_gravity_works (void);
-static void gdk_window_set_static_win_gravity (GdkWindow *window,
+static gboolean gdk_window_gravity_works (void);
+static void gdk_window_set_static_win_gravity (GdkWindow *window,
gboolean on);
-static gboolean gdk_window_have_shape_ext (void);
+static gboolean gdk_window_have_shape_ext (void);
+static gboolean gdk_window_icon_name_set (GdkWindow *window);
static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
static void gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
- GdkColormap *cmap);
-static void gdk_window_impl_x11_get_size (GdkDrawable *drawable,
- gint *width,
- gint *height);
+ GdkColormap *cmap);
+static void gdk_window_impl_x11_get_size (GdkDrawable *drawable,
+ gint *width,
+ gint *height);
+static GdkRegion* gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable);
static void gdk_window_impl_x11_init (GdkWindowImplX11 *window);
static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass);
static void gdk_window_impl_x11_finalize (GObject *object);
object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_X11,
"GdkWindowImplX11",
- &object_info);
+ &object_info, 0);
}
return object_type;
drawable_class->set_colormap = gdk_window_impl_x11_set_colormap;
drawable_class->get_colormap = gdk_window_impl_x11_get_colormap;
drawable_class->get_size = gdk_window_impl_x11_get_size;
+
+ /* Visible and clip regions are the same */
+ drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region;
+ drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region;
}
static void
GdkDrawableImplX11 *draw_impl;
g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (drawable));
- g_return_if_fail (gdk_colormap_get_visual (cmap) != gdk_drawable_get_visual (drawable));
impl = GDK_WINDOW_IMPL_X11 (drawable);
draw_impl = GDK_DRAWABLE_IMPL_X11 (drawable);
- GDK_DRAWABLE_GET_CLASS (draw_impl)->set_colormap (drawable, cmap);
-
- XSetWindowColormap (draw_impl->xdisplay,
- draw_impl->xid,
- GDK_COLORMAP_XCOLORMAP (cmap));
+ /* chain up */
+ GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);
- if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
- GDK_WINDOW_TOPLEVEL)
- gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
+ if (cmap)
+ {
+ XSetWindowColormap (draw_impl->xdisplay,
+ draw_impl->xid,
+ GDK_COLORMAP_XCOLORMAP (cmap));
+
+ if (((GdkWindowObject*)draw_impl->wrapper)->window_type !=
+ GDK_WINDOW_TOPLEVEL)
+ gdk_window_add_colormap_windows (GDK_WINDOW (draw_impl->wrapper));
+ }
}
*height = GDK_WINDOW_IMPL_X11 (drawable)->height;
}
+static GdkRegion*
+gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable)
+{
+ GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable);
+ GdkRectangle result_rect;
+
+ result_rect.x = 0;
+ result_rect.y = 0;
+ result_rect.width = impl->width;
+ result_rect.height = impl->height;
+
+ gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
+
+ return gdk_region_rectangle (&result_rect);
+}
+
void
_gdk_windowing_window_init (void)
{
private->depth = 0;
class = InputOnly;
private->input_only = TRUE;
- draw_impl->colormap = NULL;
+ draw_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (draw_impl->colormap);
}
draw_impl->xid = XCreateWindow (GDK_WINDOW_XDISPLAY (parent),
case GDK_WINDOW_TEMP:
XSetWMProtocols (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
- gdk_wm_window_protocols, 2);
+ gdk_wm_window_protocols, 3);
break;
case GDK_WINDOW_CHILD:
if ((attributes->wclass == GDK_INPUT_OUTPUT) &&
title = attributes->title;
else
title = g_get_prgname ();
-
- XmbSetWMProperties (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- title, title,
- NULL, 0,
- NULL, NULL, NULL);
+
+ gdk_window_set_title (window, title);
if (attributes_mask & GDK_WA_WMCLASS)
{
}
}
+ if (geom_mask & GDK_HINT_WIN_GRAVITY)
+ {
+ size_hints.flags |= PWinGravity;
+ size_hints.width_inc = geometry->win_gravity;
+ }
+
/* FIXME: Would it be better to delete this property of
* geom_mask == 0? It would save space on the server
*/
&size_hints);
}
+static gboolean
+utf8_is_latin1 (const gchar *str)
+{
+ const char *p = str;
+
+ while (*p)
+ {
+ gunichar ch = g_utf8_get_char (p);
+
+ if (ch >= 0xff)
+ return FALSE;
+
+ p = g_utf8_next_char (p);
+ }
+
+ return TRUE;
+}
+
+/* Set the property to @utf8_str as STRING if the @utf8_str is fully
+ * convertable to STRING, otherwise, set it as compound text
+ */
+static void
+set_text_property (GdkWindow *window,
+ GdkAtom property,
+ const gchar *utf8_str)
+{
+ guchar *prop_text = NULL;
+ GdkAtom prop_type;
+ gint prop_length;
+ gint prop_format;
+
+ if (utf8_is_latin1 (utf8_str))
+ {
+ prop_type = GDK_TARGET_STRING;
+ prop_text = gdk_utf8_to_string_target (utf8_str);
+ prop_length = strlen (prop_text);
+ prop_format = 8;
+ }
+ else
+ {
+ gdk_utf8_to_compound_text (utf8_str, &prop_type, &prop_format,
+ &prop_text, &prop_length);
+ }
+
+ if (prop_text)
+ {
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
+ property,
+ prop_type, prop_format,
+ PropModeReplace, prop_text,
+ prop_length);
+
+ g_free (prop_text);
+ }
+}
+
void
gdk_window_set_title (GdkWindow *window,
const gchar *title)
{
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
- if (!GDK_WINDOW_DESTROYED (window))
- XmbSetWMProperties (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- title, title, NULL, 0, NULL, NULL, NULL);
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
+ gdk_atom_intern ("_NET_WM_NAME", FALSE),
+ gdk_atom_intern ("UTF8_STRING", FALSE), 8,
+ PropModeReplace, title,
+ strlen (title));
+
+ set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title);
+ if (!gdk_window_icon_name_set (window))
+ set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
}
void
XFree (wm_hints);
}
+static gboolean
+gdk_window_icon_name_set (GdkWindow *window)
+{
+ return GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (window),
+ g_quark_from_static_string ("gdk-icon-name-set")));
+}
+
void
gdk_window_set_icon_name (GdkWindow *window,
const gchar *name)
{
- XTextProperty property;
- gint res;
-
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
return;
+
+ g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
+ GUINT_TO_POINTER (TRUE));
+
+ set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name);
+}
+
+void
+gdk_window_iconify (GdkWindow *window)
+{
+ Display *display;
- res = XmbTextListToTextProperty (GDK_WINDOW_XDISPLAY (window),
- &name, 1, XStdICCTextStyle,
- &property);
- if (res < 0)
- {
- g_warning ("Error converting icon name to text property: %d\n", res);
- return;
- }
-
- XSetWMIconName (GDK_WINDOW_XDISPLAY (window),
- GDK_WINDOW_XID (window),
- &property);
-
- if (property.value)
- XFree (property.value);
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GDK_IS_WINDOW (window));
+
+ if (GDK_WINDOW_DESTROYED (window))
+ return;
+
+ display = GDK_WINDOW_XDISPLAY (window);
+ XIconifyWindow (display, GDK_WINDOW_XWINDOW (window), DefaultScreen (display));
}
void