Add gdk_window_iconify.

Mon Sep 25 15:05:17 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
	Add gdk_window_iconify.

	* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
	(gdk_window_set_geometry_hints): Add win_gravity
	to geometry structure.

	* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
	Implement _NET_WM_PING.

	* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
	Set _NET_WM_PID on the client leader.

	* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
	Handle UTF-8 better.

	* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
	UTF-8 better, set _NET_WM_NAME as well. Only set
	icon name if it hasn't previously been explicitely
	set.
This commit is contained in:
Owen Taylor 2000-10-04 16:51:42 +00:00 committed by Owen Taylor
parent 502e5a8859
commit 0d15886459
12 changed files with 319 additions and 44 deletions

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -1,3 +1,26 @@
Mon Sep 25 15:05:17 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c (gdk_window_iconify):
Add gdk_window_iconify.
* gdk/gdkwindow.h gdk/x11/gdkwindow-x11.c
(gdk_window_set_geometry_hints): Add win_gravity
to geometry structure.
* gdk/x11/gdkevents-x11.c (gdk_wm_protocols_filter):
Implement _NET_WM_PING.
* gdk/x11/gdkmain-x11.c (_gdk_windowing_init_check):
Set _NET_WM_PID on the client leader.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_name):
Handle UTF-8 better.
* gdk/x11/gdkwindow-x11.c (gdk_window_set_title): Handle
UTF-8 better, set _NET_WM_NAME as well. Only set
icon name if it hasn't previously been explicitely
set.
2000-10-03 Havoc Pennington <hp@redhat.com>
* gtk/testtextbuffer.c: clean up trailing whitespace,

View File

@ -75,12 +75,13 @@ typedef enum
*/
typedef enum
{
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5
GDK_HINT_POS = 1 << 0,
GDK_HINT_MIN_SIZE = 1 << 1,
GDK_HINT_MAX_SIZE = 1 << 2,
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6
} GdkWindowHints;
/* The next two enumeration values current match the
@ -109,6 +110,24 @@ typedef enum
GDK_FUNC_CLOSE = 1 << 5
} GdkWMFunction;
/* Currently, these are the same values numerically as in the
* X protocol. If you change that, gdkwindow-x11.c/gdk_window_set_geometry_hints()
* will need fixing.
*/
typedef enum
{
GDK_GRAVITY_NORTH_WEST = 1,
GDK_GRAVITY_NORTH,
GDK_GRAVITY_NORTH_EAST,
GDK_GRAVITY_WEST,
GDK_GRAVITY_CENTER,
GDK_GRAVITY_EAST,
GDK_GRAVITY_SOUTH_WEST,
GDK_GRAVITY_SOUTH,
GDK_GRAVITY_SOUTH_EAST,
GDK_GRAVITY_STATIC,
} GdkGravity;
struct _GdkWindowAttr
{
gchar *title;
@ -137,7 +156,7 @@ struct _GdkGeometry {
gint height_inc;
gdouble min_aspect;
gdouble max_aspect;
/* GdkGravity gravity; */
GdkGravity win_gravity;
};
typedef struct _GdkWindowObject GdkWindowObject;
@ -372,6 +391,7 @@ void gdk_window_set_decorations (GdkWindow *window,
void gdk_window_set_functions (GdkWindow *window,
GdkWMFunction functions);
GList * gdk_window_get_toplevels (void);
void gdk_window_iconify (GdkWindow *window);
void gdk_window_register_dnd (GdkWindow *window);

View File

@ -1228,6 +1228,13 @@ gdk_wm_protocols_filter (GdkXEvent *xev,
else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus)
{
}
else if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("_NET_WM_PING", FALSE))
{
XEvent xev = *xevent;
xev.xclient.window = gdk_root_window;
XSendEvent (gdk_display, gdk_root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
return GDK_FILTER_REMOVE;
}

View File

@ -39,7 +39,7 @@ Window gdk_leader_window;
Atom gdk_wm_delete_window;
Atom gdk_wm_take_focus;
Atom gdk_wm_protocols;
Atom gdk_wm_window_protocols[2];
Atom gdk_wm_window_protocols[3];
Atom gdk_selection_property;
gchar *gdk_progclass = NULL;
gboolean gdk_null_window_warnings = TRUE;

View File

@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
@ -148,6 +149,7 @@ _gdk_windowing_init_check (int argc, char **argv)
{
XKeyboardState keyboard_state;
XClassHint *class_hint;
guint pid;
XSetErrorHandler (gdk_x_error);
XSetIOErrorHandler (gdk_x_io_error);
@ -176,13 +178,21 @@ _gdk_windowing_init_check (int argc, char **argv)
NULL, NULL, argv, argc,
NULL, NULL, class_hint);
XFree (class_hint);
pid = getpid();
XChangeProperty (gdk_display, gdk_leader_window,
gdk_atom_intern ("_NET_WM_PID", FALSE),
XA_CARDINAL, 32,
PropModeReplace,
(guchar *)&pid, 1);
gdk_wm_delete_window = XInternAtom (gdk_display, "WM_DELETE_WINDOW", False);
gdk_wm_take_focus = XInternAtom (gdk_display, "WM_TAKE_FOCUS", False);
gdk_wm_protocols = XInternAtom (gdk_display, "WM_PROTOCOLS", False);
gdk_wm_delete_window = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE);
gdk_wm_take_focus = gdk_atom_intern ("WM_TAKE_FOCUS", FALSE);
gdk_wm_protocols = gdk_atom_intern ("WM_PROTOCOLS", FALSE);
gdk_wm_window_protocols[0] = gdk_wm_delete_window;
gdk_wm_window_protocols[1] = gdk_wm_take_focus;
gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False);
gdk_wm_window_protocols[2] = gdk_atom_intern ("_NET_WM_PING", FALSE);
gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
XGetKeyboardControl (gdk_display, &keyboard_state);
autorepeat = keyboard_state.global_auto_repeat;

View File

@ -75,10 +75,11 @@ const int gdk_event_mask_table[21] =
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,
@ -490,7 +491,7 @@ gdk_window_new (GdkWindow *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) &&
@ -541,12 +542,8 @@ gdk_window_new (GdkWindow *parent,
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)
{
@ -1050,6 +1047,12 @@ gdk_window_set_geometry_hints (GdkWindow *window,
}
}
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
*/
@ -1058,17 +1061,83 @@ gdk_window_set_geometry_hints (GdkWindow *window,
&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
@ -1692,34 +1761,42 @@ gdk_window_set_icon (GdkWindow *window,
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;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
if (GDK_WINDOW_DESTROYED (window))
return;
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);
display = GDK_WINDOW_XDISPLAY (window);
XIconifyWindow (display, GDK_WINDOW_XWINDOW (window), DefaultScreen (display));
}
void