#include "soundeffects.h"
#include "vroot.h"
+
+/* For Maemo */
+
+#include <libosso.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
#ifdef DARWIN
#include "getopt.h"
#else
#define ARG_COMICS 52
#define ARG_COMICS_DIR 53
#define ARG_COMICS_DELAY 54
+#define ARG_VIEW 55
#define DEPTH 24
static SDL_Surface *screen=NULL, *screen_image, *background, **thisfish;
static SDL_Rect *fish_dest, *fish_src, *clean_dest;
static int curr_dest, clean_count, no_sdl_quit = 0, comics_delay = 50;
-int window_id = -1, fullscreen = 0;
+int window_id = -1, fullscreen = 1;
+int view = 1;
static unsigned char *original_bg;
static AquariumData ad;
-
+/* For Maemo */
+static osso_context_t *osso;
+DBusConnection *dbus_conn_session;
+static int pause_in_view = 0;
void screensaver_draw_image(int x, int y, int idx, int rev, SA_Image *image)
{
{
GdkEvent *event;
int counter = 0;
+ DBusMessage* msg;
while(1){
while(gdk_events_pending()){
gdk_draw_rgb_image(window, gc, ad.xmin, ad.ymin, ad.xmax, ad.ymax,
GDK_RGB_DITHER_NONE, ad.rgb, ad.xmax * 3);
gdk_flush();
+
/* 25 fps */
usleep(1000000/25);
+
+ if (pause_in_view == 0)
+ /* non blocking read of the next available message */
+ dbus_connection_read_write(dbus_conn_session, 0);
+ else
+ /* blocking read of the next available message */
+ dbus_connection_read_write(dbus_conn_session, 20000);
+
+ msg = dbus_connection_pop_message(dbus_conn_session);
+
+ if (NULL == msg){
+ continue;
+ }
+ if ( dbus_message_get_member (msg) &&
+ !strncmp( "play_livebg_on_view", dbus_message_get_member (msg),19)){
+ pause_in_view = 0;
+ }
+ if ( dbus_message_get_member (msg) &&
+ !strncmp( "pause_livebg_on_view", dbus_message_get_member (msg),19)){
+ pause_in_view = 1;
+ }
+
}
}
SDL_UpdateRect(screen,0,0,0,0);
}
+void
+initialize_dbus(void){
+ gchar *filter_string;
+ DBusError error;
+
+ dbus_error_init (&error);
+ /* Add D-BUS signal handler for 'status_changed' */
+ dbus_conn_session = (DBusConnection *) osso_get_dbus_connection(osso);
+ if (dbus_conn_session){
+ filter_string =
+ g_strdup_printf("interface='org.maemo.livewp', member='pause_livebg_on_view%i'", view);
+ dbus_bus_add_match(dbus_conn_session, filter_string, &error);
+ if (dbus_error_is_set(&error)){
+ fprintf(stderr,"dbus_bus_add_match failed: %s", error.message);
+ dbus_error_free(&error);
+ }
+ g_free(filter_string);
+ filter_string =
+ g_strdup_printf("interface='org.maemo.livewp', member='play_livebg_on_view%i'", view);
+ dbus_bus_add_match(dbus_conn_session, filter_string, &error);
+ if (dbus_error_is_set(&error)){
+ fprintf(stderr,"dbus_bus_add_match failed: %s", error.message);
+ dbus_error_free(&error);
+ }
+ g_free(filter_string);
+ }
+}
void screensaver_init()
int sdl_flags = SDL_DOUBLEBUF|SDL_HWSURFACE|SDL_ANYFORMAT;
screen_height = 480;
- screen_width = 640;
+ screen_width = 800;
+ osso = osso_initialize("org.maemo.sherman", "3.0", TRUE, NULL);
+ initialize_dbus();
+
if(window_id != -1){
display = XOpenDisplay(NULL);
XGetWindowAttributes(display, (Window)window_id, &win_attr);
Sound_settings *s, sound_settings = {0,TYPE_MP3, NULL};
Bubble_settings *bub, bubble_settings = {20};
- Bottom_settings *b, bottom_settings = {0,5,1,75,2};
- Background_settings *bg, background_settings = {NULL,NULL, 0,1,
+ Bottom_settings *b, bottom_settings = {1,5,1,75,3};
+ Background_settings *bg, background_settings = {NULL,NULL, 2,0,
(GaiColor){0, 100, 150, 0},
(GaiColor){10,120, 250, 0},
(GaiColor){0,0,0,0}};
- Fish_settings *f, fish_settings = {0, 0, 75, 0, 100, 0, 15, 0, 75, 75,
+ Fish_settings *f, fish_settings = {1, 1, 75, 0, 100, 1, 15, 0, 75, 75,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
struct option cmdline_options[] = {
{"sound", no_argument, NULL, ARG_SOUND},
{"root", no_argument, NULL, ARG_FULLSCREEN},
{"bubble", required_argument, NULL, ARG_BUBBLE},
{"desktop", no_argument, NULL, ARG_DESKTOP},
+ {"view", required_argument, NULL, ARG_VIEW},
{0,0,0,0}};
memcpy(b,&bottom_settings, sizeof(Bottom_settings));
memcpy(bub, &bubble_settings, sizeof(Bubble_settings));
memcpy(s, &sound_settings, sizeof(Sound_settings));
+fprintf(stderr, "1BG %i\n",bg->desktop);
while ((c =
getopt_long_only(argc, argv, "", cmdline_options, NULL)) != -1){
s->prg = g_strdup_printf(optarg);
break;
case ARG_WINDOW_ID:
- window_id = htoi(optarg);
+ window_id = atoi(optarg);
break;
case ARG_FULLSCREEN:
fullscreen = 1;
case ARG_BUBBLE:
bub->max_bubbles = atoi(optarg);
break;
+ case ARG_VIEW:
+ view = atoi(optarg);
+ break;
case ARG_DESKTOP:
bg->type = 0;
bg->desktop = 1;
}
+
int main(int argc, char **argv)
{
gdk_init(&argc, &argv);
screensaver_init_param(argc, argv);
screensaver_init(0);
- if(window_id==-1)
+ if(window_id==-1){
+ fprintf(stderr, "screensaver_main_sdl\n");
screensaver_main_sdl();
- else
+ }
+ else{
+ fprintf(stderr, "screensaver_main_GDK\n");
screensaver_main_gdk();
+ }
return 0;
}