* for the code
*
* This software is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but
*/
/*******************************************************************************/
#include "livewp-scene.h"
+/* This code form X11-utils */
+Window Window_With_Name( Display *dpy, Window top, char *name)
+{
+ Window *children, dummy;
+ unsigned int nchildren;
+ int i;
+ Window w=0;
+ char *window_name;
+
+ XClassHint *class_hint;
+ class_hint = XAllocClassHint();
+ XGetClassHint(dpy, top, class_hint);
+ if (class_hint->res_name && name && !strcmp(class_hint->res_name, name)){
+ XFree(class_hint->res_class);
+ XFree(class_hint->res_name);
+ return(top);
+ }
+ XFree(class_hint->res_class);
+ XFree(class_hint->res_name);
+
+ if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
+ return(top);
+
+ if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
+ return(0);
+
+ for (i=0; i<nchildren; i++) {
+ w = Window_With_Name(dpy, children[i], name);
+ if (w)
+ break;
+ }
+ if (children) XFree ((char *)children);
+ return(w);
+}
+
+/*******************************************************************************/
void
destroy_scene(AWallpaperPlugin *desktop_plugin)
{
+ int status = 0;
+
if (desktop_plugin->priv->scene){
GSList * tmp = desktop_plugin->priv->scene->actors;
while (tmp != NULL){
}
if (desktop_plugin->priv->podpid > 1){
kill (desktop_plugin->priv->podpid, SIGTERM);
+ while (TRUE){
+ if (wait(&status) == desktop_plugin->priv->podpid)
+ break;
+ }
desktop_plugin->priv->podpid = -1;
+ desktop_plugin->priv->running = FALSE;
}
}
/*******************************************************************************/
void
reload_scene(AWallpaperPlugin *desktop_plugin)
{
- /* fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme); */
+ fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
destroy_scene(desktop_plugin);
+ fill_priv(desktop_plugin->priv);
+ gtk_widget_destroy(desktop_plugin->priv->window);
+ if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1)
+ exit(-1);
+ create_xwindow(desktop_plugin->priv);
init_scene_theme(desktop_plugin);
}
/*******************************************************************************/
GPtrArray *child;
gint now = time(NULL);
gchar *str;
+ gchar *bgfile = NULL;
gint sizes1[4] = {57, 76, 43, 50},
n, j;
scene->actors = NULL;
desktop_plugin->priv->scene = scene;
- actor = init_object(desktop_plugin, "background", "bg.png",
+ bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
+ actor = init_object(desktop_plugin, "original", bgfile,
0, 0, 0, 800, 480,
TRUE, TRUE, 100, 255,
NULL, NULL, NULL);
/*******************************************************************************/
void
init_scene_External(AWallpaperPlugin *desktop_plugin){
- //fprintf(stderr,"init_scene_Xsnow\n");
+
char* child_argv[2048];
char *run_string = NULL;
+ gchar *exec_path = NULL,
+ *window_id = NULL,
+ *window_name = NULL,
+ *view = NULL,
+ *gtk_socket_id = NULL,
+ *strwin = NULL,
+ *strsocket = NULL,
+ *addedstring = NULL,
+ *theme_string_parametr1 = NULL,
+ *straddedstring = NULL,
+ *strview = NULL;
+ gint i;
+ Window id_xwindow;
if (!desktop_plugin->priv->visible)
return;
- run_string = g_strdup_printf("%s -window-id %d", desktop_plugin->priv->exec_path,
- GDK_WINDOW_XID(desktop_plugin->priv->window->window));
+ exec_path = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "exec_path"));
+ window_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_id"));
+ view = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "view"));
+ window_name = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_name"));
+ gtk_socket_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "gtk_socket_id"));
+ addedstring = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "added_string"));
+ if (!exec_path)
+ return;
+ if (window_id){
+ strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window));
+ }else
+ strwin = "";
+ if (gtk_socket_id){
+ strsocket = g_strdup_printf(" %s %i", gtk_socket_id, (int)gtk_socket_get_id (GTK_SOCKET (desktop_plugin->priv->video_socket)));
+ }else
+ strsocket = "";
+
+ if (view){
+ strview = g_strdup_printf(" %s %i", view, desktop_plugin->priv->view);
+ }else
+ strview = "";
+
+ if (addedstring){
+ straddedstring = g_strdup_printf(" %s", addedstring);
+ }else
+ straddedstring = "";
+
+ if (desktop_plugin->priv->theme_string_parametr1){
+ theme_string_parametr1 = g_strdup_printf(" %s", desktop_plugin->priv->theme_string_parametr1);
+ }else
+ theme_string_parametr1 = "";
+
+ run_string = g_strdup_printf("%s%s%s%s%s%s", exec_path, strwin, strview, strsocket, straddedstring, theme_string_parametr1);
+ fprintf(stderr, "runs string = %s\n", run_string);
parsestring(run_string, child_argv);
desktop_plugin->priv->running = TRUE;
desktop_plugin->priv->podpid = fork();
if (desktop_plugin->priv->podpid == 0){
- execvp(child_argv[0], child_argv);
+ execvp(child_argv[0], child_argv);
fprintf(stderr,"Problem with new podprocess");
}
g_free(run_string);
+
+ fprintf(stderr, "window name = %s\n", window_name);
+ if (window_name){
+ /* Do 10 trying to search of window */
+ for (i=0; i<10; i++){
+ sleep(1);
+ id_xwindow = Window_With_Name(GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ RootWindow( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window), XDefaultScreen( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window))),
+ window_name);
+ fprintf(stderr,"name %s %i %i\n", window_name, id_xwindow, i);
+ if (id_xwindow>0){
+ if (desktop_plugin->priv->one_in_all_view)
+ set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ id_xwindow, -1);
+ else
+ set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ id_xwindow, desktop_plugin->priv->view);
+ /* gtk_widget_destroy(desktop_plugin->priv->window); */
+ break;
+ }
+ }
+ }
}
/*******************************************************************************/
gboolean
}
file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
+#if 0
+ /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
+ /* Set Mute */
+ if (!desktop_plugin->priv->theme_bool_parametr1)
+ g_object_set (G_OBJECT (bin), "mute", TRUE, NULL );
+#endif
g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
if (GST_IS_X_OVERLAY (videosink))