summaryrefslogtreecommitdiff
path: root/src/Fl_Menu.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-04-09 09:48:34 +0000
committerManolo Gouy <Manolo>2016-04-09 09:48:34 +0000
commit3ac718fd327051b6287f6b60c8a16dca87dbab03 (patch)
treef47ef233874eb8964ee910300fca52cc3304ab11 /src/Fl_Menu.cxx
parent1ba6928313c3fa25f3b6719a4dfdc9471e72d359 (diff)
Rewrite Fl_Menu.cxx for the driver model.
See the detailed description in menuwindow::handle(int e) of Fl_Menu.cxx of how the menu window class could require 1 or 2 less support functions from the Fl_System_Driver class. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11557 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Menu.cxx')
-rw-r--r--src/Fl_Menu.cxx49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index 97a2574b2..39ab67072 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -23,6 +23,7 @@
// Fl_Menu_ widget.
#include <FL/Fl.H>
+#include <FL/Fl_System_Driver.H>
#include <FL/Fl_Menu_Window.H>
#include <FL/Fl_Menu_.H>
#include <FL/fl_draw.H>
@@ -119,12 +120,11 @@ public:
class menuwindow : public Fl_Menu_Window {
void draw();
void drawentry(const Fl_Menu_Item*, int i, int erase);
+ int handle_part1(int);
+ int handle_part2(int e, int ret);
public:
menutitle* title;
int handle(int);
-#if defined (__APPLE__) || defined (USE_X11) // PORTME: Fl_Screen_Driver - menubar
- int early_hide_handle(int);
-#endif
int itemheight; // zero == menubar
int numitems;
int selected;
@@ -655,12 +655,41 @@ static int backward(int menu) { // previous item in menu menu if possible
}
int menuwindow::handle(int e) {
-#if defined (__APPLE__) || defined (USE_X11) // PORTME: Fl_Screen_Driver - menubar
- // This off-route takes care of the "detached menu" bug on OS X.
+ /* In FLTK 1.3.4, the equivalent of handle_part2() is called for the Mac OS and X11 platforms
+ and "svn blame" shows it is here to fix STR #449.
+ But this STR is Mac OS-specific.
+ So, it is unclear why handle_part2() is called also for X11.
+
+ Furthermore, calling handle_part2() for X11 renders the
+ fix for STR #2619 below necessary. If handle_part2() is not called under X11,
+ then STR #2619 does not occur. need_menu_handle_part1_extra() activates this fix.
+
+ FLTK 1.3.4 behavior:
+ Fl::system_driver()->need_menu_handle_part2() returns true on Mac + X11
+ Fl::system_driver()->need_menu_handle_part1_extra() returns true on X11
+
+ Alternative behavior that seems equally correct:
+ Fl::system_driver()->need_menu_handle_part2() returns true on Mac
+ need_menu_handle_part1_extra() does not exist
+
+ Other alternative:
+ Neither need_menu_handle_part2() nor need_menu_handle_part1_extra() exist
+ --> the menuwindow code is entirely cross-platform and simpler.
+ It makes a small difference with Mac OS when resizing a window with a menu on:
+ the menu disappears after the end of the resize rather than at its beginning.
+ Apple applications do close popups at the beginning of resizes.
+ */
+ static int use_part2 = Fl::system_driver()->need_menu_handle_part2();
+ int ret = handle_part1(e);
+ if (use_part2) ret = handle_part2(e, ret);
+ return ret;
+}
+
+int menuwindow::handle_part2(int e, int ret) {
+ // This off-route takes care of the "detached menu" bug on OS X (STR #449).
// Apple event handler requires that we hide all menu windows right
// now, so that Carbon can continue undisturbed with handling window
// manager events, like dragging the application window.
- int ret = early_hide_handle(e);
menustate &pp = *p;
if (pp.state == DONE_STATE) {
hide();
@@ -682,8 +711,7 @@ int menuwindow::handle(int e) {
return ret;
}
-int menuwindow::early_hide_handle(int e) {
-#endif
+int menuwindow::handle_part1(int e) {
menustate &pp = *p;
switch (e) {
case FL_KEYBOARD:
@@ -748,12 +776,11 @@ int menuwindow::early_hide_handle(int e) {
}
break;
case FL_MOVE:
-#if ! (defined(WIN32) || defined(__APPLE__)) // PORTME: Fl_Screen_Driver - menubar
- if (pp.state == DONE_STATE) {
+ static int use_part1_extra = Fl::system_driver()->need_menu_handle_part1_extra();
+ if (use_part1_extra && pp.state == DONE_STATE) {
return 1; // Fix for STR #2619
}
/* FALLTHROUGH */
-#endif
case FL_ENTER:
case FL_PUSH:
case FL_DRAG: