Skip to content

Commit

Permalink
Fix for STR #3221: restore the correct state of mouse buttons and key…
Browse files Browse the repository at this point in the history
…board modifier keys

after closing a non-FLTK window (file or printer dialogs).

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10713 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Apr 22, 2015
1 parent 333b526 commit 335927a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/Fl_GDI_Printer.cxx
Expand Up @@ -68,7 +68,12 @@ int Fl_System_Printer::start_job (int pagecount, int *frompage, int *topage)
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE | PD_NOSELECTION;
pd.nMinPage = 1;
pd.nMaxPage = pagecount;
if (PrintDlg (&pd) != 0) {
BOOL b = PrintDlg (&pd);
if (pd.hwndOwner) { // restore the correct state of mouse buttons and keyboard modifier keys (STR #3221)
WNDPROC windproc = (WNDPROC)GetWindowLongPtrW(pd.hwndOwner, GWLP_WNDPROC);
CallWindowProc(windproc, pd.hwndOwner, WM_ACTIVATEAPP, 1, 0);
}
if (b != 0) {
hPr = pd.hDC;
if (hPr != NULL) {
strcpy (docName, "FLTK");
Expand All @@ -77,14 +82,14 @@ int Fl_System_Printer::start_job (int pagecount, int *frompage, int *topage)
di.lpszDocName = (LPCSTR) docName;
prerr = StartDoc (hPr, &di);
if (prerr < 1) {
abortPrint = TRUE;
//fl_alert ("StartDoc error %d", prerr);
err = 1;
abortPrint = TRUE;
//fl_alert ("StartDoc error %d", prerr);
err = 1;
}
} else {
commdlgerr = CommDlgExtendedError ();
fl_alert ("Unable to create print context, error %lu",
(unsigned long) commdlgerr);
(unsigned long) commdlgerr);
err = 1;
}
} else {
Expand Down
12 changes: 10 additions & 2 deletions src/Fl_Native_File_Chooser_WIN32.cxx
Expand Up @@ -568,13 +568,21 @@ int Fl_Native_File_Chooser::showdir() {
// -1 - failed; errmsg() has reason
//
int Fl_Native_File_Chooser::show() {
int retval;
if ( _btype == BROWSE_DIRECTORY ||
_btype == BROWSE_MULTI_DIRECTORY ||
_btype == BROWSE_SAVE_DIRECTORY ) {
return(showdir());
retval = showdir();
} else {
return(showfile());
retval = showfile();
}
// restore the correct state of mouse buttons and keyboard modifier keys (STR #3221)
HWND h = GetForegroundWindow();
if (h) {
WNDPROC windproc = (WNDPROC)GetWindowLongPtrW(h, GWLP_WNDPROC);
CallWindowProc(windproc, h, WM_ACTIVATEAPP, 1, 0);
}
return retval;
}

// RETURN ERROR MESSAGE
Expand Down

0 comments on commit 335927a

Please sign in to comment.