diff --git a/src/plugin.c b/src/plugin.c index 3d9bf88..e26dc6a 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -391,17 +391,18 @@ plugin_stream_as_file (NPP instance, NPStream *stream, const char *filename) static NPError plugin_set_window (NPP instance, NPWindow *window) { if (instance == NULL || !SWFMOZ_IS_PLAYER (instance->pdata)) return NPERR_INVALID_INSTANCE_ERROR; if (window) { plugin_x11_setup_windowed (instance->pdata, (Window) window->window, - window->x, window->y, window->width, window->height); + window->x, window->y, window->width, window->height, + ((NPSetWindowCallbackStruct *)window->ws_info)->visual); } else { plugin_x11_teardown (instance->pdata); } return NPERR_NO_ERROR; } static int16 plugin_handle_event (NPP instance, void *eventp) diff --git a/src/plugin_x11.c b/src/plugin_x11.c index 22775e1..2f6b3f5 100644 --- a/src/plugin_x11.c +++ b/src/plugin_x11.c @@ -46,17 +46,17 @@ plugin_x11_handle_event (SwfmozPlayer *mozplay, XEvent *event) } break; case GraphicsExpose: if (mozplay->windowless && mozplay->target) { XGraphicsExposeEvent *expose = (XGraphicsExposeEvent *) event; GdkRectangle rect = { expose->x, expose->y, expose->width, expose->height }; GdkRegion *region = gdk_region_rectangle (&rect); cairo_surface_t *surface = cairo_xlib_surface_create (expose->display, - expose->drawable, GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (mozplay->target)), + expose->drawable, mozplay->target_visual, expose->x + expose->width, expose->y + expose->height); cairo_t *cr = cairo_create (surface); swfmoz_player_render (mozplay, cr, region); cairo_destroy (cr); cairo_surface_destroy (surface); gdk_region_destroy (region); } break; @@ -124,17 +124,17 @@ plugin_x11_handle_event (SwfmozPlayer *mozplay, XEvent *event) } break; } case ConfigureNotify: { XConfigureEvent *conf = (XConfigureEvent *) event; if (!mozplay->windowless) - swfmoz_player_set_target (mozplay, mozplay->target, 0, 0, conf->width, conf->height); + swfmoz_player_set_target (mozplay, mozplay->target, 0, 0, conf->width, conf->height, mozplay->target_visual); break; } default: g_printerr ("unhandled event %d\n", event->type); break; } } @@ -142,29 +142,29 @@ static GdkFilterReturn plugin_x11_filter_event (GdkXEvent *gdkxevent, GdkEvent *unused, gpointer playerp) { plugin_x11_handle_event (playerp, gdkxevent); return GDK_FILTER_REMOVE; } void plugin_x11_setup_windowed (SwfmozPlayer *player, Window xwindow, - int x, int y, int width, int height) + int x, int y, int width, int height, Visual *visual) { if (player->windowless) { if (player->target == NULL) { GdkWindow *window; if (!plugin_get_value (player->instance, NPNVnetscapeWindow, &xwindow) || (window = gdk_window_foreign_new (xwindow)) == NULL) { g_printerr ("cannot set window given for setup (id %lu)\n", xwindow); return; } - swfmoz_player_set_target (player, window, x, y, width, height); + swfmoz_player_set_target (player, window, x, y, width, height, visual); } else { - swfmoz_player_set_target (player, player->target, x, y, width, height); + swfmoz_player_set_target (player, player->target, x, y, width, height, visual); } } else { if (player->target == NULL) { GdkWindowAttr attr; GdkWindow *parent, *window; parent = gdk_window_foreign_new (xwindow); if (parent == NULL) { @@ -181,23 +181,23 @@ plugin_x11_setup_windowed (SwfmozPlayer *player, Window xwindow, attr.y = 0; attr.width = width; attr.height = height; attr.window_type = GDK_WINDOW_CHILD; attr.wclass = GDK_INPUT_OUTPUT; window = gdk_window_new (parent, &attr, GDK_WA_X | GDK_WA_Y); gdk_window_add_filter (window, plugin_x11_filter_event, player); gdk_window_show (window); - swfmoz_player_set_target (player, window, 0, 0, width, height); + swfmoz_player_set_target (player, window, 0, 0, width, height, visual); } else { gdk_window_move_resize (player->target, 0, 0, width, height); } } } void plugin_x11_teardown (SwfmozPlayer *player) { if (player->target) { gdk_window_remove_filter (player->target, plugin_x11_filter_event, player); } - swfmoz_player_set_target (player, NULL, 0, 0, 0, 0); + swfmoz_player_set_target (player, NULL, 0, 0, 0, 0, NULL); } diff --git a/src/plugin_x11.h b/src/plugin_x11.h index b07c677..dfd39e0 100644 --- a/src/plugin_x11.h +++ b/src/plugin_x11.h @@ -27,15 +27,16 @@ G_BEGIN_DECLS void plugin_x11_setup_windowed (SwfmozPlayer * player, Window window, int x, int y, int width, - int height); + int height, + Visual * visual); void plugin_x11_teardown (SwfmozPlayer * player); void plugin_x11_handle_event (SwfmozPlayer * player, XEvent * event); G_END_DECLS #endif diff --git a/src/swfmoz_player.c b/src/swfmoz_player.c index 806ead7..bb18cfc 100644 --- a/src/swfmoz_player.c +++ b/src/swfmoz_player.c @@ -640,17 +640,17 @@ swfmoz_player_add_loader (SwfmozPlayer *player, SwfmozLoader *loader) GTK_LIST_STORE (player->loaders)); gtk_list_store_append (GTK_LIST_STORE (player->loaders), &iter); swfmoz_player_loaders_update (GTK_LIST_STORE (player->loaders), &iter, SWFDEC_LOADER (loader)); } void swfmoz_player_set_target (SwfmozPlayer *player, GdkWindow *target, - int x, int y, int width, int height) + int x, int y, int width, int height, Visual *visual) { g_return_if_fail (SWFMOZ_IS_PLAYER (player)); g_return_if_fail (target == NULL || GDK_IS_WINDOW (target)); if (target != player->target) { if (player->target) { g_object_unref (player->target); } @@ -675,16 +675,17 @@ swfmoz_player_set_target (SwfmozPlayer *player, GdkWindow *target, swfdec_gtk_player_set_missing_plugins_window (SWFDEC_GTK_PLAYER (player), NULL); } } player->target_rect.x = x; player->target_rect.y = y; player->target_rect.width = width; player->target_rect.height = height; + player->target_visual = visual; swfdec_player_set_size (SWFDEC_PLAYER (player), width, height); } static void swfdec_gtk_player_draw_pause (cairo_t *cr) { cairo_pattern_t *pattern; #if 0 diff --git a/src/swfmoz_player.h b/src/swfmoz_player.h index d9967f1..1641df5 100644 --- a/src/swfmoz_player.h +++ b/src/swfmoz_player.h @@ -54,16 +54,17 @@ struct _SwfmozPlayer { GMainContext * context; /* the main context run by the thread */ NPStream * initial; /* loader that spawned this player or NULL if none yet */ gboolean windowless; /* TRUE if player communicates with the windowing system via the browser */ gboolean opaque; /* TRUE if the player should not allow translucency */ GdkWindow * target; /* what we draw to */ GdkRectangle target_rect; /* area in target that this plugin occupies */ + Visual * target_visual; /* visual for drawing */ GSource * repaint_source; /* set when repaint is necessary */ GdkRegion * repaint; /* area to repaint or NULL if none */ /* Gtk stuff */ guint no_release; /* for disabling release event when closing right-click menu */ GtkMenu * menu; /* right-click menu */ GtkTreeModel * loaders; /* loaders used in this players */ @@ -86,17 +87,18 @@ gboolean swfmoz_player_set_initial_stream (SwfmozPlayer * player, NPStream * stream); void swfmoz_player_add_loader (SwfmozPlayer * player, SwfmozLoader * loader); void swfmoz_player_set_target (SwfmozPlayer * player, GdkWindow * target, int x, int y, int width, - int height); + int height, + Visual * visual); void swfmoz_player_set_allow_popups (SwfmozPlayer * player, gboolean allow); void swfmoz_player_render (SwfmozPlayer * player, cairo_t * cr, GdkRegion * region); gboolean swfmoz_player_mouse_press (SwfmozPlayer * player, int x, int y,