diff --git a/com.github.subhadeepjasu.pebbles.yml b/com.github.subhadeepjasu.pebbles.yml index de8ea050..f6a9fa5f 100644 --- a/com.github.subhadeepjasu.pebbles.yml +++ b/com.github.subhadeepjasu.pebbles.yml @@ -1,6 +1,6 @@ app-id: com.github.subhadeepjasu.pebbles runtime: io.elementary.Platform -runtime-version: 'daily' +runtime-version: '6' sdk: io.elementary.Sdk command: com.github.subhadeepjasu.pebbles finish-args: diff --git a/src/Application.vala b/src/Application.vala index 3bdcb1e8..e471584b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -50,6 +50,18 @@ namespace Pebbles { ); X.init_threads (); settings = Settings.get_default (); + + Timeout.add_seconds (1, () => { + if (this.get_active_window () != null) { + int height = this.get_active_window ().get_allocated_height (); + if (((MainWindow) (this.get_active_window ())).previous_height != height) { + ((MainWindow) (this.get_active_window ())).previous_height = height; + adjust_font_responsive (height); + } + return true; + } + return false; + }); } protected override void activate () { @@ -57,10 +69,6 @@ namespace Pebbles { mainwindow.application = this; mainwindow.present (); - mainwindow.configure_event.connect ((event) => { - adjust_font_responsive (event); - return false; - }); } public override int command_line (ApplicationCommandLine cmd) { @@ -122,11 +130,11 @@ namespace Pebbles { private double map_range (double input, double input_start, double input_end, double output_start, double output_end) { return output_start + ((output_end - output_start) / (input_end - input_start)) * (input - input_start); } - private void adjust_font_responsive (Gdk.EventConfigure event) { + private void adjust_font_responsive (int height) { try { - var target_size_h1 = (int)map_range (double.max((double) event.height/600, 1), 1, 2, 40, 120); - var target_size_h2 = (int)map_range (double.max((double) event.height/600, 1), 1, 2, 20, 50); - var target_size_h4 = (int)map_range (double.max((double) event.height/600, 1), 1, 2, 10, 20); + var target_size_h1 = (int)map_range (double.max((double) height/600, 1), 1, 2, 40, 120); + var target_size_h2 = (int)map_range (double.max((double) height/600, 1), 1, 2, 20, 50); + var target_size_h4 = (int)map_range (double.max((double) height/600, 1), 1, 2, 10, 20); var css = DISPLAY_FONT_SIZE_TEMPLATE.printf(target_size_h1, target_size_h2, target_size_h4); font_size_provider.load_from_data (css, -1); } catch (Error e) { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 765efccd..0170c300 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -124,6 +124,8 @@ namespace Pebbles { /// Initialized bool initialized = false; + public int previous_height = 0; + public MainWindow () { settings = Pebbles.Settings.get_default (); this.delete_event.connect (() => {