Commit 5e1439f8 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

lengthen to 15 seconds

2002-11-30  Havoc Pennington  <hp@pobox.com>

	* src/screen.c (STARTUP_TIMEOUT): lengthen to 15 seconds

	* src/util.c (utf8_fputs): hmm, return a value

	* src/screen.c (meta_screen_apply_startup_properties): new
	function to apply initial workspace based on startup sequence.

	* src/window.c (meta_window_new): load _NET_STARTUP_ID
	(meta_window_get_startup_id): new function

	* src/window-props.c (meta_display_init_window_prop_hooks): add
	hooks for _NET_STARTUP_ID

	* src/display.c (event_callback): send property events to
	groups.

	* src/xprops.c (meta_prop_get_values): make a type of INVALID
	mean to ignore that property (don't fetch its value).

	* src/group.c (meta_group_property_notify): new function

	* src/screen.c (set_supported_hint): support _NET_STARTUP_ID

	* src/display.c (meta_display_open): add _NET_STARTUP_ID to atoms
	we initialize

	* src/group-private.h: private header shared between
	group-props.c, group.c

	* src/group-props.h, src/group-props.c: new files to contain
	functions for retrieving group properties

	* src/window.c (meta_window_same_application): change this a bit
	to work with new definition of group

	* src/group.c (meta_window_get_group): always create a group for
	every window, using the window's own ID as group leader if
	required.

	* src/window.c (update_wm_hints): handle changes to group leader

	* src/group.c (meta_window_group_leader_changed): new function

	* src/display.h (struct _MetaDisplay): _NET_WM_WINDOW_TYPE_SPLASH,
	not SPLASHSCREEN. Reported by Gregory Merchan and Matthias Clasen.

	* src/screen.c (startup_sequence_timeout): when timing out a
	startup sequence, send a remove message, don't just time it out
	locally.
parent eb40c5c2
2002-11-30 Havoc Pennington <hp@pobox.com>
* src/screen.c (STARTUP_TIMEOUT): lengthen to 15 seconds
* src/util.c (utf8_fputs): hmm, return a value
* src/screen.c (meta_screen_apply_startup_properties): new
function to apply initial workspace based on startup sequence.
* src/window.c (meta_window_new): load _NET_STARTUP_ID
(meta_window_get_startup_id): new function
* src/window-props.c (meta_display_init_window_prop_hooks): add
hooks for _NET_STARTUP_ID
* src/display.c (event_callback): send property events to
groups.
* src/xprops.c (meta_prop_get_values): make a type of INVALID
mean to ignore that property (don't fetch its value).
* src/group.c (meta_group_property_notify): new function
* src/screen.c (set_supported_hint): support _NET_STARTUP_ID
* src/display.c (meta_display_open): add _NET_STARTUP_ID to atoms
we initialize
* src/group-private.h: private header shared between
group-props.c, group.c
* src/group-props.h, src/group-props.c: new files to contain
functions for retrieving group properties
* src/window.c (meta_window_same_application): change this a bit
to work with new definition of group
* src/group.c (meta_window_get_group): always create a group for
every window, using the window's own ID as group leader if
required.
* src/window.c (update_wm_hints): handle changes to group leader
* src/group.c (meta_window_group_leader_changed): new function
* src/display.h (struct _MetaDisplay): _NET_WM_WINDOW_TYPE_SPLASH,
not SPLASHSCREEN. Reported by Gregory Merchan and Matthias Clasen.
* src/screen.c (startup_sequence_timeout): when timing out a
startup sequence, send a remove message, don't just time it out
locally.
2002-11-26 Calum Benson <calum.benson@sun.com>
* src/themes/Crux :
......
......@@ -96,7 +96,7 @@ PKG_CHECK_MODULES(METACITY_MESSAGE, gtk+-2.0 >= 2.0.0)
PKG_CHECK_MODULES(METACITY_WINDOW_DEMO, gtk+-2.0 >= 2.0.0)
PKG_CHECK_MODULES(METACITY_PROPS, gtk+-2.0 >= 2.0.0 gconf-2.0 >= 1.1.9 libglade-2.0)
STARTUP_NOTIFICATION_VERSION=0.2
STARTUP_NOTIFICATION_VERSION=0.4
if $PKG_CONFIG --atleast-version $STARTUP_NOTIFICATION_VERSION libstartup-notification-1.0; then
echo "Building with libstartup-notification"
PKG_CHECK_MODULES(METACITY, gtk+-2.0 >= 2.0.0 gconf-2.0 >= 1.1.9 libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION)
......
......@@ -35,6 +35,9 @@ metacity_SOURCES= \
gradient.h \
group.c \
group.h \
group-private.h \
group-props.c \
group-props.h \
iconcache.c \
iconcache.h \
inlinepixbufs.h \
......
......@@ -26,6 +26,7 @@
#include "screen.h"
#include "window.h"
#include "window-props.h"
#include "group-props.h"
#include "frame.h"
#include "errors.h"
#include "keybindings.h"
......@@ -225,7 +226,7 @@ meta_display_open (const char *name)
"_METACITY_SET_KEYBINDINGS_MESSAGE",
"_NET_WM_STATE_HIDDEN",
"_NET_WM_WINDOW_TYPE_UTILITY",
"_NET_WM_WINDOW_TYPE_SPLASHSCREEN",
"_NET_WM_WINDOW_TYPE_SPLASH",
"_NET_WM_STATE_FULLSCREEN",
"_NET_WM_PING",
"_NET_WM_PID",
......@@ -250,7 +251,8 @@ meta_display_open (const char *name)
"_NET_WM_ACTION_CHANGE_DESKTOP",
"_NET_WM_ACTION_CLOSE",
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_BELOW"
"_NET_WM_STATE_BELOW",
"_NET_STARTUP_ID"
};
Atom atoms[G_N_ELEMENTS(atom_names)];
......@@ -358,7 +360,7 @@ meta_display_open (const char *name)
display->atom_metacity_set_keybindings_message = atoms[48];
display->atom_net_wm_state_hidden = atoms[49];
display->atom_net_wm_window_type_utility = atoms[50];
display->atom_net_wm_window_type_splashscreen = atoms[51];
display->atom_net_wm_window_type_splash = atoms[51];
display->atom_net_wm_state_fullscreen = atoms[52];
display->atom_net_wm_ping = atoms[53];
display->atom_net_wm_pid = atoms[54];
......@@ -384,9 +386,12 @@ meta_display_open (const char *name)
display->atom_net_wm_action_close = atoms[74];
display->atom_net_wm_state_above = atoms[75];
display->atom_net_wm_state_below = atoms[76];
display->atom_net_startup_id = atoms[77];
display->prop_hooks = NULL;
meta_display_init_window_prop_hooks (display);
display->group_prop_hooks = NULL;
meta_display_init_group_prop_hooks (display);
/* Offscreen unmapped window used for _NET_SUPPORTING_WM_CHECK,
* created in screen_new
......@@ -669,6 +674,7 @@ meta_display_close (MetaDisplay *display)
XFlush (display->xdisplay);
meta_display_free_window_prop_hooks (display);
meta_display_free_group_prop_hooks (display);
#ifndef USE_GDK_DISPLAY
meta_event_queue_free (display->events);
......@@ -1525,25 +1531,34 @@ event_callback (XEvent *event,
case CirculateRequest:
break;
case PropertyNotify:
if (window && !frame_was_receiver)
meta_window_property_notify (window, event);
else
{
MetaScreen *screen;
{
MetaGroup *group;
MetaScreen *screen;
if (window && !frame_was_receiver)
meta_window_property_notify (window, event);
group = meta_display_lookup_group (display,
event->xproperty.window);
if (group != NULL)
meta_group_property_notify (group, event);
screen = NULL;
if (window == NULL &&
group == NULL) /* window/group != NULL means it wasn't a root window */
screen = meta_display_screen_for_root (display,
event->xproperty.window);
if (screen)
{
if (event->xproperty.atom ==
display->atom_net_desktop_layout)
meta_screen_update_workspace_layout (screen);
else if (event->xproperty.atom ==
display->atom_net_desktop_names)
meta_screen_update_workspace_names (screen);
}
}
if (screen != NULL)
{
if (event->xproperty.atom ==
display->atom_net_desktop_layout)
meta_screen_update_workspace_layout (screen);
else if (event->xproperty.atom ==
display->atom_net_desktop_names)
meta_screen_update_workspace_names (screen);
}
}
break;
case SelectionClear:
/* do this here instead of at end of function
......
......@@ -58,6 +58,7 @@ typedef struct _MetaWindow MetaWindow;
typedef struct _MetaWorkspace MetaWorkspace;
typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
typedef void (* MetaWindowPingFunc) (MetaDisplay *display,
Window xwindow,
......@@ -133,7 +134,7 @@ struct _MetaDisplay
Atom atom_metacity_set_keybindings_message;
Atom atom_net_wm_state_hidden;
Atom atom_net_wm_window_type_utility;
Atom atom_net_wm_window_type_splashscreen;
Atom atom_net_wm_window_type_splash;
Atom atom_net_wm_ping;
Atom atom_net_wm_pid;
Atom atom_wm_client_machine;
......@@ -159,6 +160,7 @@ struct _MetaDisplay
Atom atom_net_wm_action_close;
Atom atom_net_wm_state_above;
Atom atom_net_wm_state_below;
Atom atom_net_startup_id;
/* This is the actual window from focus events,
* not the one we last set
......@@ -267,6 +269,9 @@ struct _MetaDisplay
/* Managed by window-props.c */
MetaWindowPropHooks *prop_hooks;
/* Managed by group-props.c */
MetaGroupPropHooks *group_prop_hooks;
#ifdef HAVE_STARTUP_NOTIFICATION
/* This is at the end in case someone doesn't include config.h before this file
......
/* Metacity window group private header */
/*
* Copyright (C) 2002 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef META_GROUP_PRIVATE_H
#define META_GROUP_PRIVATE_H
#include "group.h"
struct _MetaGroup
{
int refcount;
MetaDisplay *display;
GSList *windows;
Window group_leader;
char *startup_id;
char *wm_client_machine;
};
#endif
/* MetaGroup property handling */
/*
* Copyright (C) 2002 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <config.h>
#include "group-props.h"
#include "group-private.h"
#include "xprops.h"
#include <X11/Xatom.h>
typedef void (* InitValueFunc) (MetaDisplay *display,
Atom property,
MetaPropValue *value);
typedef void (* ReloadValueFunc) (MetaGroup *group,
MetaPropValue *value);
struct _MetaGroupPropHooks
{
Atom property;
InitValueFunc init_func;
ReloadValueFunc reload_func;
};
static void init_prop_value (MetaDisplay *display,
Atom property,
MetaPropValue *value);
static void reload_prop_value (MetaGroup *group,
MetaPropValue *value);
static MetaGroupPropHooks* find_hooks (MetaDisplay *display,
Atom property);
void
meta_group_reload_property (MetaGroup *group,
Atom property)
{
meta_group_reload_properties (group, &property, 1);
}
void
meta_group_reload_properties (MetaGroup *group,
const Atom *properties,
int n_properties)
{
int i;
MetaPropValue *values;
g_return_if_fail (properties != NULL);
g_return_if_fail (n_properties > 0);
values = g_new0 (MetaPropValue, n_properties);
i = 0;
while (i < n_properties)
{
init_prop_value (group->display, properties[i], &values[i]);
++i;
}
meta_prop_get_values (group->display, group->group_leader,
values, n_properties);
i = 0;
while (i < n_properties)
{
reload_prop_value (group, &values[i]);
++i;
}
meta_prop_free_values (values, n_properties);
g_free (values);
}
/* Fill in the MetaPropValue used to get the value of "property" */
static void
init_prop_value (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
MetaGroupPropHooks *hooks;
value->type = META_PROP_VALUE_INVALID;
value->atom = None;
hooks = find_hooks (display, property);
if (hooks && hooks->init_func != NULL)
(* hooks->init_func) (display, property, value);
}
static void
reload_prop_value (MetaGroup *group,
MetaPropValue *value)
{
MetaGroupPropHooks *hooks;
hooks = find_hooks (group->display, value->atom);
if (hooks && hooks->reload_func != NULL)
(* hooks->reload_func) (group, value);
}
static void
init_wm_client_machine (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_STRING;
value->atom = display->atom_wm_client_machine;
}
static void
reload_wm_client_machine (MetaGroup *group,
MetaPropValue *value)
{
g_free (group->wm_client_machine);
group->wm_client_machine = NULL;
if (value->type != META_PROP_VALUE_INVALID)
group->wm_client_machine = g_strdup (value->v.str);
meta_verbose ("Group has client machine \"%s\"\n",
group->wm_client_machine ? group->wm_client_machine : "unset");
}
static void
init_net_startup_id (MetaDisplay *display,
Atom property,
MetaPropValue *value)
{
value->type = META_PROP_VALUE_UTF8;
value->atom = display->atom_net_startup_id;
}
static void
reload_net_startup_id (MetaGroup *group,
MetaPropValue *value)
{
g_free (group->startup_id);
group->startup_id = NULL;
if (value->type != META_PROP_VALUE_INVALID)
group->startup_id = g_strdup (value->v.str);
meta_verbose ("Group has startup id \"%s\"\n",
group->startup_id ? group->startup_id : "unset");
}
#define N_HOOKS 3
void
meta_display_init_group_prop_hooks (MetaDisplay *display)
{
int i;
MetaGroupPropHooks *hooks;
g_assert (display->group_prop_hooks == NULL);
display->group_prop_hooks = g_new0 (MetaGroupPropHooks, N_HOOKS);
hooks = display->group_prop_hooks;
i = 0;
hooks[i].property = display->atom_wm_client_machine;
hooks[i].init_func = init_wm_client_machine;
hooks[i].reload_func = reload_wm_client_machine;
++i;
hooks[i].property = display->atom_net_wm_pid;
hooks[i].init_func = NULL;
hooks[i].reload_func = NULL;
++i;
hooks[i].property = display->atom_net_startup_id;
hooks[i].init_func = init_net_startup_id;
hooks[i].reload_func = reload_net_startup_id;
++i;
if (i != N_HOOKS)
g_error ("Initialized %d group hooks should have been %d\n", i, N_HOOKS);
}
void
meta_display_free_group_prop_hooks (MetaDisplay *display)
{
g_assert (display->group_prop_hooks != NULL);
g_free (display->group_prop_hooks);
display->group_prop_hooks = NULL;
}
static MetaGroupPropHooks*
find_hooks (MetaDisplay *display,
Atom property)
{
int i;
/* FIXME we could sort the array and do binary search or
* something
*/
i = 0;
while (i < N_HOOKS)
{
if (display->group_prop_hooks[i].property == property)
return &display->group_prop_hooks[i];
++i;
}
return NULL;
}
/* MetaGroup property handling */
/*
* Copyright (C) 2002 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef META_GROUP_PROPS_H
#define META_GROUP_PROPS_H
#include "group.h"
void meta_group_reload_property (MetaGroup *group,
Atom property);
void meta_group_reload_properties (MetaGroup *group,
const Atom *properties,
int n_properties);
void meta_display_init_group_prop_hooks (MetaDisplay *display);
void meta_display_free_group_prop_hooks (MetaDisplay *display);
#endif /* META_GROUP_PROPS_H */
......@@ -21,23 +21,21 @@
#include <config.h>
#include "util.h"
#include "group.h"
#include "group-private.h"
#include "group-props.h"
#include "window.h"
struct _MetaGroup
{
MetaDisplay *display;
GSList *windows;
Window group_leader;
int refcount;
};
static MetaGroup*
meta_group_new (MetaDisplay *display,
Window group_leader)
{
MetaGroup *group;
#define N_INITIAL_PROPS 3
Atom initial_props[N_INITIAL_PROPS];
int i;
g_assert (N_INITIAL_PROPS == (int) G_N_ELEMENTS (initial_props));
group = g_new0 (MetaGroup, 1);
group->display = display;
......@@ -54,6 +52,19 @@ meta_group_new (MetaDisplay *display,
g_hash_table_insert (display->groups_by_leader,
&group->group_leader,
group);
/* Fill these in the order we want them to be gotten */
i = 0;
initial_props[i++] = display->atom_wm_client_machine;
initial_props[i++] = display->atom_net_wm_pid;
initial_props[i++] = display->atom_net_startup_id;
g_assert (N_INITIAL_PROPS == i);
meta_group_reload_properties (group, initial_props, N_INITIAL_PROPS);
meta_topic (META_DEBUG_GROUPS,
"Created new group with leader 0x%lx\n",
group->group_leader);
return group;
}
......@@ -66,6 +77,10 @@ meta_group_unref (MetaGroup *group)
group->refcount -= 1;
if (group->refcount == 0)
{
meta_topic (META_DEBUG_GROUPS,
"Destroying group with leader 0x%lx\n",
group->group_leader);
g_assert (group->display->groups_by_leader != NULL);
g_hash_table_remove (group->display->groups_by_leader,
......@@ -78,6 +93,9 @@ meta_group_unref (MetaGroup *group)
group->display->groups_by_leader = NULL;
}
g_free (group->wm_client_machine);
g_free (group->startup_id);
g_free (group);
}
}
......@@ -88,16 +106,23 @@ meta_window_get_group (MetaWindow *window)
if (window->unmanaging)
return NULL;
if (window->cached_group == NULL &&
window->xgroup_leader != None) /* some windows have no group */
if (window->cached_group == NULL)
{
MetaGroup *group;
/* use window->xwindow if no window->xgroup_leader */
group = NULL;
if (window->display->groups_by_leader)
group = g_hash_table_lookup (window->display->groups_by_leader,
&window->xgroup_leader);
{
if (window->xgroup_leader != None)
group = g_hash_table_lookup (window->display->groups_by_leader,
&window->xgroup_leader);
else
group = g_hash_table_lookup (window->display->groups_by_leader,
&window->xwindow);
}
if (group != NULL)
{
......@@ -106,24 +131,36 @@ meta_window_get_group (MetaWindow *window)
}
else
{
group = meta_group_new (window->display,
window->xgroup_leader);
if (window->xgroup_leader != None)
group = meta_group_new (window->display,
window->xgroup_leader);
else
group = meta_group_new (window->display,
window->xwindow);