initial import
[vuplus_webkit] / Source / WebCore / platform / graphics / gstreamer / PlatformVideoWindowGtk.cpp
1 /*
2  * Copyright (C) 2010 Igalia S.L
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include "config.h"
21 #include "PlatformVideoWindow.h"
22 #if ENABLE(VIDEO) && USE(GSTREAMER)
23
24 #include <gtk/gtk.h>
25
26 #ifdef GDK_WINDOWING_X11
27 #include <gdk/gdkx.h> // for GDK_WINDOW_XID
28 #endif
29
30 using namespace WebCore;
31
32 PlatformVideoWindow::PlatformVideoWindow()
33 {
34     m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
35     gtk_widget_set_events(m_window, GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_FOCUS_CHANGE_MASK);
36
37     m_videoWindow = gtk_drawing_area_new();
38     gtk_widget_set_double_buffered(m_videoWindow, FALSE);
39     gtk_container_add(GTK_CONTAINER(m_window), m_videoWindow);
40
41     gtk_widget_realize(m_window);
42
43 #ifdef GDK_WINDOWING_X11
44     m_videoWindowId = GDK_WINDOW_XID(gtk_widget_get_window(m_window));
45 #endif
46
47 }
48
49 PlatformVideoWindow::~PlatformVideoWindow()
50 {
51     if (m_videoWindow && m_window) {
52         gtk_container_remove(GTK_CONTAINER(m_window), m_videoWindow);
53         gtk_widget_destroy(m_videoWindow);
54         m_videoWindow = 0;
55     }
56
57     if (m_window) {
58         gtk_widget_destroy(m_window);
59         m_window = 0;
60     }
61
62     m_videoWindowId = 0;
63 }
64
65 void PlatformVideoWindow::prepareForOverlay(GstMessage*)
66 {
67 }
68 #endif // USE(GSTREAMER)
69