summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx28
-rw-r--r--src/Fl_Screen_Driver.cxx16
2 files changed, 37 insertions, 7 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 013d4dee1..c9a2972d2 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -827,6 +827,34 @@ void Fl::add_handler(Fl_Event_Handler ha) {
}
+/** Returns the last function installed by a call to Fl::add_handler() */
+Fl_Event_Handler Fl::last_handler() {
+ return handlers ? handlers->handle : NULL;
+}
+
+
+/** Install a function to parse unrecognized events with less priority than another function.
+ Install function \p ha to handle unrecognized events
+ giving it the priority just lower than that of function \p before
+ which was previously installed.
+ \see Fl::add_handler(Fl_Event_Handler)
+ \see Fl::last_handler()
+ */
+void Fl::add_handler(Fl_Event_Handler ha, Fl_Event_Handler before) {
+ if (!before) return Fl::add_handler(ha);
+ handler_link *l = handlers;
+ while (l) {
+ if (l->handle == before) {
+ handler_link *p = l->next, *q = new handler_link;
+ q->handle = ha;
+ q->next = p;
+ l->next = q;
+ return;
+ }
+ l = l->next;
+ }
+}
+
/**
Removes a previously added event handler.
\see Fl::handle(int, Fl_Window*)
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index d127b6b1e..112f376d3 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -571,21 +571,23 @@ void Fl_Screen_Driver::use_startup_scale_factor()
void Fl_Screen_Driver::open_display()
{
static bool been_here = false;
- // Add scale_handler first so it has least priority of all handlers
- if (!been_here) Fl::add_handler(Fl_Screen_Driver::scale_handler);
- open_display_platform();
if (!been_here) {
been_here = true;
- bool keep_scale_handler = false;
+ open_display_platform();
+ // Memorize the most recently added handler. It may have been
+ // added by open_display_platform()
+ Fl_Event_Handler last_added = Fl::last_handler();
if (rescalable()) {
use_startup_scale_factor();
- if (keyboard_screen_scaling && rescalable())
- keep_scale_handler = true;
+ if (keyboard_screen_scaling && rescalable()) {
+ // Add scale_handler after memorized one in linked list
+ // so it has less priority
+ Fl::add_handler(Fl_Screen_Driver::scale_handler, last_added);
+ }
int mx, my;
int ns = Fl::screen_driver()->get_mouse(mx, my);
Fl_Graphics_Driver::default_driver().scale(scale(ns));
}
- if (!keep_scale_handler) Fl::remove_handler(Fl_Screen_Driver::scale_handler);
}
}