44 static PRLogModuleInfo* gGStreamerPlatformGDK =
45 PR_NewLogModule(
"sbGStreamerPlatformGDK");
48 if (gGStreamerPlatformGDK) \
49 PR_LOG(gGStreamerPlatformGDK, PR_LOG_WARNING, args)
52 if (gGStreamerPlatformGDK) \
53 PR_LOG(gGStreamerPlatformGDK, PR_LOG_DEBUG, args)
65 GDKPlatformInterface::gdk_event_filter(GdkXEvent *gdk_xevent,
69 XEvent *xevent = (XEvent *)gdk_xevent;
71 switch (xevent->type) {
83 return GDK_FILTER_CONTINUE;
90 mFullscreenWindow(NULL)
97 NS_ASSERTION (mFullscreenWindow == NULL,
"Fullscreen window is non-null");
99 GdkScreen *screen = NULL;
100 gint screenWidth, screenHeight;
102 XWindowAttributes xattrs;
104 attributes.window_type = GDK_WINDOW_TOPLEVEL;
107 attributes.width = 0;
108 attributes.height = 0;
109 attributes.wclass = GDK_INPUT_OUTPUT;
110 attributes.event_mask = 0;
114 mFullscreenWindow = gdk_window_new(NULL, &attributes, GDK_WA_X | GDK_WA_Y);
115 gdk_window_show(mFullscreenWindow);
116 gdk_window_reparent(mWindow, mFullscreenWindow, 0, 0);
117 gdk_window_fullscreen(mFullscreenWindow);
121 XGetWindowAttributes(GDK_DISPLAY (), GDK_WINDOW_XWINDOW (mWindow), &xattrs);
122 XSelectInput(GDK_DISPLAY (), GDK_WINDOW_XWINDOW (mWindow),
123 xattrs.your_event_mask | ButtonPressMask);
124 gdk_window_add_filter(mWindow, gdk_event_filter,
this);
126 XGetWindowAttributes(GDK_DISPLAY (), GDK_WINDOW_XWINDOW (mFullscreenWindow),
128 XSelectInput(GDK_DISPLAY (), GDK_WINDOW_XWINDOW (mFullscreenWindow),
129 xattrs.your_event_mask | ButtonPressMask);
130 gdk_window_add_filter(mFullscreenWindow, gdk_event_filter,
this);
134 screen = gdk_screen_get_default();
136 screenWidth = gdk_screen_get_width(screen);
137 screenHeight = gdk_screen_get_height(screen);
143 SetInvisibleCursor();
151 NS_ASSERTION (mFullscreenWindow,
"Fullscreen window is null");
153 gdk_window_remove_filter(mWindow, gdk_event_filter,
this);
154 gdk_window_remove_filter(mFullscreenWindow, gdk_event_filter,
this);
156 gdk_window_unfullscreen(mWindow);
157 gdk_window_reparent(mWindow, mParentWindow, 0, 0);
158 gdk_window_destroy(mFullscreenWindow);
159 mFullscreenWindow = NULL;
165 GDKPlatformInterface::SetInvisibleCursor()
168 GdkPixmap* pixmap = gdk_bitmap_create_from_data(NULL, (gchar*)&data, 1, 1);
170 GdkColor color = { 0, 0, 0, 0 };
171 GdkCursor* cursor = gdk_cursor_new_from_pixmap(pixmap,
172 pixmap, &color, &color, 0, 0);
174 gdk_pixmap_unref(pixmap);
176 gdk_window_set_cursor(mWindow, cursor);
177 if (mFullscreenWindow)
178 gdk_window_set_cursor(mFullscreenWindow, cursor);
180 gdk_cursor_unref(cursor);
185 GDKPlatformInterface::SetDefaultCursor()
187 gdk_window_set_cursor(mWindow, NULL);
188 if (mFullscreenWindow)
189 gdk_window_set_cursor(mFullscreenWindow, NULL);
196 LOG((
"Moving video window to %d,%d, size %d,%d", x, y, width, height));
197 gdk_window_move_resize(mWindow, x, y, width, height);
213 mVideoSink = gst_element_factory_make(
"gconfvideosink",
"video-sink");
216 mVideoSink = gst_element_factory_make(
"autovideosink",
"video-sink");
238 mAudioSink = gst_element_factory_make(
"gconfaudiosink",
"audio-sink");
243 g_object_set (G_OBJECT (
mAudioSink),
"profile", 1, NULL);
249 mAudioSink = gst_element_factory_make(
"autoaudiosink",
"audio-sink");
264 NS_ENSURE_SUCCESS(rv, rv);
267 mParentWindow = GDK_WINDOW(aWidget->GetNativeData(NS_NATIVE_WIDGET));
268 NS_ENSURE_TRUE(mParentWindow != NULL, NS_ERROR_FAILURE);
273 attributes.window_type = GDK_WINDOW_CHILD;
276 attributes.width = 0;
277 attributes.height = 0;
278 attributes.wclass = GDK_INPUT_OUTPUT;
279 attributes.event_mask = GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK |
280 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK;
282 mWindow = gdk_window_new(mParentWindow, &attributes, GDK_WA_X | GDK_WA_Y);
283 NS_ENSURE_TRUE(mParentWindow != NULL, NS_ERROR_FAILURE);
285 gdk_window_show(mWindow);
291 mWindowXID = gdk_x11_drawable_get_xid (mWindow);
295 gdk_window_hide(mWindow);
296 gdk_window_reparent(mWindow, NULL, 0, 0);
297 gdk_window_destroy(mWindow);
301 mParentWindow = nsnull;
315 nsCOMPtr<nsIThread> mainThread;
316 rv = NS_GetMainThread(getter_AddRefs(mainThread));
317 NS_ENSURE_SUCCESS(rv, );
319 nsCOMPtr<nsIRunnable> runnable =
324 rv = mainThread->Dispatch(runnable, NS_DISPATCH_SYNC);
325 NS_ENSURE_SUCCESS(rv, );
329 gst_x_overlay_set_xwindow_id(aXOverlay, mWindowXID);
331 LOG((
"Set xoverlay %d to windowid %x\n", aXOverlay, mWindowXID));