[pitivi] viewer: Use the "realize" GTK callback to asynchronously obtain window handle
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Use the "realize" GTK callback to asynchronously obtain window handle
- Date: Sat, 28 Sep 2013 19:38:22 +0000 (UTC)
commit a0a21e6ed84e6fce11636a0ca9eca73fb05cc734
Author: Nicolas Dufresne <nicolas dufresne collabora co uk>
Date: Sat Sep 28 15:01:12 2013 -0400
viewer: Use the "realize" GTK callback to asynchronously obtain window handle
This eliminates some race conditions resulting from the use of GstVideoOverlay.
Namely, this allows docking the viewer correctly if it was undocked on startup.
Note the new style of getting win32 handle.
pitivi/viewer.py | 38 +++++++++++++++++++++-----------------
1 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 86c0206..06a44b0 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -180,6 +180,10 @@ class PitiviViewer(Gtk.VBox, Loggable):
self.settings.viewerX = event.x
self.settings.viewerY = event.y
+ def _videoRealized(self, widget):
+ if widget == self.target:
+ self._switch_output_window()
+
def _createUi(self):
""" Creates the Viewer GUI """
# Drawing area
@@ -277,6 +281,8 @@ class PitiviViewer(Gtk.VBox, Loggable):
# would show through the non-double-buffered widget!
self.internal.set_no_show_all(True)
self.external.set_no_show_all(True)
+ self.internal.connect("realize", self._videoRealized)
+ self.external.connect("realize", self._videoRealized)
self.show_all()
self.external_vbox.show_all()
@@ -487,12 +493,21 @@ class PitiviViewer(Gtk.VBox, Loggable):
self.internal._currentStateCb(self.pipeline, state)
def _switch_output_window(self):
- Gdk.threads_enter()
- # Prevent cases where target has no "window_xid" (yes, it happens!):
- self.target.show()
- self.sink.set_window_handle(self.target.window_xid)
- self.sink.expose()
- Gdk.threads_leave()
+ # Don't do anything if we don't have a pipeline
+ if self.sink is None:
+ return
+
+ if self.target.get_realized():
+ if platform.system() == 'Windows':
+ xid = self.target.get_window().get_handle()
+ else:
+ xid = self.target.get_window().get_xid()
+
+ self.sink.set_window_handle(xid)
+ self.sink.expose()
+ else:
+ # Show the widget and wait for the realized callback
+ self.target.show()
class Point():
@@ -899,17 +914,6 @@ class ViewerWidget(Gtk.DrawingArea, Loggable):
self.stored = True
- def do_realize(self):
- """
- Redefine gtk DrawingArea's do_realize method to handle multiple OSes.
- This is called when creating the widget to get the window ID.
- """
- Gtk.DrawingArea.do_realize(self)
- if platform.system() == 'Windows':
- self.window_xid = self.props.window.handle
- else:
- self.window_xid = self.get_property('window').get_xid()
-
def button_release_event(self, widget, event):
if event.button == 1:
self.box.update_effect_properties()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]