Commit Graph

83 Commits

Author SHA1 Message Date
Andreas Kling
7ad8790d80 LibGUI: Run clang-format on everything. 2019-06-07 11:46:02 +02:00
Robin Burchell
1024dfa81a StringViewize a bunch of things -- mostly LibGUI 2019-06-03 20:27:05 +02:00
Andreas Kling
51581c21fc WindowServer+LibGUI: Add a way to bring a window to the front.
GWindow::move_to_front() can now be used to move a window to the top of
the window stack.

We use this in Terminal to bring the settings window to the front if it
already exists when it's requested, in case it's hiding behind something.
2019-06-01 20:10:37 +02:00
Andreas Kling
723ba91f74 LibGUI: Add GWidget::for_each_child_widget(callback). 2019-05-27 03:52:33 +02:00
Christopher Dumas
957f8b84f2 WindowServer: Make it possible to turn off window title bars (#88)
Also, Launcher now does not use titlebars.
Only check if titlebar should be shown if the window type works with that.
2019-05-24 23:37:23 +02:00
Andreas Kling
b0ccd04a9c LibGUI: When tabbing between focusable widgets, skip over disabled ones. 2019-05-24 22:57:05 +02:00
Andreas Kling
08228f34b9 GWindow: Only flip the window backing stores once per paint event. 2019-05-21 21:05:10 +02:00
Andreas Kling
33d0916d29 WindowServer: Add support for fullscreen windows.
Fullscreen windows are rendered alone and above everything else when they
are active, and as part of the regular window stack order when something
else is active.

Currently windows cannot be made fullscreen after-the-fact, but must have
the fullscreen flag included in their CreateWindow message.

It should not possible to interact with the menu, taskbar or window frame
while the active window is fullscreened. :^)
2019-05-17 22:33:19 +02:00
Robin Burchell
a4b0dfff43 Move double click events from LibGUI to the window server 2019-05-15 22:45:28 +02:00
Andreas Kling
ad731cc08f LibGUI: Support cycling through focusable widgets with Tab and Shift-Tab. 2019-05-15 02:39:58 +02:00
Andreas Kling
dab9901235 WindowServer+LibGUI: Handle mouse wheel deltas in the mouse event stream.
The wheel events will end up in GWidget::mousewheel_event(GMouseEvent&)
on the client-side. This patch also implements basic wheel scrolling in
GScrollableWidget via this mechanism. :^)
2019-05-13 19:52:57 +02:00
Andreas Kling
b227b57508 GWindow: Mirror the correct number of pixels to newly created back bitmaps. 2019-05-08 03:34:36 +02:00
Andreas Kling
cec16105cc Make sure all GraphicsBitmap scanlines are 16-byte aligned.
This is a prerequisite for some optimizations.
2019-05-06 14:04:54 +02:00
Andreas Kling
6a5d92f0ad WindowServer+LibGUI: Allow changing whether windows have alpha channels.
Use this in Terminal to tell the window server to not bother with the alpha
channel in the backing store if we're running without transparency.
Semi-transparent terminals look neat but they slow everything down, so this
keeps things fast while making it easy to switch to the flashy mode. :^)
2019-05-03 21:07:16 +02:00
Andreas Kling
ea9a39a9f2 LibGUI+WindowServer: Add a GResizeCorner widget.
This widget is automatically included in GStatusBar, but can be added in
any other place, too. When clicked (with the left button), it initiates a
window resize (using a WM request.)

In this patch I also fixed up some issues with override cursors being
cleared after the WindowServer finishes a drag or resize.
2019-05-03 01:38:24 +02:00
Andreas Kling
9ff36afeaa GWindow: Fix crash when calling set_rect() repeatedly.
We throw away the backing store if the window rect changes size. Since the
resizing happens asynchronously at the mercy of the WindowServer, we might
end up in set_rect() again before gaining a new backing store. So there are
no guarantees that the back/front bitmaps exist here.
2019-04-26 20:08:30 +02:00
Andreas Kling
8495abd140 GWindow: Don't send InvalidateRect message with 0 rects to WindowServer.
This could happen if GWindow::hide() was called while a window had pending
repaint rects. The deferred_invoke() lambda in GWindow::update() would
eventually run, but by then, hide() had cleared all pending rects.
2019-04-23 20:43:51 +02:00
Andreas Kling
58240fdb33 Do a pass of compiler warning fixes.
This is really making me question not using 64-bit integers more.
2019-04-23 13:00:53 +02:00
Andreas Kling
9f122bff5a WindowServer+LibGUI: Allow arbitrary number of rects in messages.
To get truly atomic updates, add a mechanism for passing arbitrary amounts
of extra data along with WindowServer messages. This allows us to pass all
the rects in a single message.
2019-04-22 01:15:47 +02:00
Andreas Kling
7234900f61 WindowServer+LibGUI: Coalesce multiple client paints into GMultiPaintEvents.
This allows GWindow to paint up to 32 separate rects before telling the
WindowServer to flip the buffers. Quite a bit smoother. :^)
2019-04-20 17:38:51 +02:00
Andreas Kling
7efd61fcf5 WindowSerer+LibGUI: Send multiple rects in invalidation/flush messages.
This patch moves to sending up to 32 rects at a time when coordinating the
painting between WindowServer and its clients. Rects are also merged into
a minimal DisjointRectSet on the server side before painting.

Interactive resize looks a lot better after this change, since we can
usually do all the repainting needed in one go.
2019-04-20 17:23:35 +02:00
Andreas Kling
45a30b4dfa LibGUI: Bundle up update() invalidations and send them on next event loop. 2019-04-20 15:19:02 +02:00
Andreas Kling
49e7ffc06a WindowServer: Introduce a WM event mask so Taskbar can ignore window rects.
Taskbar was waking up to do nothing every time a window rect changed.
2019-04-20 14:40:59 +02:00
Andreas Kling
cc9cefbd5f LibGUI: GWindow's focused widget should be a WeakPtr.
This fixes some very obvious use-after-free accesses.
2019-04-18 23:16:57 +02:00
Andreas Kling
c931eaa22c WindowServer: Generate a separate WM event for window icon changes. 2019-04-18 00:39:11 +02:00
Andreas Kling
952f334de7 GWidget: Tidy up the hit-testing code somewhat. 2019-04-16 13:25:00 +02:00
Andreas Kling
3f6408919f AK: Improve smart pointer ergonomics a bit. 2019-04-14 02:36:06 +02:00
Andreas Kling
c09c114d77 WindowServer+LibGUI: Add ability to set per-window icons.
The icons are passed around as filesystem paths for now, since the shared
memory bitmaps only support 2 sides.
2019-04-13 16:59:55 +02:00
Andreas Kling
2f1f51b8ab LibCore: Move LibGUI/GObject to LibCore/CObject. 2019-04-10 17:01:54 +02:00
Andreas Kling
b8062f69d8 LibCore: Add CEvent and make LibGUI/GEvent inherit from it. 2019-04-10 16:56:55 +02:00
Andreas Kling
55811f233f LibGUI+WindowServer: Coalesce paints and resizes on the client side.
Only process paint and resize events on the GUI client side if those events
have the latest up-to-date window size. This drastically reduces async
overdraw during interactive resize.
2019-04-10 15:39:28 +02:00
Andreas Kling
0ac55f2c38 GWindow: Discard wrongly-sized backing stores in set_rect().
The WindowServer still holds on to at least one backing store in case it
needs to paint us again before we can render a new one. This ensures that
we don't end up stuck with an undersized backing store.
2019-04-10 14:35:13 +02:00
Andreas Kling
d4818dd2dd WindowServer: Give windows a "background color" to use for missing parts.
When resizing a window, we often end up having to paint some part of it
without coverage in the current backing store. This patch makes those cases
look nicer by having a fallback background color for each window, passed
along with the CreateWindow client message.
2019-04-10 14:29:47 +02:00
Andreas Kling
7f2eeb0b35 LibGUI+WindowServer: Add support for GWidget tooltips.
Any GWidget can have a tooltip and it will automatically pop up below the
center of the widget when hovered. GActions added to GToolBars will use
the action text() as their tooltip automagically. :^)
2019-04-08 18:58:44 +02:00
Andreas Kling
99b98dc653 WindowServer: Merge WM_WindowAdded and WM_WindowStateChanged.
These events are identical, so it's silly to send both. Just broadcast
window state changes everywhere instead, it doesn't matter when it was
added as clients are learning about this asynchronously anyway.
2019-04-05 15:01:28 +02:00
Andreas Kling
aa03a07e61 Taskbar+LibGUI: More work on bringup. 2019-04-03 21:04:16 +02:00
Andreas Kling
a22774ee3f Taskbar: Start working on a taskbar app.
I originally thought I would do this inside WindowServer, but let's try to
make it as a standalone app that communicates with WindowServer instead.
That will allow us to use LibGUI. :^)
2019-04-03 19:38:44 +02:00
Andreas Kling
528054d192 GWindow: Don't ignore update(), it should repaint the whole window.
This was causing some apps to have an empty window on startup since the
call to update() in show() was effectively a no-op.
2019-04-03 15:54:16 +02:00
Andreas Kling
dcf6726487 WindowServer: Add support for per-window override cursors.
Use this to implement automatic switching to an I-beam cursor when hovering
over a GTextEditor. :^)
2019-03-31 23:52:02 +02:00
Andreas Kling
9fa21fa585 LibGUI: Add a GPainter class that inherits from Painter.
This gets rid of the last little piece of LibGUI knowledge in Painter.
2019-03-28 17:19:56 +01:00
Andreas Kling
20f7d7ec67 LibGUI: Add GWidget::doubleclick_event().
Now double-clicking an item in a GTableView or GItemView will activate it.
2019-03-25 01:43:32 +01:00
Andreas Kling
b4da451c9a WindowServer+LibGUI: Implement automatic cursor tracking.
When a mouse button is pressed inside a window, put that window into an
automatic mouse tracking state where all mouse events are sent to that
window until all mouse buttons are released.

This might feel even better if it only cared about the mouse buttons you
actually pressed while *inside* the windows to get released, I don't know.
I'll have to use it for a while and see how it's like.
2019-03-24 15:01:56 +01:00
Andreas Kling
43304d2adf WindowServer: Add special treatment for modal windows.
While a WSClientConnection has a modal window showing, non-modal windows
belonging to that client are not sent any events.
2019-03-19 00:52:39 +01:00
Andreas Kling
57ff293a51 LibGUI: Implement nested event loops to support dialog boxes.
This patch adds a simple GMessageBox that can run in a nested event loop.
Here's how you use it:

    GMessageBox box("Message text here", "Message window title");
    int result = box.exec();

The next step is to make the WindowServer respect the modality flag of
these windows and prevent interaction with other windows in the same
process until the modal window has been closed.
2019-03-19 00:01:02 +01:00
Andreas Kling
4e451c1e92 Add client-side double buffering of window backing stores.
This prevents flicker and looks rather good. The main downside is that
resizing gets even more sluggish. That's the price we pay for now.
2019-03-17 04:23:54 +01:00
Andreas Kling
0f49b5e7be LibGUI: Ignore GWindow::update() with an empty rect. 2019-03-17 01:36:38 +01:00
Andreas Kling
f40d11f06d LibGUI+WindowServer: Implement drag-to-select behavior in GTextEditor.
To make this feel right, I needed to start passing keyboard modifiers along
with mouse events. That allows shift-clicking to extend the selection. :^)
2019-03-08 17:53:02 +01:00
Andreas Kling
eda0866992 Add a C++ helper class for working with shared buffers.
This is a bit more comfortable than passing the shared buffer ID manually
everywhere and keeping track of size etc.
2019-03-08 12:24:05 +01:00
Andreas Kling
6af2ce0f7e LibGUI: Re-enable the update rect coalescing. 2019-02-28 13:58:04 +01:00
Andreas Kling
6e70ba7d1d LibGUI: GWindow should only discard the backing store on actual resize. 2019-02-27 18:52:12 +01:00