Skip to content
This repository has been archived by the owner on Dec 17, 2017. It is now read-only.

Commit

Permalink
lightdm: Ensure we set the primary screen's widget as active when the…
Browse files Browse the repository at this point in the history
…re more screens
  • Loading branch information
pvanek committed Jun 21, 2012
1 parent d7f30e9 commit c3d6d79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions razorqt-lightdm-greeter/main.cpp
Expand Up @@ -27,14 +27,26 @@
#include <QtGui/QDesktopWidget>
#include "mainwindow.h"


int main(int argc, char *argv[])
{
QApplication a(argc, argv);

MainWindow *focusWindow = 0;
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i)
{
MainWindow *w = new MainWindow(i);
w->show();
if (w->isMain())
focusWindow = w;
}

// Ensure we set the primary screen's widget as active when there
// are more screens
if (focusWindow)
{
focusWindow->setFocus(Qt::OtherFocusReason);
focusWindow->activateWindow();
}

return a.exec();
Expand Down
5 changes: 4 additions & 1 deletion razorqt-lightdm-greeter/mainwindow.cpp
Expand Up @@ -33,6 +33,8 @@
MainWindow::MainWindow(int screen, QWidget *parent)
: QWidget(parent)
{
setObjectName(QString("MainWindow_%1").arg(screen));

QRect screenRect = QApplication::desktop()->screenGeometry(screen);
setGeometry(screenRect);
QImage image(QString(SHARE_DIR) + "/themes/light/simple_blue_widescreen.png");
Expand All @@ -42,7 +44,8 @@ MainWindow::MainWindow(int screen, QWidget *parent)
this->setPalette(palette);

// display login dialog only in the main screen
if (screen == QApplication::desktop()->primaryScreen())
m_main = screen == QApplication::desktop()->primaryScreen();
if (m_main)
{
LoginForm *loginForm = new LoginForm(this);
int offsetX = 2*screenRect.width()/5 - loginForm->width()/2;
Expand Down
4 changes: 3 additions & 1 deletion razorqt-lightdm-greeter/mainwindow.h
Expand Up @@ -41,8 +41,10 @@ class MainWindow : public QWidget
explicit MainWindow(int screen, QWidget *parent = 0);
~MainWindow();

bool isMain() { return m_main; };


private:
bool m_main;
};

#endif // MAINWINDOW_H

0 comments on commit c3d6d79

Please sign in to comment.