@@ -16,9 +16,7 @@ public class Jorts.ZoomController : Object {
1616 private Jorts . StickyNoteWindow window;
1717
1818 // We keep those values static as we dont need to track instance specific
19- public static double current_scroll_delta = 0 ;
2019 public static bool is_control_key_pressed = false ;
21- public static uint8 sensitivity = 1 ;
2220
2321 // Avoid setting this unless it is to restore a specific value, do_set_zoom does not check input
2422 private uint16 _old_zoom;
@@ -31,18 +29,6 @@ public class Jorts.ZoomController : Object {
3129 this . window = window;
3230 }
3331
34- construct {
35- var keypress_controller = new Gtk .EventControllerKey ();
36- keypress_controller. key_pressed. connect (on_key_press_event);
37- keypress_controller. key_released. connect (on_key_release_event);
38- ((Gtk . Widget )window). add_controller ((Gtk . EventController )keypress_controller);
39-
40- var scroll_controller = new Gtk .EventControllerScroll (VERTICAL );
41- scroll_controller. scroll_end. connect (() = > current_scroll_delta = 0 );
42- scroll_controller. scroll. connect (on_scroll);
43- ((Gtk . Widget )window). add_controller ((Gtk . EventController )scroll_controller);
44- }
45-
4632 /**
4733 * Handler. Wraps a zoom enum into the correct function-
4834 */
@@ -109,33 +95,37 @@ public class Jorts.ZoomController : Object {
10995 window. changed ();
11096 }
11197
112- private bool on_key_press_event (uint keyval , uint keycode , Gdk .ModifierType state ) {
98+ public bool on_key_press_event (uint keyval , uint keycode , Gdk .ModifierType state ) {
11399 if (keyval == Gdk . Key . Control_L || keyval == Gdk . Key . Control_R ) {
100+ print (" Press!" );
114101 is_control_key_pressed = true ;
102+
103+ // disable scrolling for the stickies else it will prevent what we are trying to do
104+ window. view. scrolled. sensitive = false ;
115105 }
116106
117107 return Gdk . EVENT_PROPAGATE ;
118108 }
119109
120- private void on_key_release_event (uint keyval , uint keycode , Gdk .ModifierType state ) {
110+ public void on_key_release_event (uint keyval , uint keycode , Gdk .ModifierType state ) {
121111 if (keyval == Gdk . Key . Control_L || keyval == Gdk . Key . Control_R ) {
112+ debug (" Release!" );
122113 is_control_key_pressed = false ;
123- }
124- }
125114
126- private bool on_scroll (double dx , double dy ) {
127- if (! is_control_key_pressed) { return false ;}
128-
129- if (current_scroll_delta == 0 ) {
130- zoom_changed (Zoomkind . from_delta (dy));
115+ // Allow scrolling again
116+ window. view. scrolled. sensitive = true ;
131117 }
118+ }
132119
133- current_scroll_delta + = dy;
120+ public bool on_scroll (double dx , double dy ) {
121+ debug (" Scroll + Ctrl!" );
134122
135- if (current_scroll_delta . abs () > sensitivity) { // Balance between reactive and ignoring misinput
136- current_scroll_delta = 0 ;
123+ if (! is_control_key_pressed) {
124+ return false ;
137125 }
138126
139- return true ;
127+ zoom_changed (Zoomkind . from_delta (dy));
128+ debug (" Go! Zoooommmmm" );
129+ return false ;
140130 }
141131}
0 commit comments