--- a/gntwm.c Fri May 10 04:09:23 2019 -0400
+++ b/gntwm.c Fri May 10 04:28:35 2019 -0400
@@ -106,6 +106,8 @@
@@ -376,6 +378,7 @@
read_window_positions(GntWM *wm)
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); GKeyFile *gfile = g_key_file_new();
char *filename = g_build_filename(gnt_get_config_dir(), ".gntpositions", NULL);
@@ -405,7 +408,7 @@
GntPosition *p = g_new0(GntPosition, 1);
- g_hash_table_replace(wm->positions, g_strdup(title + 1), p);
+ g_hash_table_replace(priv->positions, g_strdup(title + 1), p); gnt_warning("Invalid number of arguments (%" G_GSIZE_FORMAT
") for positioning a window.", l);
@@ -447,7 +450,7 @@
priv->nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
- wm->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ priv->positions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (gnt_style_get_bool(GNT_STYLE_REMPOS, TRUE))
read_window_positions(wm);
g_timeout_add_seconds(IDLE_CHECK_INTERVAL, check_idle, NULL);
@@ -2010,7 +2013,7 @@
if (GNT_IS_BOX(widget)) {
const gchar *title = gnt_box_get_title(GNT_BOX(widget));
- if (title && (p = g_hash_table_lookup(wm->positions, title)) != NULL) {
+ if (title && (p = g_hash_table_lookup(priv->positions, title)) != NULL) { sanitize_position(widget, &p->x, &p->y, TRUE);
gnt_widget_set_position(widget, p->x, p->y);
mvwin(gnt_widget_get_window(widget), p->y, p->x);
@@ -2274,6 +2277,7 @@
write_already(gpointer data)
+ GntWMPrivate *priv = gnt_wm_get_instance_private(wm); @@ -2284,7 +2288,7 @@
gnt_warning("error opening file (%s) to save positions", filename);
fprintf(file, "[positions]\n");
- g_hash_table_foreach(wm->positions, (GHFunc)write_gdi, file);
+ g_hash_table_foreach(priv->positions, (GHFunc)write_gdi, file); @@ -2332,7 +2336,7 @@
GntPosition *p = g_new0(GntPosition, 1);
GntWidget *wid = node->me;
gnt_widget_get_position(wid, &p->x, &p->y);
- g_hash_table_replace(wm->positions, g_strdup(title), p);
+ g_hash_table_replace(priv->positions, g_strdup(title), p); write_positions_to_file(wm);
@@ -2439,6 +2443,17 @@
g_hash_table_foreach(priv->nodes, func, user_data);
+gnt_wm_has_window_position(GntWM *wm, const gchar *title) + GntWMPrivate *priv = NULL; + g_return_val_if_fail(GNT_IS_WM(wm), FALSE); + priv = gnt_wm_get_instance_private(wm); + return g_hash_table_lookup(priv->positions, title) != NULL; gnt_wm_set_mainloop(GntWM *wm, GMainLoop *loop)
--- a/gntwm.h Fri May 10 04:09:23 2019 -0400
+++ b/gntwm.h Fri May 10 04:28:35 2019 -0400
@@ -85,9 +85,6 @@
- GHashTable *GNTSEAL(positions);
@@ -353,6 +350,20 @@
time_t gnt_wm_get_idle_time(void);
+ * gnt_wm_has_window_position: + * @wm: The window-manager. + * @title: The title of the window. + * Checks whether the window manager has a recorded window position for a + * window with the given @title. + * Returns: #TRUE if a position is recorded for the window, %FALSE otherwise. +gboolean gnt_wm_has_window_position(GntWM *wm, const gchar *title); --- a/wms/s.c Fri May 10 04:09:23 2019 -0400
+++ b/wms/s.c Fri May 10 04:28:35 2019 -0400
@@ -129,7 +129,7 @@
gnt_widget_set_size(win, -1, h + 2); /* XXX: Why is the +2 needed here? -- sadrul */
} else if (!gnt_widget_get_transient(win)) {
const gchar *title = gnt_box_get_title(GNT_BOX(win));
- if (title == NULL || !g_hash_table_lookup(wm->positions, title)) {
+ if (title == NULL || !gnt_wm_has_window_position(wm, title)) { /* In the middle of the screen */