[vlc-commits] GTK: respect bgcolor attribute

Cheng Sun git at videolan.org
Thu Jan 5 03:03:06 CET 2012


npapi-vlc | branch: master | Cheng Sun <chengsun9 at gmail.com> | Tue Jan  3 21:07:52 2012 +0000| [c752b17037e26a99c4c9acf9795c6b984ed1ce77] | committer: Jean-Baptiste Kempf

GTK: respect bgcolor attribute

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=c752b17037e26a99c4c9acf9795c6b984ed1ce77
---

 npapi/vlcplugin_gtk.cpp |   22 ++++++++++++++--------
 npapi/vlcplugin_gtk.h   |    1 +
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/npapi/vlcplugin_gtk.cpp b/npapi/vlcplugin_gtk.cpp
index 9fdfd37..c781468 100644
--- a/npapi/vlcplugin_gtk.cpp
+++ b/npapi/vlcplugin_gtk.cpp
@@ -343,17 +343,17 @@ bool VlcPluginGtk::create_windows()
     display = ( (NPSetWindowCallbackStruct *) npwindow.ws_info )->display;
 
     Window socket = (Window) npwindow.window;
-    GdkColor color_black;
-    gdk_color_parse("black", &color_black);
+    GdkColor color_bg;
+    gdk_color_parse(psz_bgcolor, &color_bg);
 
     parent = gtk_plug_new(socket);
-    gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_black);
+    gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_bg);
 
     parent_vbox = gtk_vbox_new(false, 0);
     gtk_container_add(GTK_CONTAINER(parent), parent_vbox);
 
     video_container = gtk_drawing_area_new();
-    gtk_widget_modify_bg(video_container, GTK_STATE_NORMAL, &color_black);
+    gtk_widget_modify_bg(video_container, GTK_STATE_NORMAL, &color_bg);
     gtk_widget_add_events(video_container,
             GDK_BUTTON_PRESS_MASK
           | GDK_BUTTON_RELEASE_MASK);
@@ -366,7 +366,7 @@ bool VlcPluginGtk::create_windows()
 
     /* fullscreen top-level */
     fullscreen_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_widget_modify_bg(fullscreen_win, GTK_STATE_NORMAL, &color_black);
+    gtk_widget_modify_bg(fullscreen_win, GTK_STATE_NORMAL, &color_bg);
     gtk_window_set_decorated(GTK_WINDOW(fullscreen_win), false);
     g_signal_connect(G_OBJECT(fullscreen_win), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this);
     g_signal_connect(G_OBJECT(fullscreen_win), "show", G_CALLBACK(fullscreen_win_visibility_handler), this);
@@ -377,10 +377,14 @@ bool VlcPluginGtk::create_windows()
      * GTK+ is incapable of reparenting without changing xid
      */
     Display *display = get_display();
-    int blackColor = BlackPixel(display, DefaultScreen(display));
+    Colormap colormap = DefaultColormap(display, DefaultScreen(display));
+    bg_color.red   = color_bg.red;
+    bg_color.green = color_bg.green;
+    bg_color.blue  = color_bg.blue;
+    XAllocColor(display, colormap, &bg_color);
     video_xwindow = XCreateSimpleWindow(display, get_xid(video_container), 0, 0,
                    1, 1,
-                   0, blackColor, blackColor);
+                   0, bg_color.pixel, bg_color.pixel);
 
     /* connect video_container resizes to video_xwindow */
     video_container_size_handler_id = g_signal_connect(
@@ -436,5 +440,7 @@ bool VlcPluginGtk::resize_windows()
 
 bool VlcPluginGtk::destroy_windows()
 {
-    /* TODO */
+    Display *display = get_display();
+    Colormap colormap = DefaultColormap(display, DefaultScreen(display));
+    XFreeColors(display, colormap, &bg_color.pixel, 1, 0);
 }
diff --git a/npapi/vlcplugin_gtk.h b/npapi/vlcplugin_gtk.h
index 6b5202c..4e7fa83 100644
--- a/npapi/vlcplugin_gtk.h
+++ b/npapi/vlcplugin_gtk.h
@@ -66,6 +66,7 @@ private:
 
     Display *display;
     Window video_xwindow;
+    XColor bg_color;
     bool is_fullscreen, is_toolbar_visible;
 };
 



More information about the vlc-commits mailing list