banshee r3794 - in trunk/banshee: . src/Core/Banshee.Services src/Extensions/Banshee.NowPlaying src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying



Author: abock
Date: Sat Apr 19 01:26:30 2008
New Revision: 3794
URL: http://svn.gnome.org/viewvc/banshee?rev=3794&view=rev

Log:
2008-04-18  Aaron Bockover  <abock gnome org>

    This commit adds video rendering to the fullscreen window and fixes all
    of the GTK CRITICAL messages that could be seen when switching from the
    now playing source to something else

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs:
    Implemented a sweet widget reparenting hack to work around the windowing
    issues with GstXOverlay; when the video wiget is not to be displayed,
    it is reparented to the fullscreen window, which will be hidden; this
    also implements the rest of fullscreen support as far as video rendering
    is concerned (there are no fullscreen controls yet, but you can press
    escape to close the window)

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs:
    Hide and unfullscreen self instead of destroying

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs:
    Abstracted non GstXOverlay specific pieces of the video widget to make
    the code easier to maintain

    * src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs:
    Fixes with the internal windowing to better work with the reparenting
    hack outlined above



Added:
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
   trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp	Sat Apr 19 01:26:30 2008
@@ -145,6 +145,9 @@
     <File name="Banshee.MediaProfiles/Profile.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.MediaProfiles/ProfileConfiguration.cs" subtype="Code" buildaction="Compile" />
     <File name="Banshee.Hardware/IDeviceMediaCapabilities.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Collection.Database/CachedList.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.ServiceStack/BatchUserJob.cs" subtype="Code" buildaction="Compile" />
+    <File name="Banshee.Sources/IDiskUsageReporter.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying.mdp	Sat Apr 19 01:26:30 2008
@@ -15,6 +15,7 @@
     <File name="Resources/idle-logo.png" subtype="Code" buildaction="EmbedAsResource" />
     <File name="Banshee.NowPlaying/FullscreenWindow.cs" subtype="Code" buildaction="Compile" />
     <File name="Resources/ActiveSourceUI.xml" subtype="Code" buildaction="EmbedAsResource" />
+    <File name="Banshee.NowPlaying/XOverlayVideoDisplay.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/FullscreenWindow.cs	Sat Apr 19 01:26:30 2008
@@ -30,13 +30,12 @@
 
 using System;
 using Gtk;
-using Mono.Unix;
 
 namespace Banshee.NowPlaying
 {
     public class FullscreenWindow : Window
     {
-        public FullscreenWindow (string title, Window parent) : base (title)
+        public FullscreenWindow (Window parent) : base ("Banshee")
         {
             Gdk.Screen screen = Screen;
             int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
@@ -47,16 +46,12 @@
             Decorated = false;
         }
         
-        protected override void OnDestroyed ()
-        {
-            base.OnDestroyed ();
-        }
-        
         protected override bool OnKeyPressEvent (Gdk.EventKey evnt)
         {
             switch (evnt.Key) {
                 case Gdk.Key.Escape: 
-                    Destroy ();
+                    Unfullscreen ();
+                    Hide ();
                     return true;
             }
             

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/NowPlayingInterface.cs	Sat Apr 19 01:26:30 2008
@@ -43,6 +43,7 @@
         private NowPlayingSource source;
         private VideoDisplay video_display;
         private Hyena.Widgets.RoundedFrame frame;
+        private Gtk.Window video_window;
 
         public VideoDisplay VideoDisplay {
             get { return video_display; }
@@ -50,21 +51,58 @@
         
         public NowPlayingInterface ()
         {
-            video_display = new VideoDisplay ();
-            video_display.Show ();
+            GtkElementsService service = ServiceManager.Get<GtkElementsService> ();
+            
+            video_display = new XOverlayVideoDisplay ();
+            
+            // This is my really sweet hack - it's where the video widget
+            // is sent when the source is not active. This keeps the video
+            // widget from being completely destroyed, causing problems with
+            // its internal windowing and GstXOverlay. It's also conveniently
+            // the window that is used to do fullscreen video. Sweeeeeeeeeet. 
+            video_window = new FullscreenWindow (service.PrimaryWindow);
+            video_window.Hidden += OnFullscreenWindowHidden;
+            video_window.Realize ();
+            video_window.Add (video_display);
             
             frame = new Hyena.Widgets.RoundedFrame ();
             frame.SetFillColor (new Cairo.Color (0, 0, 0));
             frame.DrawBorder = false;
-            frame.Add (video_display);
             frame.Show ();
             
             PackStart (frame, true, true, 0);
         }
         
+        private void MoveVideoExternal (bool hidden)
+        {
+            if (video_display.Parent != video_window) {
+                video_display.Visible = !hidden;
+                video_display.Reparent (video_window);
+            }
+        }
+        
+        private void MoveVideoInternal ()
+        {
+            if (video_display.Parent != frame) {
+                video_display.Reparent (frame);
+                video_display.Show ();
+            }
+        }
+        
+        protected override void OnRealized ()
+        {
+            base.OnRealized ();
+            MoveVideoInternal ();
+        }
+        
+        protected override void OnUnrealized ()
+        {
+            MoveVideoExternal (false);
+            base.OnUnrealized ();
+        }
+
 #region Video Fullscreen Override
 
-        private Gtk.Window fullscreen_window;
         private ViewActions.FullscreenHandler previous_fullscreen_handler;
 
         private void DisableFullscreenAction ()
@@ -98,29 +136,20 @@
             service.ViewActions.Fullscreen = previous_fullscreen_handler;
         }
         
-        private void OnFullscreenWindowDestroyed (object o, EventArgs args)
+        private void OnFullscreenWindowHidden (object o, EventArgs args)
         {
-            if (fullscreen_window != null) {
-                fullscreen_window.Destroyed -= OnFullscreenWindowDestroyed;
-                fullscreen_window = null;
-            }
-            
+            MoveVideoInternal ();
             DisableFullscreenAction ();
         }
-        
+
         private void FullscreenHandler (bool fullscreen)
         {
             if (fullscreen) {
-                if (fullscreen_window == null) {
-                    GtkElementsService service = ServiceManager.Get<GtkElementsService> (); 
-                    fullscreen_window = new FullscreenWindow (service.PrimaryWindow.Title, service.PrimaryWindow);
-                    fullscreen_window.Destroyed += OnFullscreenWindowDestroyed;
-                }
-                
-                fullscreen_window.ShowAll ();
-                fullscreen_window.Fullscreen ();
-            } else if (fullscreen_window != null) {
-                fullscreen_window.Destroy ();
+                MoveVideoExternal (true);
+                video_window.ShowAll ();
+                video_window.Fullscreen ();
+            } else {
+                video_window.Hide ();
             }
         }
         

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/VideoDisplay.cs	Sat Apr 19 01:26:30 2008
@@ -33,107 +33,37 @@
 using Banshee.ServiceStack;
 using Banshee.Collection;
 
-using Banshee.Gui;
-
 namespace Banshee.NowPlaying
 {   
-    public class VideoDisplay : Gtk.EventBox
+    public abstract class VideoDisplay : Gtk.Widget
     {
         private Gdk.Pixbuf idle_pixbuf;
         private bool render_idle = true;
 
-        private bool fullscreen = false;
-        public bool FullScreen {
-            get { return fullscreen; }
-            set { fullscreen = value; }
-        }
-
-        private Gdk.Window video_window;
-        public Gdk.Window VideoWindow {
-            get { return video_window; }
-        }
-    
         public VideoDisplay ()
         {
-            CreateVideoWindow ();
             ServiceManager.PlayerEngine.EventChanged += OnPlayerEngineEventChanged;
             ToggleIdleVisibility ();
         }
-        
-        private void CreateVideoWindow ()
-        {
-            Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
-            attributes.WindowType = Gdk.WindowType.Child;
-            attributes.Visual = Visual;
-            attributes.Wclass = Gdk.WindowClass.InputOutput;
-            attributes.Colormap = Colormap;
-            attributes.EventMask = (int)(
-                Gdk.EventMask.VisibilityNotifyMask |
-                Gdk.EventMask.ExposureMask);
-            
-            Gdk.WindowAttributesType attributes_mask = 
-                Gdk.WindowAttributesType.X | 
-                Gdk.WindowAttributesType.Y | 
-                Gdk.WindowAttributesType.Visual | 
-                Gdk.WindowAttributesType.Colormap;
-                
-            video_window = new Gdk.Window (null, attributes, attributes_mask);
-            video_window.UserData = Handle;
-                        
-            video_window.SetBackPixmap (null, false);
-            
-            ServiceManager.PlayerEngine.VideoWindow = video_window.Handle;
-        }
-        
-        protected override void OnRealized ()
-        {
-            base.OnRealized ();
-            video_window.Reparent (Parent.GdkWindow, Allocation.X, Allocation.Y);
-        }
-        
-        protected override void OnUnrealized ()
-        {
-            base.OnUnrealized ();
-            video_window.Reparent (null, 0, 0);
-        }
 
-        protected override void OnMapped ()
-        {
-            base.OnMapped ();
-            video_window.Show ();
-        }
+        protected abstract Gdk.Window RenderWindow { get; }
         
-        protected override void OnUnmapped ()
-        {
-            video_window.Hide ();
-            base.OnUnmapped ();
-        }
+        protected abstract void ExposeVideo (Gdk.EventExpose evnt);
         
-        protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+        protected override void OnDestroyed ()
         {
-            video_window.MoveResize (allocation);
-            base.OnSizeAllocated (allocation);
-            
-            QueueDraw ();
+            base.OnDestroyed ();
+            ServiceManager.PlayerEngine.EventChanged -= OnPlayerEngineEventChanged;
         }
         
-        protected override bool OnConfigureEvent (Gdk.EventConfigure evnt)
-        {
-            if (video_window != null && ServiceManager.PlayerEngine.SupportsVideo) {
-                ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, true);
-            }
-            
-            return false;
-        }
-
         protected override bool OnExposeEvent (Gdk.EventExpose evnt)
         {
-            if (video_window == null || !video_window.IsVisible) {
+            if (RenderWindow == null || !RenderWindow.IsVisible) {
                 return true;
             }
             
             if (!render_idle && ServiceManager.PlayerEngine.SupportsVideo) {
-                ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, false);
+                ExposeVideo (evnt);
                 return true;
             }
             
@@ -145,7 +75,7 @@
                 return true;
             }
             
-            video_window.DrawPixbuf (Style.BackgroundGC (StateType.Normal), idle_pixbuf, 0, 0, 
+            RenderWindow.DrawPixbuf (Style.BackgroundGC (StateType.Normal), idle_pixbuf, 0, 0, 
                 (Allocation.Width - idle_pixbuf.Width) / 2, (Allocation.Height - idle_pixbuf.Height) / 2, 
                 idle_pixbuf.Width, idle_pixbuf.Height, Gdk.RgbDither.Normal, 0, 0);
             
@@ -154,8 +84,11 @@
         
         private void OnPlayerEngineEventChanged (object o, PlayerEngineEventArgs args)
         {
-            if (args.Event == PlayerEngineEvent.StartOfStream || args.Event == PlayerEngineEvent.EndOfStream) {
-                ToggleIdleVisibility ();
+            switch (args.Event) {
+                case PlayerEngineEvent.StartOfStream:
+                case PlayerEngineEvent.EndOfStream:
+                    ToggleIdleVisibility ();
+                    break;
             }
         }
         
@@ -169,8 +102,8 @@
         public new void QueueDraw ()
         {
             base.QueueDraw ();
-            if (video_window != null) {
-                video_window.InvalidateRect (new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height), true);
+            if (RenderWindow != null) {
+                RenderWindow.InvalidateRect (new Gdk.Rectangle (0, 0, Allocation.Width, Allocation.Height), true);
             }
         }
     }

Added: trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Banshee.NowPlaying/XOverlayVideoDisplay.cs	Sat Apr 19 01:26:30 2008
@@ -0,0 +1,155 @@
+//
+// XOverlayVideoDisplay.cs
+//
+// Author:
+//   Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Gtk;
+
+using Banshee.ServiceStack;
+
+namespace Banshee.NowPlaying
+{   
+    public class XOverlayVideoDisplay : VideoDisplay
+    {
+        private Gdk.Window video_window;                
+        protected override Gdk.Window RenderWindow {
+            get { return video_window; }
+        }
+
+        public XOverlayVideoDisplay () : base ()
+        {
+        }
+        
+        protected override void OnRealized ()
+        {
+            WidgetFlags |= WidgetFlags.Realized;
+        
+            Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
+            attributes.WindowType = Gdk.WindowType.Child;
+            attributes.X = Allocation.X;
+            attributes.Y = Allocation.Y;
+            attributes.Width = Allocation.Width;
+            attributes.Height = Allocation.Height;
+            attributes.Visual = Visual;
+            attributes.Wclass = Gdk.WindowClass.InputOutput;
+            attributes.Colormap = Colormap;
+            attributes.EventMask = (int)(Gdk.EventMask.ExposureMask | Gdk.EventMask.VisibilityNotifyMask);
+            
+            Gdk.WindowAttributesType attributes_mask = 
+                Gdk.WindowAttributesType.X | 
+                Gdk.WindowAttributesType.Y | 
+                Gdk.WindowAttributesType.Visual | 
+                Gdk.WindowAttributesType.Colormap;
+                
+            GdkWindow = new Gdk.Window (Parent.GdkWindow, attributes, attributes_mask);
+            GdkWindow.UserData = Handle;
+            
+            if (video_window != null) {
+                video_window.Reparent (GdkWindow, 0, 0);
+                video_window.MoveResize (0, 0, Allocation.Width, Allocation.Height);
+                video_window.ShowUnraised ();
+                return;
+            }
+            
+            attributes = new Gdk.WindowAttr ();
+            attributes.WindowType = Gdk.WindowType.Child;
+            attributes.X = 0;
+            attributes.Y = 0;
+            attributes.Width = Allocation.Width;
+            attributes.Height = Allocation.Height;
+            attributes.Visual = Visual;
+            attributes.Wclass = Gdk.WindowClass.InputOutput;
+            attributes.Colormap = Colormap;
+            attributes.EventMask = (int)(Gdk.EventMask.ExposureMask | Gdk.EventMask.VisibilityNotifyMask);
+            
+            attributes_mask = 
+                Gdk.WindowAttributesType.X | 
+                Gdk.WindowAttributesType.Y | 
+                Gdk.WindowAttributesType.Visual | 
+                Gdk.WindowAttributesType.Colormap;
+                
+            video_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
+            video_window.UserData = Handle;
+                        
+            video_window.SetBackPixmap (null, false);
+            
+            ServiceManager.PlayerEngine.VideoWindow = video_window.Handle;
+        }
+        
+        protected override void OnUnrealized ()
+        {
+            video_window.Hide ();
+            video_window.Reparent (null, 0, 0);
+            
+            base.OnUnrealized ();
+        }
+
+        protected override void OnMapped ()
+        {
+            WidgetFlags |= WidgetFlags.Mapped;
+            
+            GdkWindow.Show ();
+            video_window.ShowUnraised ();
+        }
+        
+        protected override void OnUnmapped ()
+        {
+            WidgetFlags &= ~WidgetFlags.Mapped;
+            
+            video_window.Hide ();
+            GdkWindow.Hide ();
+        }
+        
+        protected override void OnSizeAllocated (Gdk.Rectangle allocation)
+        {
+            if (!IsRealized) {
+                return;
+            }
+            
+            Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, allocation.Width, allocation.Height);
+            video_window.MoveResize (rect);
+            
+            base.OnSizeAllocated (allocation);
+            
+            QueueDraw ();
+        }
+        
+        protected override bool OnConfigureEvent (Gdk.EventConfigure evnt)
+        {
+            if (video_window != null && ServiceManager.PlayerEngine.SupportsVideo) {
+                ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, true);
+            }
+            
+            return false;
+        }
+        
+        protected override void ExposeVideo (Gdk.EventExpose evnt)
+        {
+            ServiceManager.PlayerEngine.VideoExpose (video_window.Handle, true);
+        }
+    }
+}

Modified: trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am	(original)
+++ trunk/banshee/src/Extensions/Banshee.NowPlaying/Makefile.am	Sat Apr 19 01:26:30 2008
@@ -7,7 +7,8 @@
 	Banshee.NowPlaying/FullscreenWindow.cs \
 	Banshee.NowPlaying/NowPlayingInterface.cs \
 	Banshee.NowPlaying/NowPlayingSource.cs \
-	Banshee.NowPlaying/VideoDisplay.cs
+	Banshee.NowPlaying/VideoDisplay.cs \
+	Banshee.NowPlaying/XOverlayVideoDisplay.cs
 
 RESOURCES =  \
 	Banshee.NowPlaying.addin.xml \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]