Results 1 to 15 of 15

Thread: Fullscreen application under Gnome

  1. #1
    Join Date
    Dec 2007
    Posts
    14

    Default Fullscreen application under Gnome

    I've tried various code to make my QT application run full screen, but with no success.
    I've found this in Qt Assistant:
    void QWidget::showFullScreen () [slot]

    Shows the widget in full-screen mode.
    Calling this function only affects windows.
    To return from full-screen mode, call showNormal().
    Full-screen mode works fine under Windows, but has certain problems under X. These problems are due to limitations of the ICCCM protocol that specifies the communication between X11 clients and the window manager. ICCCM simply does not understand the concept of non-decorated full-screen windows. Therefore, the best we can do is to request a borderless window and place and resize it to fill the entire screen. Depending on the window manager, this may or may not work. The borderless window is requested using MOTIF hints, which are at least partially supported by virtually all modern window managers.
    An alternative would be to bypass the window manager entirely and create a window with the Qt::X11BypassWindowManagerHint flag. This has other severe problems though, like totally broken keyboard focus and very strange effects on desktop changes or when the user raises other windows.
    X11 window managers that follow modern post-ICCCM specifications support full-screen mode properly.
    See also showNormal(), showMaximized(), show(), hide(), and isVisible().
    How can I use those MOTIF hints ? There's a simpler way to run my QT application full screen in Gnome ?
    Last edited by jpn; 30th December 2007 at 17:25. Reason: missing [quote] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen application under Gnome

    is your widget a Qt 'window'?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    Yes, it's derived by QWidget.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen application under Gnome

    Yes, it's derived by QWidget.
    That doesn't make it a window yet.
    A window is a widget that isn't visually the child of any other widget and that usually has a frame and a window title.

    A window can have a parent widget. It will then be grouped with its parent and deleted when the parent is deleted, minimized when the parent is minimized etc. If supported by the window manager, it will also have a common taskbar entry with its parent.

    QDialog and QMainWindow widgets are by default windows, even if a parent widget is specified in the constructor. This behavior is specified by the Qt::Window flag.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    Ok, now it's derived from QMainWindow. How can I set it full screen ?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen application under Gnome

    and.....?
    Saying its not working doesn't include enough information.
    Relevant code will be helpful.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    Qt Code:
    1. #include "BaseWindow.h"
    2.  
    3. #include <QPushButton>
    4. #include <QPalette>
    5. #include <QPixmap>
    6. #include <QBrush>
    7.  
    8. #include "TransparentPushButton.h"
    9. #include "WindowManager.h"
    10.  
    11. #include <cstdlib>
    12.  
    13. BaseWindow::BaseWindow(const char *backgroundFileName, QWidget *parent)
    14. : QMainWindow(parent)
    15. {
    16. resize(1024, 768);
    17.  
    18. setWindowState(windowState() ^ Qt::WindowFullScreen);
    19.  
    20. QPalette palette;
    21. QPixmap pixmap = QPixmap(backgroundFileName);
    22. palette.setBrush(backgroundRole(), QBrush(pixmap));
    23. setPalette(palette);
    24.  
    25. TransparentPushButton *quit = new TransparentPushButton(990, 368, 34, 34, this);
    26.  
    27. setFocus();
    28.  
    29. QObject::connect(quit, SIGNAL(clicked()), WindowManager::TheManager, SLOT(standby()));
    30. }
    To copy to clipboard, switch view to plain text mode 
    I think it's not working beacuse of the problem with X quoted before.

  8. #8
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    It works using this code:

    Qt Code:
    1. setFixedSize(qApp->desktop()->size());
    2. setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 31st December 2007 at 08:21. Reason: missing [code] tags

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Fullscreen application under Gnome

    Well the important thing is you got what you want.
    The problem with it, is that it will only work for screens that are 1024x 768 pixels. (I mean the first code you posted)
    In addition you are setting size to the window, and I suspect this conflicts with full screen mode (but I am not sure about that) , since full screen takes the screen size as you did manfully in the second code you posted.
    Try omitting the size setting in the constructor, and see if it will show full screen with out
    Qt Code:
    1. setFixedSize(qApp->desktop()->size());
    To copy to clipboard, switch view to plain text mode 
    (just out of interest)
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  10. #10
    Join Date
    Aug 2006
    Posts
    83

    Default Re: Fullscreen application under Gnome

    This works fine under my gnome desktop:

    Qt Code:
    1. Window::Window(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4. Qt::WindowStates state = windowState();
    5. state |= Qt::WindowFullScreen;
    6. setWindowState( state );
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    Do you set the size of the windget calling resize or setFixedSize ? Do you have Compiz enabled ?

    With Compiz enabled my app goes fullscreen simply setting widget size to desktop size. But on a Compiz disabled system the same app is placed in the space between Gnome panels and Metacity window decoration is displayed.

    If I set the size AND I set Qt::FramelessWindowHint flag the widget goes fullscreen also on the Compiz disabled system.

    high_flyer: if I omit resize or setFixedSize and I use showFullScreen or setWindowState to set Qt::WindowFullScreen state the window has a small size.
    If I use only setFixedSize I've the same behaviour described above with Compiz enabled or disabled.

    So for me the only way to go fullscreen is:

    Qt Code:
    1. setFixedSize(qApp->desktop()->size());
    2. setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 31st December 2007 at 08:21. Reason: missing [code] tags

  12. #12
    Join Date
    Aug 2006
    Posts
    83

    Default Re: Fullscreen application under Gnome

    I don't use compiz. I don't use anything but the code I posted to make fullscreen applications.

  13. #13
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    Ok...I'll try your code in a new empty project and then I'll post it here.

  14. #14
    Join Date
    Dec 2007
    Posts
    14

    Default Re: Fullscreen application under Gnome

    moowy: your code works with Compiz disabled, but don't work with Compiz enable.

    Thanks a lot, I'll try to make it compatible with Compiz.

  15. #15
    Join Date
    Mar 2006
    Posts
    74
    Thanks
    1
    Qt products
    Qt3
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Fullscreen application under Gnome

    Quote Originally Posted by cionci View Post
    Do you set the size of the windget calling resize or setFixedSize ? Do you have Compiz enabled ?

    With Compiz enabled my app goes fullscreen simply setting widget size to desktop size. But on a Compiz disabled system the same app is placed in the space between Gnome panels and Metacity window decoration is displayed.

    If I set the size AND I set Qt::FramelessWindowHint flag the widget goes fullscreen also on the Compiz disabled system.

    high_flyer: if I omit resize or setFixedSize and I use showFullScreen or setWindowState to set Qt::WindowFullScreen state the window has a small size.
    If I use only setFixedSize I've the same behaviour described above with Compiz enabled or disabled.

    So for me the only way to go fullscreen is:

    Qt Code:
    1. setFixedSize(qApp->desktop()->size());
    2. setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    The above code is clearly wrong on a system with more than one monitor (IE. assuming that you want your app to take over one screen) since QApplication::desktop()->size() will return the size of the desktop and NOT the size of any of the screens that make up the desktop.

    I my application I have been using Qt::WStyle_StaysOnTop flag as my WindowFlag and this will result in a full screen app on most systems including KDE, Windows and OS/X. But this does not work on some systems. I am am not sure exactly which systems this applies to. I know it does not work on a GNOME system with Compiz. But I am not sure if this is a Compiz issue or a GNOME issue. In any case is there a definitive answer to how to make this work for all systems?

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  3. Fullscreen on Gnome is not full
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 8th March 2007, 02:05
  4. Gnome makes application crash
    By regix in forum Qt Programming
    Replies: 35
    Last Post: 18th August 2006, 19:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.