Setting QWidget fullscreen on multi monitor setup - linux

i have a linux system with 2 monitor outputs (1920x1080). I arranged them to have a desktop size of 1920x2160.
Now i wanted to run a Qt Applcation, which starts in full screen mode covering the 1920x2160 desktop.
I tried:
QWidget::setFullScreen() -> The QWidget is maximized across 1 monitor
QWidget::setGeometry(0,0,1920,2160) -> The QWidget is also maximized across 1 monitor
Even if i do:
QWidget::move(0,0) & QWidget::resize(1920,2160) -> The QWidget does not exceed the size of the 1 monitor.
But if i move and resize the QWidget manually with the mouse, i can resize it to 1920x2160.
I was not able to do that programmatically.
Maybe someone has a hint for me on what i am doing wrong.
Thanks in advance.

Cause of the problem is the window manager. If i started the X server without any window manager, it was possible to call
QWidget::setGeometry(...)
and the window sized itself across all connected displays.
So i mistakenly assumed that Qt is the problem.

Related

Window manager for linux, supporting focusless windows

On my arm embedded device with a touchscreen, I have a 3rd party program (program A), that creates a window which handle keyboard presses. Because of that, this window always has to have focus. This is a closed source, and I do not have options to modify it.
I need to create a window in linux, that never grabs focus. It just shows an image, some times full screen. However, I have options not to make it full screen (1 pixel less, so window below is visible.).
Right now, I am using only X server, but I can install (almost) any window manager.
Is there a way to create a window in X, that never gets focus? If I understand X correctly, a window bellow mouse will get focus.
Is there a window manager, which supports such feature?
Is this possible to do with with xcb or wayland?
On Wayland, it's up to the compositor to tell the client whether it has focus or not, and which surface(s) to send key events to. So it would depend on the compositor or compositor toolkit you're using if it's possible.
KWin has an option that sounds like it does what you want. Right click the window title bar and choose more actions -> special window settings -> accept focus
Of the compositor toolkits, I only know the Qt Wayland Compositor API, and with that it should be possible (assuming your application can run as a Wayland client). The easiest thing would be to just show the image in the compositor using the QML APIs, or you could set enabled: false on the WaylandQuickItem or ShellSurfaceItem that you don't want to grab input focus.

pyautogui.pixel picking up color from upper left of actual position

while True:
x=pyautogui.position()
print(x+pyautogui.pixel(x[0],x[1]))
and program is picking up color that is actually upper left of my cursor...
I am using python 3.6, windows 10, on 125% magnification. is this one of the reason?
Usually picking color with the mouse gives NOT the color of the mouse pointer on the screen but the color of the screen 'below' the cursor.
On my box (Linux Mint) the code:
import pyautogui
while True:
posXY = pyautogui.position()
print(posXY, pyautogui.pixel(posXY[0], posXY[1]) )
if posXY[0] == 0:
break
delivers what it should - the color 'below' the mouse pointer.
Notice the 'break' in the endless loop. This allows you to stop the loop by moving the mouse to the left edge of the screen :)
I have the same setup as yours (but Python 3.7) and faced the very same issue.
Why it occurred? Every now and then I connect and disconnect the external monitor from my laptop. This causes certain scaling issues every time. So, I tried restarting my computer with the external monitor connected and did not disconnect it until I ran this script. It worked like a charm. BTW, I also tried just restarting the Windows Explorer, but this did not resolve the issue.
tldr; Restart your PC and do not modify the display configuration since the restart

With Qt under Gnome 3, Xfce and Unity a full screen window with a child window doesn't stay on top

I have a full screen application based on Qt. Full screen applications should always be on top because otherwise part of the window will be obstructed. I want the frameless full screen window to have child windows (special dialogs, ..). These child windows should be shown on top of the full screen window. Not much sense in showing them below.
A short, self contained example is:
from PySide import QtGui, QtCore
app = QtGui.QApplication([])
window = QtGui.QWidget(f=QtCore.Qt.WindowStaysOnTopHint)
child_window = QtGui.QWidget(window, f=QtCore.Qt.Window)
child_window.resize(400, 300)
layout = QtGui.QVBoxLayout(window)
exit = QtGui.QPushButton('Exit')
exit.clicked.connect(app.exit)
layout.addWidget(exit)
create = QtGui.QPushButton('Create child window')
create.clicked.connect(child_window.show)
layout.addWidget(create)
layout.addStretch()
window.showFullScreen()
app.exec_()
It's written in Python and tested on Python 3.X + PySide 1.2.2 (Qt 4.8) + Ubuntu 14.04 (Unity desktop) or Windows 7. However transformation to C++ Qt (or PyQt) should be straightforward.
The observation is that on Windows everything is as described at the beginning. The Qt.WindowsStaysOnTopHint is not necessary, while on Ubuntu it is.
On Ubuntu I see that initially the full screen main window is on top of everything but as soon as a child dialog window is created the usual desktop decorations (top and left bars) are shown above the full screen main window obstructing part of the view! As soon as the child window is closed the full screen window is on top again.
Question is now if there is anything that can be done to have a full screen window which is on top plus child windows on Ubuntu and with Qt?
The different behavior between Windows and Linux is also not satisfying because OS specific code should be avoided if possible.
Later:
Using the overview of available desktop environment on Ubuntu I installed several environments and tested them.
KDE, Lubuntu (Lxde?) and Openbox work as expected (and equally to Windows). The main window stays on top when shown full screen and child windows are displayed above.
However for Gnome-Shell (Gnome 3), Xfce, Unity and Awesome the desktop decoration stays on top of full screen mode windows of children windows are displayed also. Xfce and Unity behave exactly equal, Gnome and Awesome have even some small additional problems.
Did you tried thing which documentation suggests?
Qt::WindowStaysOnTopHint 0x00040000 Informs the window system that the window should stay on top of all other windows. Note that on
some window managers on X11 you also have to pass
Qt::X11BypassWindowManagerHint for this flag to work correctly.
Another thing why you want other window to be a child if it you what to be under a parent?

Different QWidget behaviour on Windows and Linux

QWidget is created after some time in my app. I start my app. Then I use internet browser. On Linux my new widget appeares over my browser, but on Windows - not. Widget has parent widget. How to fix it on Linux?
both parent and my widget have only setFocusPolicy(Qt::StrongFocus); The Linux OS is Xubuntu. And one difference in parent class:
#if defined(Q_WS_X11)
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
#else
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
#endif
I believe Windows prevents other programs from stealing the focus while some other OS may not enforce that.
When you create your widget, you should set the window state before making it visible.
For instance
QWidget* lateWidget = new QWidget(this); // or add to layout or whatever
lateWidget->setWindowState(this->windowState());
lateWidget->show();
Edit:
From the docs :
A widget that happens to be obscured by other windows on the screen is
considered to be visible
Which means that if you open the browser on top of parent then lateWidget->show() will ask to the window system to be activated.lateWidget which then pop on top and gain user mouse and keyboard focus.
before showing lateWidget a quick fix is to use
lateWidget->setAttribute(Qt::WA_ShowWithoutActivating);

Desktop effects (compiz) turned on: How to capture the image of a window WITH border/frame/title bar?

I would like to get the image of an X server Window (toplevel window, parent is the root Window) with its border/frame/title bar. I have already tried several libraries (Xlib, XRender, gdk, cairo) but none of them works. The captured image has the same geometry as the window but the frame is missing.
The problem is that the child window which should hold the frame image is InputOnly. The reason might be for this that the frame is rendered by the window decorator on the fly the same time as the Window itself.
I cannot capture the image from the RootWindow as the Window might be partially or entirely covered.
Redecorating the captured Window image could be an alternative.
Any suggestions? Thanks.
PS. When compiz is not running everything works as expected.
I use shutter for screen shots on linux, it's super easy to capture whatever portion of the screen you want. As a bonus, there are tools to add arrows or highlight sections.
http://shutter-project.org/preview/screenshots/

Resources