summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2008-09-05 19:16:16 +0200
committerBenjamin Otte <otte@gnome.org>2008-09-05 19:16:16 +0200
commit66fa8293b527079c00d486f23e696ac2b1777d59 (patch)
tree106ba3998b5f1760fb5b618cc335ed7d5383f224
parentebb39c2e645fcee3305a9405ea2a0e082ec80d00 (diff)
make query_size work properly, so that (de)maximizing works nicely
-rw-r--r--src/plugin.h6
-rw-r--r--src/plugin_x11.c17
-rw-r--r--src/plugin_x11.h20
-rw-r--r--src/swfmoz_player.c29
4 files changed, 61 insertions, 11 deletions
diff --git a/src/plugin.h b/src/plugin.h
index 963cc3b..a6008bb 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -20,7 +20,7 @@
#ifndef _SWFMOZ_PLUGIN_H_
#define _SWFMOZ_PLUGIN_H_
-#include <glib.h>
+#include <gdk/gdk.h>
#include <npapi.h>
G_BEGIN_DECLS
@@ -59,5 +59,9 @@ gboolean plugin_push_allow_popups (NPP instance,
gboolean allow);
gboolean plugin_pop_allow_popups (NPP instance);
+/* in plugin_x11.h */
+GdkWindow * plugin_get_window (NPP instance);
+
+
G_END_DECLS
#endif
diff --git a/src/plugin_x11.c b/src/plugin_x11.c
index 2f6b3f5..cfe1f7f 100644
--- a/src/plugin_x11.c
+++ b/src/plugin_x11.c
@@ -201,3 +201,20 @@ plugin_x11_teardown (SwfmozPlayer *player)
}
swfmoz_player_set_target (player, NULL, 0, 0, 0, 0, NULL);
}
+
+GdkWindow *
+plugin_get_window (NPP instance)
+{
+ Window xid;
+ GdkWindow *window;
+
+ if (!plugin_get_value (instance, NPNVnetscapeWindow, &xid))
+ return NULL;
+
+ window = gdk_window_lookup (xid);
+ if (window)
+ return window;
+
+ return gdk_window_foreign_new (xid);
+}
+
diff --git a/src/plugin_x11.h b/src/plugin_x11.h
index dfd39e0..941b85a 100644
--- a/src/plugin_x11.h
+++ b/src/plugin_x11.h
@@ -26,17 +26,17 @@
G_BEGIN_DECLS
+void plugin_x11_setup_windowed (SwfmozPlayer * player,
+ Window window,
+ int x,
+ int y,
+ int width,
+ int height,
+ Visual * visual);
+void plugin_x11_teardown (SwfmozPlayer * player);
+void plugin_x11_handle_event (SwfmozPlayer * player,
+ XEvent * event);
-void plugin_x11_setup_windowed (SwfmozPlayer * player,
- Window window,
- int x,
- int y,
- int width,
- 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 1040431..97abb89 100644
--- a/src/swfmoz_player.c
+++ b/src/swfmoz_player.c
@@ -458,6 +458,33 @@ swfmoz_player_notify (SwfmozPlayer *player, GParamSpec *pspec, gpointer unused)
}
}
+static gboolean
+swfmoz_player_query_size (SwfmozPlayer *player, gboolean fullscreen,
+ int *width, int *height)
+{
+ if (fullscreen) {
+ GdkWindow *window = plugin_get_window (player->instance);
+ GdkScreen *screen;
+ GdkRectangle rect;
+ int monitor;
+
+ if (window == NULL)
+ return FALSE;
+ screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
+ monitor = gdk_screen_get_monitor_at_window (screen, window);
+ gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+ *width = rect.width;
+ *height = rect.height;
+ } else if (player->target == NULL) {
+ *width = -1;
+ *height = -1;
+ } else {
+ *width = player->target_rect.width;
+ *height = player->target_rect.height;
+ }
+ return TRUE;
+}
+
static void
swfmoz_player_get_property (GObject *object, guint param_id, GValue *value,
GParamSpec * pspec)
@@ -519,6 +546,7 @@ swfmoz_player_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (player, swfmoz_player_redraw, NULL);
g_signal_handlers_disconnect_by_func (player, swfmoz_player_launch, NULL);
g_signal_handlers_disconnect_by_func (player, swfmoz_player_notify, NULL);
+ g_signal_handlers_disconnect_by_func (player, swfmoz_player_query_size, NULL);
if (player->target) {
g_object_unref (player->target);
player->target = NULL;
@@ -555,6 +583,7 @@ swfmoz_player_init (SwfmozPlayer *player)
g_signal_connect (player, "invalidate", G_CALLBACK (swfmoz_player_redraw), NULL);
g_signal_connect (player, "launch", G_CALLBACK (swfmoz_player_launch), NULL);
g_signal_connect (player, "notify", G_CALLBACK (swfmoz_player_notify), NULL);
+ g_signal_connect (player, "query-size", G_CALLBACK (swfmoz_player_query_size), NULL);
player->context = g_main_context_default ();
player->loaders = GTK_TREE_MODEL (gtk_list_store_new (SWFMOZ_LOADER_N_COLUMNS,