self->have_real_transparency = FALSE;
}
+/* Center the given TildaWindow in the horizontal axis */
+static void
+tilda_window_center_horizontally (TildaWindow *self)
+{
+ const gint screen_center = gdk_screen_width() / 2;
+ const gint tilda_center = self->width / 2;
+ const gint center_coord = screen_center - tilda_center;
+
+ g_object_set (G_OBJECT(self), "x-position", center_coord, NULL);
+}
+
+/* Center the given TildaWindow in the vertical axis */
+static void
+tilda_window_center_vertically (TildaWindow *self)
+{
+ const gint screen_center = gdk_screen_height() / 2;
+ const gint tilda_center = self->height / 2;
+ const gint center_coord = screen_center - tilda_center;
+
+ g_object_set (G_OBJECT(self), "y-position", center_coord, NULL);
+}
+
static void
tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
{
case TILDA_WINDOW_CENTERED_HORIZONTALLY:
self->centered_horizontally = g_value_get_boolean (value);
+ if (self->centered_horizontally)
+ tilda_window_center_horizontally (self);
g_print ("window centered horizontally: %d\n", self->centered_horizontally);
break;
case TILDA_WINDOW_CENTERED_VERTICALLY:
self->centered_vertically = g_value_get_boolean (value);
+ if (self->centered_vertically)
+ tilda_window_center_vertically (self);
g_print ("window centered vertically: %d\n", self->centered_vertically);
break;