Commit Graph

56 Commits

Author SHA1 Message Date
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
Andreas Kling
ae90043424 WindowServer+LibGUI: Send the window size along with Paint server messages.
This way GWindow doesn't need to do synchronous IPC to fetch the appropriate
size for the window's backing store. This is mostly only relevant during
live resize.
2019-02-26 10:53:21 +01:00
Andreas Kling
1effe70543 WindowServer+LibGUI: Fix global mouse tracking with recursive widget trees.
Also avoid sending multiple copies of mouse events to global trackers.
2019-02-26 10:34:05 +01:00
Andreas Kling
95cfa49f1b LibGUI: Make event receivers be weak pointers. 2019-02-26 00:51:49 +01:00
Andreas Kling
9624b54703 More moving towards using signed types.
I'm still feeling this out, but I am starting to like the general idea.
2019-02-25 22:06:55 +01:00
Andreas Kling
6084cd0c56 Add concept of size increments to windowing system.
Use this to implement incremental resizing for Terminal so that we only
ever resize to fit a perfect number of rows and columns.

This is very nice. :^)
2019-02-21 00:21:23 +01:00
Andreas Kling
fa02d2a39b Rework the rendering model so that clients instantiate backing stores.
This makes interactive resizing work a lot better, althought it's still not
perfect. There are still glitches and unpleasant flashes of zeroed memory.
2019-02-20 22:08:14 +01:00
Andreas Kling
59b8183c4b WindowServer: Support resizing windows.
This is pretty limited and not entirely stable, but it does work! :^)
2019-02-20 15:34:55 +01:00
Andreas Kling
bf30502560 LibGUI: Implement enter/leave events (with WindowServer support.)
Windows now learn when the mouse cursor leaves or enters them.
Use this to implement GWidget::{enter,leave}_event() and use that
to implement the CoolBar button effect. :^)
2019-02-20 10:12:19 +01:00
Andreas Kling
9b71307d49 WindowServer: Support windows with alpha channels. And per-WSWindow opacity.
This patch also adds a Format concept to GraphicsBitmap. For now there are
only two formats: RGB32 and RGBA32. Windows with alpha channel have their
backing stores created in the RGBA32 format.

Use this to make Terminal windows semi-transparent for that comfy rice look.
There is one problem here, in that window compositing overdraw incurs
multiple passes of blending of the same pixels. This leads to a mismatch in
opacity which is obviously not good. I will work on this in a later patch.

The alpha blending is currently straight C++. It should be relatively easy
to optimize this using SSE instructions.

For now I'm just happy with the cute effect. :^)
2019-02-19 01:42:53 +01:00
Andreas Kling
4b15dd2bca LibGUI: Rename GEventLoop::exit() and GApplication::exit() to quit().
These functions don't exit immediately, but rather on the next iteration
of the event loop.

Since exit() is already used by the standard library, let's call it quit()
instead. That way, saying exit() means the same thing here as anywhere else.
2019-02-17 09:59:56 +01:00
Andreas Kling
29c49356e3 WindowServer: Rename GUI_Foo to WSAPI_Foo. 2019-02-15 09:17:18 +01:00
Andreas Kling
f529b845ec WindowServer: Convert entire API to be message-based.
One big step towards userspace WindowServer. :^)
2019-02-14 01:21:32 +01:00
Andreas Kling
7abef6ba9e LibGUI: Put some logspam behind debugging macros. 2019-02-11 08:27:13 +01:00
Andreas Kling
08322ab8e1 LibGUI: Coalesce update rects at the GWindow level. 2019-02-10 14:46:43 +01:00
Andreas Kling
53d34a0885 Port Terminal to LibGUI.
To facilitate listening for action on arbitrary file descriptors,
I've added a GNotifier class. It's quite simple but very useful:

GNotifier notifier(fd, GNotifier::Read);
notifier.on_ready_to_read = [this] (GNotifier& fd) {
    // read from fd or whatever else you like :^)
};

The callback will get invoked by GEventLoop when select() says we
have something to read on the fd.
2019-02-10 14:28:39 +01:00
Andreas Kling
bf766fc12c LibGUI: Implement GWindow::rect(). 2019-02-08 00:13:35 +01:00
Andreas Kling
353b191a49 Clean up some uninteresting log spam. 2019-02-06 11:32:23 +01:00
Andreas Kling
11db8c1697 Add a simple close button ("X") to windows.
Clicking the button generates a WindowCloseRequest event which the client app
then has to deal with. The default behavior for GWindow is to close() itself.

I also added a flag, GWindow::should_exit_event_loop_on_close() which does
what it sounds like it does.

This patch exposed some bugs in GWindow and GWidget teardown.
2019-02-05 10:31:37 +01:00
Andreas Kling
ffab6897aa Big, possibly complete sweep of naming changes. 2019-01-31 17:31:23 +01:00
Andreas Kling
37ab7b7a8c LibGUI: Implement destroying individual windows without exiting the process. 2019-01-30 20:03:52 +01:00
Andreas Kling
069d21ed7f Make buttons unpress when the cursor leaves the button rect.
Implement this functionality by adding global cursor tracking.
It's currently only possible for one GWidget per GWindow to track the cursor.
2019-01-27 08:48:34 +01:00
Andreas Kling
2e370fa4d5 LibGUI: Don't consider a GWidget focused if the window is inactive. 2019-01-26 21:58:43 +01:00
Andreas Kling
de2423de5f LibGUI: Flesh out focus implementation and more GTextBox work. 2019-01-26 11:24:16 +01:00
Andreas Kling
d72575d196 LibGUI: Start bringing up GTextBox in the standalone world. 2019-01-26 06:39:13 +01:00
Andreas Kling
7cf3c7461c Refactor GUI rendering model to be two-phased.
Instead of clients painting whenever they feel like it, we now ask that they
paint in response to a paint message.

After finishing painting, clients notify the WindowServer about the rect(s)
they painted into and then flush eventually happens, etc.

This stuff leaves us with a lot of badly named things. Need to fix that.
2019-01-26 05:20:32 +01:00
Andreas Kling
86eae0f8df Let userland retain the window backing store while drawing into it.
To start painting, call:
gui$get_window_backing_store()

Then finish up with:
gui$release_window_backing_store()

Process will retain the underlying GraphicsBitmap behind the scenes.
This fixes racing between the WindowServer and GUI clients.

This patch also adds a WSWindowLocker that is exactly what it sounds like.
2019-01-24 23:44:19 +01:00
Andreas Kling
05f18febb6 Ext2FS: Delete inodes when their link count goes to zero. 2019-01-22 16:34:24 +01:00