]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[script] Allow setting the position of the windows
authorCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 29 Nov 2009 01:19:37 +0000 (01:19 +0000)
committerCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 29 Nov 2009 01:19:37 +0000 (01:19 +0000)
Although the windows are set up to in a reasonable default configuration, the
themes may align the windows differently to not crop some important elements.

The Window.SetX and SetY allow positioning the window anywhere on the canvas.
Use this sparingly as it induces a full refresh of all screens.

If there is a desire to have totally different scenes, the second window can be
positioned somewhere far away so there is overlap and a complete different set
of sprites is used. Another sensible configuration is to have the screens side
by side and allow sprites to span the gap. Remember to create password dialogs
for each screen as not all may be visible.

src/plugins/splash/script/script-lib-sprite.c

index 959deaedc695b8aba4a5c2eea01ba50e99bd9911..8b3dd382915ec0d6cc8a78f63a5c1b4e2210f0de 100644 (file)
@@ -200,6 +200,55 @@ static script_return_t sprite_window_get_height (script_state_t *state,
   return script_return_obj (script_obj_new_number (height));
 }
 
+static script_return_t sprite_window_set_x (script_state_t *state,
+                                            void           *user_data)
+{
+  script_lib_sprite_data_t *data = user_data;
+  ply_list_node_t *node;
+  script_lib_display_t *display;
+  int index;
+  int x;
+
+  index = script_obj_hash_get_number (state->local, "window");
+  x = script_obj_hash_get_number (state->local, "value");
+  node = ply_list_get_nth_node (data->displays, index);
+  if (node)
+    {
+      display = ply_list_node_get_data (node);
+      if (display->x != x)
+        {
+          display->x = x;
+          data->full_refresh = true;
+        }
+    }
+  return script_return_obj_null ();
+}
+
+static script_return_t sprite_window_set_y (script_state_t *state,
+                                            void           *user_data)
+{
+  script_lib_sprite_data_t *data = user_data;
+  ply_list_node_t *node;
+  script_lib_display_t *display;
+  int index;
+  int y;
+
+  index = script_obj_hash_get_number (state->local, "window");
+  y = script_obj_hash_get_number (state->local, "value");
+  ply_trace("%d\n", index);
+  node = ply_list_get_nth_node (data->displays, index);
+  if (node)
+    {
+      display = ply_list_node_get_data (node);
+      if (display->y != y)
+        {
+          display->y = y;
+          data->full_refresh = true;
+        }
+    }
+  return script_return_obj_null ();
+}
+
 static uint32_t extract_rgb_color (script_state_t *state)
 {
   uint8_t red =   CLAMP (255 * script_obj_hash_get_number (state->local, "red"),   0, 255);
@@ -399,6 +448,20 @@ script_lib_sprite_data_t *script_lib_sprite_setup (script_state_t *state,
                               data,
                               "window",
                               NULL);
+  script_add_native_function (window_hash,
+                              "SetX",
+                              sprite_window_set_x,
+                              data,
+                              "window",
+                              "value",
+                              NULL);
+  script_add_native_function (window_hash,
+                              "SetY",
+                              sprite_window_set_y,
+                              data,
+                              "window",
+                              "value",
+                              NULL);
   script_add_native_function (window_hash,
                               "SetBackgroundTopColor",
                               sprite_window_set_background_top_color,