Qt solves this problem with nifty heuristics and clever code that works on a wide range of window managers that exist today. X11 provides no standard or easy way to get the frame geometry once the window is decorated.
Due to the partially unclear Inter-Client Communication Conventions Manual (ICCCM), window placement is handled quite differently in existing window managers. The window manager, a separate process, may either obey, ignore or misunderstand them. All Qt can do is to send certain hints to the window manager.
Basic rule: There's always one user who uses a window manager that breaks your assumption, and who will complain to you.įurthermore, a toolkit cannot simply place windows on the screen. Thus you cannot make any safe assumption about the decoration frame your window will get. Bear in mind that X11 is policy-free (others call it flexible). This happens asynchronously at some point in time after calling QWidget::show() and the first paint event the window receives, or it does not happen at all. On X11, a window does not have a frame until the window manager decorates it. This diagram shows most of the functions in use: For all child widgets, the frame geometry is equal to the widget's client geometry. Note that the distinction only matters for decorated top-level widgets.
The QMainWindow and the QDialog classes set the Qt::WA_Window flag in their constructor, as they are designed to be used as windows and provide facilities that are not wanted for child widgets.
Depending on the window management system such secondary windows are usually stacked on top of their respective parent window, and not have a task bar entry of their own. In addition, a QWidget that has a parent can become a window by setting the Qt::WA_Window flag. This is usually only wanted for one window in the application, the primary window. Primary and Secondary WindowsĪny QWidget that has no parent will become a window, and will on most platforms be listed in the desktop's task bar. For instance, selected windows of an application are represented in the task bar. Windows are typically integrated into the desktop environment and to some degree managed by the window management system that the desktop environment provides. Windows separate applications visually from each other and usually provide a window decoration that allows the user to resize and position the applications according to his preferences. In applications, windows provide the screen space upon which the user interface is built. In Qt, QMainWindow and the various subclasses of QDialog are the most common window types. (Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). A widget that is not embedded in a parent widget is called a window.