194 points · by ingve · 2y ago · 122 comments
In Qt, there is an option to use either native windows for individual widgets or "alien" windows, in which only the top level widget is a native window - https://doc.qt.io/qt-6/qwidget.html#native-widgets-vs-alien-....
The non-client area included stuff like the title bar, min/max/close buttons and system menu icon, and resizing borders.
The client area was where your app would put its content, including any child windows like buttons and list boxes.
Many of the window messages for the client area had corresponding non-client messages, for example WM_PAINT and WM_NCPAINT. All of these messages would arrive in your GetMessage/DispatchMessage loop, but you would generally ignore the WM_NC versions and DispatchMessage would send them to the Windows code for default processing.
OS/2 Presentation Manager took a more elegant approach here (but probably slower). You had one main window and everything inside it - both "client" and "non-client" stuff - was child windows.
So you just had one set of messages for everything, no WM_NCxxxx messages at all. The client area was a child window, with other child windows for the non-client doodads.
Windows is kinda smalltalk-like in its window message system.
[1]: https://devblogs.microsoft.com/oldnewthing/20050211-00/?p=36...
[2]: https://devblogs.microsoft.com/oldnewthing/20050315-00/?p=36...
BTW, the current Windows Task Manager still shows the total HANDLE count on the CPU page.
They were not used in apps with complex UIs because native controls were hard to skin and didn't work very well when their size was very small (as complex UIs tend to need)
That depends on the overhead per window. Microsoft Windows could use nested windows because it had separate Graphics objects to store such things as the current drawing pen, its position and the current font to use for drawing (https://learn.microsoft.com/en-us/windows/win32/api/gdiplusg...)
In comparison, on the classic Mac every window had a GrafPort that defined a boundary region, a clipping region, the current pen position, size, drawing pattern, etc.
The Mac could have such heavy-weight window objects because it didn’t nest windows. Instead, each window had a single list of controls that were much lighter-weight.
my gut feeling says separating the drawing state from windows as in MS Windows is the better choice, but I also think having separate entities called “windows” and “controls” as on the Mac is the better choice.
(its documentation is ‘less than stellar’, but it appears GrafPort still exists: https://developer.apple.com/documentation/applicationservice...)
For a while there, at least on Windows 3.1 and before, possibly some Windows 9x versions -- you had a GDI heap and USER heap of 64k each (one 16-bit x86 segment). If you allocated too many HANDLEs, you could blow one of these heaps. So it still made sense to be judicious about how many windows you created. Most Web browsers and word processors, for instance, drew their documents in the client area and did not use subwindows to position text elements.
IIRC this limit never applied to the NT family (NT, 2000, XP, …).
--
[1] I can't remember if this was resolved at all in the 98 releases, I imagine not
Every time I’m forced to use Windows I’m blow away by the clownishness of every application deciding to skin its own custom windowing controls.
This started happening some time around XP, I think?
What you want to do instead is to use custom drawing and event handling code for those list items. The it will be very snappy.
In older programs this menu is still around and you can still use it to close programs, like you did in Windows 3.1 days. Even doubleclicking the icon in the top left corner still works to close those programs.
It's alt+SPACE. Very handy if you manage to get a window off screen, you that menu almost always shows up on screen, and you can select Move (possibly by hitting m), and then move (or drag) your mouse and the window comes back.
Maybe, but I just tried it and it seems to open some type of search.
> Very handy if you manage to get a window off screen, you that menu almost always shows up on screen, and you can select Move (possibly by hitting m), and then move (or drag) your mouse and the window comes back.
I used to use it exactly for this, but it seems like they fixed something in the past 10 years, because that does no longer happen for me. I think the last time it happened was in the Windows 7 days. That's probably also why I forgot the shortcut.
I still use the double click in the top left corner to close windows, but they kill that for more and more programs. For some time it still worked for some programs with reduced chrome, like tabbed browsers, when I clicked on a few of the blank pixels in the top left corner.
As they say, they had to do it to eliminate flicker.
Which goes to show that if your elegant design can't scale, it will be corrupted until it can. Something something "worse is better"
smalltalk has worked this way since at least 01976, but the word they used instead of 'window' was 'view'. see for example steve burbeck's 01992 'how to use model-view-controller' which is describing smalltalk-80 https://www.researchgate.net/publication/238719652_Applicati...
> Views are designed to be nested. Most windows in fact involve at least two views, one nested inside the other. The outermost view, known as the topView is an instance of StandardSystemView or one of its subClasses. The StandardSystemView manages the familiar label tab of its window. Its associated controller, which is an instance of StandardSystemController, manages the familiar moving, framing, collapsing, and closing operations available for top level windows. Inside a topView are one or more subViews and their associated controllers which manage the control options available in those views. The familiar workspace for example has a StandardSystemView as a topView, and a StringHolderView as its single subView. A subView may, in turn, have additional subViews although this is not required in most applications.
so it's not a peculiarity of x-windows; it's how windows/icon/menu/pointer guis have been built since the beginning. (i'd say 'it's how guis have been built since the beginning' but of course sketchpad, grail, nls/augment, and genesys didn't work this way, and they were certainly graphical user interfaces, even if very different in style.)
Yes of course he did, and you don't have to guess, because the phrase "Windows for example uses" makes Windows a singular noun, compare with "windows for example use". There is no possible ambiguity in the post you replied to.
find a hobby other than harassing me on hn
if you can't control yourself, take a break from hn
(most recent previous incident, though not the only one: https://news.ycombinator.com/item?id=39402249)
Yes it does. You think they run that in the same address space? When there are multiple processes with different privilege levels running their UIs? Maybe this comment was accurate for Win3.1, but for a long time there is absolutely a client server architecture behind it.
Anyway one of my favorite uses of HWND is to use a non visible window as a worker thread mechanism. Each HWND is tied to a message pump in the thread that owns it. So you can send it messages, and boom, you have a thread API...
This is why misbehaving application could get you the famous "trailing window" effect where moving a window would leave partly painted trace of it behind - you had to wait for some other coffee to properly repaint that other area.
With DWM, your GDI windows are backed by memory that at most will be a texture in DirectX, which will be then composited by DWM (equivalent of X11 extensions to capture window drawing into pixmap instead of lowest common denominator implementation of DIX/DDX that would draw immediately to framebuffer)
...features and functionality as X, regretably
Two nifty examples of this:
For a more practical way to simulate a top-level window being a child window of another program, you make the top-level window Borderless, and perform all the necessary window management to maintain position, dimensions, and Z-order.
Anyway, I believe the Microsoft Management Console (MMC) actually does this. The content windows (at least in some cases) belong to a different process than the surrounding UI.
Also, WebView2 (the new Chromium-based Edge webview) runs out-of-process, but maybe it does some things in the embedding process to improve performance?
As for why there would be bad performance for putting a window into another process's window, I can only speculate. It takes something like 10000+ CPU cycles for Windows to finish switching to a different thread or process. If this is happening for every message that is handled by both the parent and the child window, that would be a lot of overhead.
I haven't checked if the Out-of-process webview is the EXE that owns the window or not.
No idea how that's gonna work on Wayland.
There's a lot of stuff that seems hackish about modern stuff, but the needs are different. (Perhaps it seems worse to me when the modern stuff is grafted on top of X)
The thing that I remember being horrific about X was the abuse of pointers in some of the toolkits like Motif.
When GTK came along it seemed a lot easier to write to. As did Tk.
frame = (Frame)xv_create (NULL, FRAME,
FRAME_LABEL, argv[0],
XV_WIDTH, 200,
XV_HEIGHT, 100,
NULL);
panel = (Panel)xv_create (frame, PANEL, NULL);
(void) xv_create (panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Quit",
PANEL_NOTIFY_PROC, quit,
NULL);
xv_main_loop (frame);This isn't even really that old-fashioned. Any X11 WM that draws server-side-decorations is going to do this to some extent. I didn't realize fwvm uses so many windows for its decorations, but at the very least, a WM is often going to reparent the window created by the client as a child of a WM-created window, where the titlebar and drag-handle-borders will be drawn.
I imagine GNOME/X11 generally doesn't do this anymore, due to their bizarre obsession with client-side decorations. But any (IMO) sane WM that agrees with me that it's a good user experience to make all windows look visually similar, will do something like this.
Have you looked at Discord on Linux? It ~~not using~~ trying not to use CSD just looks fucking terrible and has been one of my main grips with it... If an app isn't designed around having SSDs (or is something like a game) it just looks majorly out of place.
OP is one of today's lucky 10,000 I guess.
Anyway, so it's very useful that everything in X is a window, because it works well with this input grabbing. Also it's nice for borders: the border was one outer window, and the drawing area was a smaller inner window.
I don't quite remember anymore, but I think a bad part about using the X's windows is that the coordinates were limited. Sure you only need 12-bits or so for screen coordinates, but it's convenient if you had 64-bits to handle any possible clipping or relative offset situation.
On MS Windows it's called "Capture".
macOS does precisely that. Open a Chrome window and put a Finder window over it, then move your mouse and do a scroll gesture - the target will always be whatever is below the mouse cursor at that moment, even if you don't actively select the window.
And that's how it be with the X Window System.
Compare: Windows Services for Linux.
A file server mediates access to a file system; clients connect to access files. A database server mediates access to a collection of data; clients connect to access data. A print server mediates access to a printer; clients connect to access the printer.
And an X server mediates access to the graphics device; clients connect to access the display and its related peripherals (keyboard, mouse).
If you wanted to do email on your home computer, you'd [buy and] install an email client.
You wanted to go on AOL? Install the AOL client.
Need to use Lotus Notes? Have MIS send a guy over to install the Notes client.
Wanted to run X programs? Install an X server. What? Seemed weird!
You still hear that terminology some, but nowadays you're much more likely to hear about an email app.
Anecdata, but that's why it's confusing to me even today.
But as a user, the IO devices that I interact with (keyboard, mouse, display) are the client that connect to some backend (whether a web server or a remote program).
It's the MacOS Classic and GDI and similar direct-to-hw toolkits that are now outliers
I suspect the X terminology is confusing to two groups of people:
1. Those who are used to the idea that when the computer and the display are separated by distance, the local display is a mirror of the remote machine's desktop, courtesy of a service on that machine to which the local display connects as a client. X isn't a remote desktop mirroring protocol, though; those people have the wrong model.
2. Those who are used to the idea that a server is something that runs in the background (daemon), not visible in the desktop. How can the X desktop be the server, when it's shoving pixels in your face, right in the foreground? Well, you know, someone serving you a punch also does it in your face.
So yea, I'd argue this is not some strange quirk of the X-Window system, but rather a natural property which the wise hackers decided not to spend extra effort on trying to tame.
[1] Thomas Thurman - https://www.youtube.com/watch?v=GWQh_DmDLKQ https://people.freedesktop.org/~daniels/lca2013-wayland-x11....