Merge lp:~tombeckmann/audience/aspect-ration-second-try into lp:~audience-members/audience/trunk

Proposed by Tom Beckmann
Status: Merged
Approved by: Viko Adi Rahmawan
Approved revision: 467
Merged at revision: 499
Proposed branch: lp:~tombeckmann/audience/aspect-ration-second-try
Merge into: lp:~audience-members/audience/trunk
Diff against target: 153 lines (+66/-12)
2 files modified
src/Audience.vala (+61/-7)
src/Widgets/VideoPlayer.vala (+5/-5)
To merge this branch: bzr merge lp:~tombeckmann/audience/aspect-ration-second-try
Reviewer Review Type Date Requested Status
Viko Adi Rahmawan (community) Approve
Artem Anufrij (community) ratio Needs Fixing
Review via email: mp+242789@code.launchpad.net

Commit message

fix ratio constrain in CSD

Description of the change

I think it's working now, so I'm proposing it for being merged. I'm not 100% sure it will work seamlessly in all cases though, so I haven't removed the debug prints yet.

The system works by locking the window's aspect ratio after a resize has finished or while it pauses. This is required, as outlined before, because of the CSD, which adds a constant padding around the video, so in turn the entire window's aspect ratio is no longer constant when resized.

To post a comment you must log in.
467. By Tom Beckmann

try to work around minimal black bars occuring because of the resize operation

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Hey Tom,
"audience" crashes on add a new video into playlist.

It doesn't happening on currently version.

review: Needs Fixing
Revision history for this message
Tom Beckmann (tombeckmann) wrote :

After some investigations we found out that this crash is not related to this branch.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :
review: Needs Fixing (ratio)
Revision history for this message
PerfectCarl (name-is-carl) wrote :

What is the status of this work?

How can we test it in a reproducible way?
(we can't just get our hands on random movies and see what happens).

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

It works!
btw, there is a bug where i can't resize window twice, not until i fullscreen-unfullscreen the window (trunk affected too)
so maybe just remove debugging code, merge from trunk than merge it to trunk

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

I'll be focusing on gala the next couple of days (and then probably some other project will have to take immediate priority). If you like, I can change the branch ownership to ~elementary-apps (if you're part of that team, or your account directly) so you can take over from here.

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

i think unresizable bug is different problem, so my proposal we should just merge this branch into trunk.

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

I'll leave that decision completely to you, feel free to do any adjustments you like while merging :)

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

fix ratio constrain in CSD

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Audience.vala'
--- src/Audience.vala 2014-11-02 19:13:36 +0000
+++ src/Audience.vala 2014-11-25 18:33:34 +0000
@@ -89,6 +89,7 @@
89 private static App app; // global App instance89 private static App app; // global App instance
90 private Audience.Widgets.VideoPlayer video_player;90 private Audience.Widgets.VideoPlayer video_player;
91 private Audience.Widgets.BottomBar bottom_bar;91 private Audience.Widgets.BottomBar bottom_bar;
92 private Gtk.HeaderBar header;
92 private Clutter.Stage stage;93 private Clutter.Stage stage;
93 private Gtk.Revealer unfullscreen_bar;94 private Gtk.Revealer unfullscreen_bar;
94 private GtkClutter.Actor bottom_actor;95 private GtkClutter.Actor bottom_actor;
@@ -167,7 +168,7 @@
167 mainbox.pack_start (clutter);168 mainbox.pack_start (clutter);
168 mainbox.pack_start (welcome);169 mainbox.pack_start (welcome);
169170
170 var header = new Gtk.HeaderBar ();171 header = new Gtk.HeaderBar ();
171 header.set_show_close_button (true);172 header.set_show_close_button (true);
172 header.get_style_context ().remove_class ("header-bar");173 header.get_style_context ().remove_class ("header-bar");
173174
@@ -275,7 +276,7 @@
275 return false;276 return false;
276 });277 });
277278
278 mainwindow.size_allocate.connect ((alloc) => {on_size_allocate (alloc);});279 mainwindow.size_allocate.connect (on_size_allocate);
279 mainwindow.motion_notify_event.connect ((event) => {280 mainwindow.motion_notify_event.connect ((event) => {
280 if (event.window == null)281 if (event.window == null)
281 return false;282 return false;
@@ -551,12 +552,62 @@
551 mainwindow.get_window ().move_resize (monitor.width / 2 - width / 2 + monitor.x,552 mainwindow.get_window ().move_resize (monitor.width / 2 - width / 2 + monitor.x,
552 monitor.height / 2 - height / 2 + monitor.y,553 monitor.height / 2 - height / 2 + monitor.y,
553 width, height);554 width, height);
554555 }
555 if (settings.keep_aspect) {556
557 uint update_aspect_ratio_timeout = 0;
558 bool update_aspect_ratio_locked = false;
559 int prev_width = 0;
560 int prev_height = 0;
561 /**
562 * Updates the window's aspect ratio locking if enabled.
563 * Return type is just there to make it compatible with Idle.add()
564 */
565 private bool update_aspect_ratio ()
566 {
567 if (!settings.keep_aspect || video_player.video_width < 1 || video_player.height < 1
568 || !clutter.visible)
569 return false;
570
571 if (update_aspect_ratio_timeout != 0)
572 Source.remove (update_aspect_ratio_timeout);
573
574 update_aspect_ratio_timeout = Timeout.add (200, () => {
575 Gtk.Allocation a;
576 clutter.get_allocation (out a);
577 print ("%i %i %i,%i\n", a.x, a.y, (mainwindow.get_allocated_width () - clutter.get_allocated_width ()) / 2, (mainwindow.get_allocated_height () - clutter.get_allocated_height ()) / 2);
578 double width = clutter.get_allocated_width ();
579 double height = width * video_player.video_height / (double) video_player.video_width;
580 double width_offset = mainwindow.get_allocated_width () - width;
581 double height_offset = mainwindow.get_allocated_height () - clutter.get_allocated_height ();
582
583 print ("Width: %f, Height: %f, Offset: %f (%f, %f)\n", width, height, height_offset, video_player.video_width, video_player.video_height);
584
556 var geom = Gdk.Geometry ();585 var geom = Gdk.Geometry ();
557 geom.min_aspect = geom.max_aspect = video_w / (double)video_h;586 geom.min_aspect = geom.max_aspect = (width + width_offset) / (height + height_offset);
587
588 var w = mainwindow.get_allocated_width ();
589 var h = (int) (w * geom.max_aspect);
590 int b, c;
591
558 mainwindow.get_window ().set_geometry_hints (geom, Gdk.WindowHints.ASPECT);592 mainwindow.get_window ().set_geometry_hints (geom, Gdk.WindowHints.ASPECT);
559 }593
594 mainwindow.get_window ().constrain_size (geom, Gdk.WindowHints.ASPECT, w, h, out b, out c);
595 print ("Result: %i %i == %i %i\n", w, h, b, c);
596 mainwindow.get_window ().resize (b, c);
597
598 update_aspect_ratio_timeout = 0;
599
600 Idle.add (() => {
601 prev_width = mainwindow.get_allocated_width ();
602 prev_height = mainwindow.get_allocated_height ();
603
604 return false;
605 });
606
607 return false;
608 });
609
610 return false;
560 }611 }
561612
562 private void on_window_state_changed (Gdk.WindowState window_state) {613 private void on_window_state_changed (Gdk.WindowState window_state) {
@@ -603,6 +654,9 @@
603 old_h = alloc.height;654 old_h = alloc.height;
604 }655 }
605 }656 }
657
658 if (prev_width != mainwindow.get_allocated_width () && prev_height != mainwindow.get_allocated_height ())
659 Idle.add (update_aspect_ratio);
606 }660 }
607661
608 private bool update_pointer_position (double y, int window_height) {662 private bool update_pointer_position (double y, int window_height) {
@@ -854,4 +908,4 @@
854 var app = Audience.App.get_instance ();908 var app = Audience.App.get_instance ();
855909
856 app.run (args);910 app.run (args);
857}
858\ No newline at end of file911\ No newline at end of file
912}
859913
=== modified file 'src/Widgets/VideoPlayer.vala'
--- src/Widgets/VideoPlayer.vala 2014-10-05 06:13:09 +0000
+++ src/Widgets/VideoPlayer.vala 2014-11-25 18:33:34 +0000
@@ -102,7 +102,7 @@
102 if (video != null && video.data != null) {102 if (video != null && video.data != null) {
103 var video_info = (Gst.PbUtils.DiscovererVideoInfo)video.data;103 var video_info = (Gst.PbUtils.DiscovererVideoInfo)video.data;
104 video_height = video_info.get_height ();104 video_height = video_info.get_height ();
105 video_width = get_video_width (video_info);105 video_width = query_video_width (video_info);
106 }106 }
107 } catch (Error e) {107 } catch (Error e) {
108 error ();108 error ();
@@ -161,8 +161,8 @@
161 public dynamic Gst.Element playbin;161 public dynamic Gst.Element playbin;
162 Clutter.Texture video;162 Clutter.Texture video;
163163
164 uint video_width;164 public uint video_width { get; private set; }
165 uint video_height;165 public uint video_height { get; private set; }
166166
167 public GnomeSessionManager session_manager;167 public GnomeSessionManager session_manager;
168 uint32 inhibit_cookie;168 uint32 inhibit_cookie;
@@ -459,7 +459,7 @@
459 playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, new_position);459 playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, new_position);
460 }460 }
461461
462 uint get_video_width (Gst.PbUtils.DiscovererVideoInfo video_info) {462 uint query_video_width (Gst.PbUtils.DiscovererVideoInfo video_info) {
463 var par = get_video_par (video_info);463 var par = get_video_par (video_info);
464 if (par == -1) {464 if (par == -1) {
465 return video_info.get_width ();465 return video_info.get_width ();
@@ -477,4 +477,4 @@
477 return num / (double)denom;477 return num / (double)denom;
478 }478 }
479 }479 }
480}
481\ No newline at end of file480\ No newline at end of file
481}

Subscribers

People subscribed via source and target branches

to all changes: