aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/call_window
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-10 23:12:05 +0200
committerfiaxh <git@lightrise.org>2021-04-11 15:09:28 +0200
commit0707fd9ac466aa5280565f5ba9ced261d725ca42 (patch)
tree125626472f98897db3b6981d29efef02f7c9da76 /main/src/ui/call_window
parent8a54a263f2714560d4eb8d83a61e14d184b61fba (diff)
downloaddino-0707fd9ac466aa5280565f5ba9ced261d725ca42.tar.gz
dino-0707fd9ac466aa5280565f5ba9ced261d725ca42.zip
Improve automatic call window resizing
Diffstat (limited to 'main/src/ui/call_window')
-rw-r--r--main/src/ui/call_window/call_window_controller.vala33
1 files changed, 29 insertions, 4 deletions
diff --git a/main/src/ui/call_window/call_window_controller.vala b/main/src/ui/call_window/call_window_controller.vala
index f66a37e1..616e341d 100644
--- a/main/src/ui/call_window/call_window_controller.vala
+++ b/main/src/ui/call_window/call_window_controller.vala
@@ -14,6 +14,9 @@ public class Dino.Ui.CallWindowController : Object {
private Plugins.VideoCallWidget? own_video = null;
private Plugins.VideoCallWidget? counterpart_video = null;
+ private int window_height = -1;
+ private int window_width = -1;
+ private bool window_size_changed = false;
public CallWindowController(CallWindow call_window, Call call, StreamInteractor stream_interactor) {
this.call_window = call_window;
@@ -26,7 +29,7 @@ public class Dino.Ui.CallWindowController : Object {
this.counterpart_video = call_plugin.create_widget(Plugins.WidgetType.GTK);
call_window.counterpart_display_name = Util.get_conversation_display_name(stream_interactor, conversation);
- call_window.set_default_size(640, 480);
+ call_window.set_default_size(704, 528); // 640x480 * 1.1
call_window.set_video_fallback(stream_interactor, conversation);
this.call_window.bottom_bar.video_enabled = calls.should_we_send_video(call);
@@ -77,12 +80,27 @@ public class Dino.Ui.CallWindowController : Object {
call_window.set_own_video_ratio((int)width, (int)height);
});
counterpart_video.resolution_changed.connect((width, height) => {
+ if (window_size_changed) return;
if (width == 0 || height == 0) return;
- if (width / height > 640 / 480) {
- call_window.resize(640, (int) (height * 640 / width));
+ if (width > height) {
+ call_window.resize(704, (int) (height * 704 / width));
} else {
- call_window.resize((int) (width * 480 / height), 480);
+ call_window.resize((int) (width * 704 / height), 704);
}
+ capture_window_size();
+ });
+ call_window.configure_event.connect((event) => {
+ if (window_width == -1 || window_height == -1) return false;
+ int current_height = this.call_window.get_allocated_height();
+ int current_width = this.call_window.get_allocated_width();
+ if (window_width != current_width || window_height != current_height) {
+ debug("Call window size changed by user. Disabling auto window-to-video size adaptation. %i->%i x %i->%i", window_width, current_width, window_height, current_height);
+ window_size_changed = true;
+ }
+ return false;
+ });
+ call_window.realize.connect(() => {
+ capture_window_size();
});
call.notify["state"].connect(on_call_state_changed);
@@ -91,6 +109,13 @@ public class Dino.Ui.CallWindowController : Object {
update_own_video();
}
+ private void capture_window_size() {
+ Allocation allocation;
+ this.call_window.get_allocation(out allocation);
+ this.window_height = this.call_window.get_allocated_height();
+ this.window_width = this.call_window.get_allocated_width();
+ }
+
private void end_call() {
call.notify["state"].disconnect(on_call_state_changed);
calls.call_terminated.disconnect(on_call_terminated);