From 3026a589b07aec9fbaf29180905631bb3f73c2fc Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 28 Feb 2002 14:36:23 +0000 Subject: [PATCH] John's possible fix to the Bad Window problems that some people have been experiencing. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3610 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 7 +++++++ src/frontends/xforms/FormBase.C | 8 ++++++++ src/frontends/xforms/FormBaseDeprecated.C | 8 ++++++++ src/frontends/xforms/FormFiledialog.C | 17 +++++++++++++---- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index e89f12a113..838f9fc27d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,10 @@ +2002-02-28 John Levon + + * FormBase.C: + * FormBaseDeprecated.C: + * FormFiledialog.C: possible fix to the Bad Window problems that some + people have been experiencing. + 2002-02-28 Angus Leeming * FormForks.C (input_button_all): resolve comparison between signed diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index bb16b6fa75..814247e298 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -19,6 +19,7 @@ #include "Dialogs.h" #include "FormBase.h" #include "xformsBC.h" +#include "GUIRunTime.h" #include "support/LAssert.h" #include "Tooltips.h" #include "xforms_helpers.h" // formatted @@ -109,6 +110,13 @@ void FormBase::show() void FormBase::hide() { + // xforms sometimes tries to process a hint-type MotionNotify, and + // use XQueryPointer, without verifying if the window still exists. + // So we try to clear out motion events in the queue before the + // DestroyNotify + XSync(fl_get_display(), false); + GUIRunTime::processEvents(); + if (form() && form()->visible) fl_hide_form(form()); } diff --git a/src/frontends/xforms/FormBaseDeprecated.C b/src/frontends/xforms/FormBaseDeprecated.C index f9ed4ef1fc..cd17667c90 100644 --- a/src/frontends/xforms/FormBaseDeprecated.C +++ b/src/frontends/xforms/FormBaseDeprecated.C @@ -19,6 +19,7 @@ #include "Dialogs.h" #include "FormBaseDeprecated.h" #include "LyXView.h" +#include "GUIRunTime.h" #include "support/LAssert.h" #include "xformsBC.h" #include "lyxrc.h" @@ -113,6 +114,13 @@ void FormBaseDeprecated::show() void FormBaseDeprecated::hide() { + // xforms sometimes tries to process a hint-type MotionNotify, and + // use XQueryPointer, without verifying if the window still exists. + // So we try to clear out motion events in the queue before the + // DestroyNotify + XSync(fl_get_display(), false); + GUIRunTime::processEvents(); + if (form() && form()->visible) { // some dialogs might do things to the form first // such as the nested tabfolder problem in Preferences diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index 95a4701b88..e5ed32b8e4 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -509,25 +509,34 @@ string const FileDialog::Private::GetDirectory() const return string("."); } +namespace { + bool x_sync_kludge(bool ret) + { + XSync(fl_get_display(), false); + return ret; + } +} // namespace anon // RunDialog: handle dialog during file selection bool FileDialog::Private::RunDialog() { force_cancel = false; force_ok = false; - + // event loop while (true) { FL_OBJECT * pObject = fl_do_forms(); if (pObject == pFileDlgForm->Ready) { if (HandleOK()) - return true; + return x_sync_kludge(true); + } else if (pObject == pFileDlgForm->Cancel || force_cancel) - return false; + return x_sync_kludge(false); + else if (force_ok) - return true; + return x_sync_kludge(true); } } -- 2.39.2