Skip to content
Permalink
Browse files

Ensure canvas has focus if nothing else has

Forward port from Sourcepole's fork
  • Loading branch information
manisandro authored and nyalldawson committed Aug 9, 2017
1 parent 4c52607 commit a6b0c44ec440f42be842daae523e8a3b505f3cba
Showing with 12 additions and 0 deletions.
  1. +10 −0 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
@@ -1234,6 +1234,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
}
#endif

connect( qApp, SIGNAL( focusChanged( QWidget*, QWidget* ) ), this, SLOT( onFocusChanged( QWidget*, QWidget* ) ) );
} // QgisApp ctor

QgisApp::QgisApp()
@@ -8791,6 +8792,15 @@ void QgisApp::userRotation()
mMapCanvas->refresh();
}

void QgisApp::onFocusChanged( QWidget* /*old*/, QWidget* now )
{
// If nothing has focus even though the window is active, ensure map canvas receives it
if ( !now && isActiveWindow() )
{
mapCanvas()->setFocus();
}
}

// toggle overview status
void QgisApp::isInOverview()
{
@@ -1510,6 +1510,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

void updateCrsStatusBar();

void onFocusChanged( QWidget* old, QWidget* now );

signals:

/**

3 comments on commit a6b0c44

@wonder-sk

This comment has been minimized.

Copy link
Member

@wonder-sk wonder-sk replied Dec 29, 2017

hi @nyalldawson I have found out this commit breaks shift+drag of 3D view when the dock widget is docked - https://issues.qgis.org/issues/17337 - and I can't really see how to safely fix that while keeping the canvas auto-focus behavior. I am a bit worried that it may cause other similar issues in the future by forcing the focus to canvas. I would prefer to roll back this change to have modifier keys work correctly in 3D view...

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Dec 29, 2017

@wonder-sk I'm ok for you to revert!

@manisandro you may want to revert from Kadas too

@manisandro

This comment has been minimized.

Copy link
Member Author

@manisandro manisandro replied Dec 29, 2017

@nyalldawson Thanks for the heads up, we haven't had any issues with it, and it is pretty essential for our "CAD"-style floating coordinate input widgets.

Please sign in to comment.
You can’t perform that action at this time.