Commit d5cd6921 authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz
Browse files

Add fields to PanelToplevel to have the possibility to use a position

2007-06-29  Vincent Untz  <vuntz@gnome.org>

	Add fields to PanelToplevel to have the possibility to use a position
	relative from the right and/or bottom of the monitor. This is mainly
	for non-expanded panels. This fixes the panel position:
	 - after a resolution change: if the panel was at the bottom or right
	   of the screen and the resolution goes down and up again, we no
	   longer have a panel that starts to be floating for no reason
	 - when the panel is at the right of the screen and its size grows
	   (because of a tasklist): it no longer becomes centered or snaps to
	   the left of the screen.
	This change should still compatibility with older configuration: if
	you log in with an older GNOME after having used 2.20, things should
	still work as expected.
	Fix bug #107622 (and maybe other bugs).

	* panel-toplevel.schemas.in: add x_right, y_bottom keys for toplevels
	* panel-default-setup.entries: add those keys in the default setup
	* panel-profile.c: (panel_profile_queue_toplevel_location_change):
	(panel_profile_connect_to_toplevel):
	(panel_profile_toplevel_change_notify):
	(panel_profile_load_toplevel):
	(panel_profile_can_be_moved_freely): basically, a dumb update to
	handle the new keys (I just searched for what was done for the x and y
	keys and copied that)
	* panel-toplevel.[ch]: add new fields and properties for x_right and
	y_bottom
	(panel_toplevel_begin_grab_op): updated
	(panel_toplevel_cancel_grab_op): updated
	(panel_toplevel_resize_to_pointer): update y_bottom and x_right when
	this is necessary
	(panel_toplevel_move_to): fix x (y) when x_centered (y_centered) is
	true, and compute the new x_right/y_bottom values
	(panel_toplevel_calc_floating): use position from x_right/y_bottom
	when they're different from -1
	(panel_toplevel_update_normal_position): don't set x/y after snapping:
	this is just wrong, since setting x/y should only be done after a
	direct change by the user (and not automatically). This function is
	only used to update the x/y in the geometry, and not in the config.
	Also, to determine if we need to snap, only use x/y (with right/bottom
	variants) from the config, not the computed values imposed by
	constraints. This part fix the case where a panel is right aligned,
	but gets centered and then left aligned because its size grows
	(panel_toplevel_update_auto_hide_position): same update
	(panel_toplevel_update_expanded_position): compute x_right and
	y_bottom too, and notify of their changes when needed
	(panel_toplevel_update_position): handle x_right/y_bottom in the
	temporary position_centered case, and core part of the change: use
	x_right/y_bottom when they're not -1
	(panel_toplevel_set_property): updated for new properties
	(panel_toplevel_get_property): ditto
	(panel_toplevel_class_init): ditto
	(panel_toplevel_init): ditto
	(panel_toplevel_set_expand): small update to put the right values for
	x_right/y_bottom
	(panel_toplevel_set_orientation): when rotating a centered panel, set
	the relevant x_right/y_bottom value to -1 (since the rotated panel is
	centered (but not "force-centered"), its position is relative to the
	left/top
	(panel_toplevel_set_x): add x_right handling
	(panel_toplevel_set_y): add y_bottom handling
	(panel_toplevel_get_position): add x_right/y_bottom handling

svn path=/trunk/; revision=10497
parent 5fbbb953
2007-06-29 Vincent Untz <vuntz@gnome.org>
Add fields to PanelToplevel to have the possibility to use a position
relative from the right and/or bottom of the monitor. This is mainly
for non-expanded panels. This fixes the panel position:
- after a resolution change: if the panel was at the bottom or right
of the screen and the resolution goes down and up again, we no
longer have a panel that starts to be floating for no reason
- when the panel is at the right of the screen and its size grows
(because of a tasklist): it no longer becomes centered or snaps to
the left of the screen.
This change should still compatibility with older configuration: if
you log in with an older GNOME after having used 2.20, things should
still work as expected.
Fix bug #107622 (and maybe other bugs).
* panel-toplevel.schemas.in: add x_right, y_bottom keys for toplevels
* panel-default-setup.entries: add those keys in the default setup
* panel-profile.c: (panel_profile_queue_toplevel_location_change):
(panel_profile_connect_to_toplevel):
(panel_profile_toplevel_change_notify):
(panel_profile_load_toplevel):
(panel_profile_can_be_moved_freely): basically, a dumb update to
handle the new keys (I just searched for what was done for the x and y
keys and copied that)
* panel-toplevel.[ch]: add new fields and properties for x_right and
y_bottom
(panel_toplevel_begin_grab_op): updated
(panel_toplevel_cancel_grab_op): updated
(panel_toplevel_resize_to_pointer): update y_bottom and x_right when
this is necessary
(panel_toplevel_move_to): fix x (y) when x_centered (y_centered) is
true, and compute the new x_right/y_bottom values
(panel_toplevel_calc_floating): use position from x_right/y_bottom
when they're different from -1
(panel_toplevel_update_normal_position): don't set x/y after snapping:
this is just wrong, since setting x/y should only be done after a
direct change by the user (and not automatically). This function is
only used to update the x/y in the geometry, and not in the config.
Also, to determine if we need to snap, only use x/y (with right/bottom
variants) from the config, not the computed values imposed by
constraints. This part fix the case where a panel is right aligned,
but gets centered and then left aligned because its size grows
(panel_toplevel_update_auto_hide_position): same update
(panel_toplevel_update_expanded_position): compute x_right and
y_bottom too, and notify of their changes when needed
(panel_toplevel_update_position): handle x_right/y_bottom in the
temporary position_centered case, and core part of the change: use
x_right/y_bottom when they're not -1
(panel_toplevel_set_property): updated for new properties
(panel_toplevel_get_property): ditto
(panel_toplevel_class_init): ditto
(panel_toplevel_init): ditto
(panel_toplevel_set_expand): small update to put the right values for
x_right/y_bottom
(panel_toplevel_set_orientation): when rotating a centered panel, set
the relevant x_right/y_bottom value to -1 (since the rotated panel is
centered (but not "force-centered"), its position is relative to the
left/top
(panel_toplevel_set_x): add x_right handling
(panel_toplevel_set_y): add y_bottom handling
(panel_toplevel_get_position): add x_right/y_bottom handling
2007-06-26 Vincent Untz <vuntz@gnome.org>
 
* gnome-desktop-item-edit.c: (main): use
......
......@@ -100,6 +100,8 @@
<entry><key>toplevels/top_panel/monitor</key><schema_key>/schemas/apps/panel/toplevels/monitor</schema_key></entry>
<entry><key>toplevels/top_panel/x</key><schema_key>/schemas/apps/panel/toplevels/x</schema_key></entry>
<entry><key>toplevels/top_panel/y</key><schema_key>/schemas/apps/panel/toplevels/y</schema_key></entry>
<entry><key>toplevels/top_panel/x_right</key><schema_key>/schemas/apps/panel/toplevels/x_right</schema_key></entry>
<entry><key>toplevels/top_panel/y_bottom</key><schema_key>/schemas/apps/panel/toplevels/y_bottom</schema_key></entry>
<entry><key>toplevels/top_panel/x_centered</key><schema_key>/schemas/apps/panel/toplevels/x_centered</schema_key></entry>
<entry><key>toplevels/top_panel/y_centered</key><schema_key>/schemas/apps/panel/toplevels/y_centered</schema_key></entry>
<entry><key>toplevels/top_panel/auto_hide</key><schema_key>/schemas/apps/panel/toplevels/auto_hide</schema_key></entry>
......@@ -140,12 +142,20 @@
<int>24</int>
</value>
</entry>
<entry>
<key>toplevels/top_panel/y_bottom</key>
<schema_key>/schemas/apps/panel/toplevels/y_bottom</schema_key>
<value>
<int>0</int>
</value>
</entry>
<entry><key>toplevels/bottom_panel/name</key><schema_key>/schemas/apps/panel/toplevels/name</schema_key></entry>
<entry><key>toplevels/bottom_panel/screen</key><schema_key>/schemas/apps/panel/toplevels/screen</schema_key></entry>
<entry><key>toplevels/bottom_panel/monitor</key><schema_key>/schemas/apps/panel/toplevels/monitor</schema_key></entry>
<entry><key>toplevels/bottom_panel/x</key><schema_key>/schemas/apps/panel/toplevels/x</schema_key></entry>
<entry><key>toplevels/bottom_panel/y</key><schema_key>/schemas/apps/panel/toplevels/y</schema_key></entry>
<entry><key>toplevels/top_panel/x_right</key><schema_key>/schemas/apps/panel/toplevels/x_right</schema_key></entry>
<entry><key>toplevels/bottom_panel/x_centered</key><schema_key>/schemas/apps/panel/toplevels/x_centered</schema_key></entry>
<entry><key>toplevels/bottom_panel/y_centered</key><schema_key>/schemas/apps/panel/toplevels/y_centered</schema_key></entry>
<entry><key>toplevels/bottom_panel/auto_hide</key><schema_key>/schemas/apps/panel/toplevels/auto_hide</schema_key></entry>
......
......@@ -44,8 +44,10 @@ typedef struct {
int monitor;
int size;
int x;
int x_right;
gboolean x_centered;
int y;
int y_bottom;
gboolean y_centered;
PanelOrientation orientation;
......@@ -53,8 +55,10 @@ typedef struct {
guint monitor_changed : 1;
guint size_changed : 1;
guint x_changed : 1;
guint x_right_changed : 1;
guint x_centered_changed : 1;
guint y_changed : 1;
guint y_bottom_changed : 1;
guint y_centered_changed : 1;
guint orientation_changed : 1;
} ToplevelLocationChange;
......@@ -934,6 +938,12 @@ panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel,
panel_profile_get_toplevel_key (toplevel, "x"),
change->x);
if (change->x_right_changed)
gconf_change_set_set_int (
queued_changes,
panel_profile_get_toplevel_key (toplevel, "x_right"),
change->x_right);
if (change->x_centered_changed)
gconf_change_set_set_bool (
queued_changes,
......@@ -946,6 +956,12 @@ panel_profile_queue_toplevel_location_change (PanelToplevel *toplevel,
panel_profile_get_toplevel_key (toplevel, "y"),
change->y);
if (change->y_bottom_changed)
gconf_change_set_set_int (
queued_changes,
panel_profile_get_toplevel_key (toplevel, "y_bottom"),
change->y_bottom);
if (change->y_centered_changed)
gconf_change_set_set_bool (
queued_changes,
......@@ -984,15 +1000,19 @@ TOPLEVEL_LOCATION_CHANGED_HANDLER(y_centered)
panel_profile_toplevel_##c##_changed (PanelToplevel *toplevel) \
{ \
ToplevelLocationChange change = { NULL }; \
int x, y; \
int x, y, x_right, y_bottom; \
change.c##_changed = TRUE; \
panel_toplevel_get_position (toplevel, &x, &y); \
panel_toplevel_get_position (toplevel, \
&x, &x_right, \
&y, &y_bottom); \
change.c = c; \
panel_profile_queue_toplevel_location_change (toplevel, &change); \
}
TOPLEVEL_POSITION_CHANGED_HANDLER(x)
TOPLEVEL_POSITION_CHANGED_HANDLER(x_right)
TOPLEVEL_POSITION_CHANGED_HANDLER(y)
TOPLEVEL_POSITION_CHANGED_HANDLER(y_bottom)
static void
panel_profile_toplevel_screen_changed (PanelToplevel *toplevel)
......@@ -1016,10 +1036,14 @@ panel_profile_connect_to_toplevel (PanelToplevel *toplevel)
G_CALLBACK (panel_profile_toplevel_size_changed), NULL);
g_signal_connect (toplevel, "notify::x",
G_CALLBACK (panel_profile_toplevel_x_changed), NULL);
g_signal_connect (toplevel, "notify::x-right",
G_CALLBACK (panel_profile_toplevel_x_right_changed), NULL);
g_signal_connect (toplevel, "notify::x-centered",
G_CALLBACK (panel_profile_toplevel_x_centered_changed), NULL);
g_signal_connect (toplevel, "notify::y",
G_CALLBACK (panel_profile_toplevel_y_changed), NULL);
g_signal_connect (toplevel, "notify::y-bottom",
G_CALLBACK (panel_profile_toplevel_y_bottom_changed), NULL);
g_signal_connect (toplevel, "notify::y-centered",
G_CALLBACK (panel_profile_toplevel_y_centered_changed), NULL);
g_signal_connect (toplevel, "notify::orientation",
......@@ -1095,22 +1119,42 @@ panel_profile_toplevel_change_notify (GConfClient *client,
gconf_value_get_bool (value)); \
}
#define UPDATE_POS(k, n) \
#define UPDATE_POS(k, n, n2) \
if (!strcmp (key, k)) { \
if (value->type == GCONF_VALUE_INT) \
if (value->type == GCONF_VALUE_INT) { \
int x, x_right, y, y_bottom; \
panel_toplevel_get_position (toplevel, &x, &x_right, \
&y, &y_bottom); \
panel_toplevel_set_##n ( \
toplevel, \
gconf_value_get_int (value), \
n2, \
panel_toplevel_get_##n##_centered (toplevel)); \
} \
}
#define UPDATE_CENTERED(k, n) \
#define UPDATE_POS2(k, n, n2) \
if (!strcmp (key, k)) { \
if (value->type == GCONF_VALUE_INT) { \
int x, x_right, y, y_bottom; \
panel_toplevel_get_position (toplevel, &x, &x_right, \
&y, &y_bottom); \
panel_toplevel_set_##n ( \
toplevel, \
n, \
gconf_value_get_int (value), \
panel_toplevel_get_##n##_centered (toplevel)); \
} \
}
#define UPDATE_CENTERED(k, n, n2) \
if (!strcmp (key, k)) { \
if (value->type == GCONF_VALUE_BOOL) { \
int x, y; \
panel_toplevel_get_position (toplevel, &x, &y); \
int x, x_right, y, y_bottom; \
panel_toplevel_get_position (toplevel, &x, &x_right, \
&y, &y_bottom); \
panel_toplevel_set_##n ( \
toplevel, n, gconf_value_get_bool (value)); \
toplevel, n, n2, gconf_value_get_bool (value)); \
} \
}
......@@ -1137,10 +1181,12 @@ panel_profile_toplevel_change_notify (GConfClient *client,
else UPDATE_BOOL ("expand", expand)
else UPDATE_STRING ("orientation", orientation)
else UPDATE_INT ("size", size)
else UPDATE_POS ("x", x)
else UPDATE_POS ("y", y)
else UPDATE_CENTERED ("x_centered", x)
else UPDATE_CENTERED ("y_centered", y)
else UPDATE_POS ("x", x, x_right)
else UPDATE_POS ("y", y, y_bottom)
else UPDATE_POS2 ("x_right", x, x_right)
else UPDATE_POS2 ("y_bottom", y, y_bottom)
else UPDATE_CENTERED ("x_centered", x, x_right)
else UPDATE_CENTERED ("y_centered", y, y_bottom)
else UPDATE_BOOL ("auto_hide", auto_hide)
else UPDATE_BOOL ("enable_animations", animate)
else UPDATE_BOOL ("enable_buttons", enable_buttons)
......@@ -1665,17 +1711,24 @@ panel_profile_load_toplevel (GConfClient *client,
GET_INT ("auto_hide_size", auto_hide_size);
GET_STRING ("animation_speed", animation_speed);
#define GET_POSITION(a, c, fn) \
#define GET_POSITION(a, b, c, fn) \
{ \
gboolean centered; \
int position; \
int position2; \
key = panel_gconf_sprintf ("%s/" c, toplevel_dir); \
centered = gconf_client_get_bool (client, key, &error); \
error = NULL; \
key = panel_gconf_sprintf ("%s/" a, toplevel_dir); \
position = gconf_client_get_int (client, key, &error); \
if (!error) { \
key = panel_gconf_sprintf ("%s/" a, toplevel_dir); \
position = gconf_client_get_int (client, key, &error); \
} \
if (!error) { \
key = panel_gconf_sprintf ("%s/" b, toplevel_dir); \
position2 = gconf_client_get_int (client, key, &error); \
} \
if (!error) \
panel_toplevel_set_##fn (toplevel, position, centered); \
panel_toplevel_set_##fn (toplevel, position, position2, \
centered); \
else { \
g_warning (_("Error reading GConf integer value '%s': %s"), \
key, error->message); \
......@@ -1683,8 +1736,8 @@ panel_profile_load_toplevel (GConfClient *client,
} \
}
GET_POSITION ("x", "x_centered", x);
GET_POSITION ("y", "y_centered", y);
GET_POSITION ("x", "x_right", "x_centered", x);
GET_POSITION ("y", "y_bottom", "y_centered", y);
panel_profile_load_background (toplevel, client, toplevel_dir);
......@@ -2498,6 +2551,9 @@ panel_profile_can_be_moved_freely (PanelToplevel *toplevel)
return TRUE;
key = panel_profile_get_toplevel_key (toplevel, "x");
if (!gconf_client_key_is_writable (client, key, NULL))
return FALSE;
key = panel_profile_get_toplevel_key (toplevel, "x_right");
if (!gconf_client_key_is_writable (client, key, NULL))
return FALSE;
key = panel_profile_get_toplevel_key (toplevel, "x_centered");
......@@ -2505,6 +2561,9 @@ panel_profile_can_be_moved_freely (PanelToplevel *toplevel)
return FALSE;
key = panel_profile_get_toplevel_key (toplevel, "y");
if (!gconf_client_key_is_writable (client, key, NULL))
return FALSE;
key = panel_profile_get_toplevel_key (toplevel, "y_bottom");
if (!gconf_client_key_is_writable (client, key, NULL))
return FALSE;
key = panel_profile_get_toplevel_key (toplevel, "y_centered");
......
This diff is collapsed.
......@@ -97,13 +97,17 @@ void panel_toplevel_set_auto_hide_size (PanelToplevel
int panel_toplevel_get_auto_hide_size (PanelToplevel *toplevel);
void panel_toplevel_set_x (PanelToplevel *toplevel,
int x,
int x_right,
gboolean x_centered);
void panel_toplevel_set_y (PanelToplevel *toplevel,
int y,
int y_bottom,
gboolean y_centered);
void panel_toplevel_get_position (PanelToplevel *toplevel,
int *x,
int *y);
int *x_right,
int *y,
int *y_bottom);
gboolean panel_toplevel_get_x_centered (PanelToplevel *toplevel);
gboolean panel_toplevel_get_y_centered (PanelToplevel *toplevel);
void panel_toplevel_set_monitor (PanelToplevel *toplevel,
......
......@@ -133,6 +133,44 @@
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/panel/toplevels/x_right</key>
<owner>panel</owner>
<type>int</type>
<default>-1</default>
<locale name="C">
<short>X co-ordinate of panel, starting from the right of the screen</short>
<long>
The location of the panel along the x-axis, starting from the right of
the screen. If set to -1, the value is ignored and the value of the x
key is used. If the value is greater than 0, then the value of the x
key is ignored.
This key is only relevant in un-expanded mode. In expanded mode this
key is ignored and the panel is placed at the screen edge
specified by the orientation key.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/panel/toplevels/y_bottom</key>
<owner>panel</owner>
<type>int</type>
<default>-1</default>
<locale name="C">
<short>Y co-ordinate of panel, starting from the bottom of the screen</short>
<long>
The location of the panel along the y-axis, starting from the bottom of
the screen. If set to -1, the value is ignored and the value of the y
key is used. If the value is greater than 0, then the value of the y
key is ignored.
This key is only relevant in un-expanded mode. In expanded mode this
key is ignored and the panel is placed at the screen edge
specified by the orientation key.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/panel/toplevels/x_centered</key>
......@@ -142,10 +180,10 @@
<locale name="C">
<short>Center panel on x-axis</short>
<long>
If true, the x key is ignored and the panel is placed at
If true, the x and x_right keys are ignored and the panel is placed at
the center of the x-axis of the screen. If the panel is
resized it will remain at that position - i.e. the panel
will grow on both sides. If false, the x key specifies
will grow on both sides. If false, the x and x_right keys specify
the location of the panel.
</long>
</locale>
......@@ -159,10 +197,10 @@
<locale name="C">
<short>Center panel on y-axis</short>
<long>
If true, the y key is ignored and the panel is placed at
If true, the y and y_bottom keys are ignored and the panel is placed at
the center of the y-axis of the screen. If the panel is
resized it will remain at that position - i.e. the panel
will grow on both sides. If false, the y key specifies
will grow on both sides. If false, the y and y_bottom keys specify
the location of the panel.
</long>
</locale>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment