From: Charlie Brej Date: Sun, 29 Nov 2009 01:19:37 +0000 (+0000) Subject: [script] Allow setting the position of the windows X-Git-Tag: 0.8.0~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e487da507bc3e9720ad19b30bde5e48880fc785;p=thirdparty%2Fplymouth.git [script] Allow setting the position of the windows 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. --- diff --git a/src/plugins/splash/script/script-lib-sprite.c b/src/plugins/splash/script/script-lib-sprite.c index 959deaed..8b3dd382 100644 --- a/src/plugins/splash/script/script-lib-sprite.c +++ b/src/plugins/splash/script/script-lib-sprite.c @@ -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,