Commit Graph

617 Commits

Author SHA1 Message Date
Karol Kosek
f2c9ef3763 WindowServer: Reuse config variable from the class on theme change
When changing the theme, there were two Core::ConfigFile instances
(one class scoped -- m_config and one function scoped -- wm_config)
fighting over the file, resulting in not saving the new theme name
to the config. :^(

This makes WindowServer remember selected theme from the menu
after reboot!
2021-07-22 00:26:44 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Tom
dbb9f891fb WindowServer: Re-use existing Screen instances and improve fallbacks
If a screen layout cannot be applied, instead of failing to start
WindowServer try to fall back to an auto-generated screen layout with
the devices that are detected.

Also, be a bit smarter about changing the current screen layout.
Instead of closing all framebuffers and bringing them back up, keep
what we can and only change resolution on those that we need to change
them on. To make this work we also need to move away from using an
array of structures to hold compositor related per-screen data to
attaching it to the Screen itself, which makes re-using a screen much
simpler.
2021-07-21 00:06:58 +02:00
Andreas Kling
59b6169b51 Taskbar: Update the start button width when system fonts change 2021-07-20 02:48:29 +02:00
Linus Groh
37cc110003 Taskbar: Launch apps in Terminal when RunInTerminal=true is specified
This feels a bit awkward right now, and needs code duplication - I think
adding a mechanism to the AppFile class to run the executable would be
neat, especially if we add an arguments field to app files - but this
will do for now.
2021-07-20 00:58:26 +01:00
Peter Elliott
2b37fad60b WindowServer: Add set_virtual_dekstop WindowManager message
Users can specify the row and column of the virtual desktop, and
WindowServer will animate to it.
2021-07-19 18:21:40 +02:00
Tom
18eeb3db87 WindowServer: Fix crash rendering fullscreen window
Fixes #8869
2021-07-19 10:24:58 +02:00
Tom
7ae46ae218 WindowServer: Fix menu over-drawing
We only need to re-draw the item being selected and the item being
deselected. We also don't care anymore if applets were added or
removed as we no longer have a global menu bar.
2021-07-18 23:55:13 +02:00
Tom
220886db4c WindowServer: Fix compositor overdraw issues related to transparency
We were re-rendering areas that were considered transparency areas even
though they weren't transparency areas or were occluded by opaque
areas.

In order to fix this, we need to be a bit smarter about what is above
and below any given window. Even though a window may have transparent
areas, if those are occluded by opaque window areas on top they are
not actually any areas that should be rendered at all. And the opposite
also applies, opaque window areas for windows below that are occluded
by transparent areas, do need to be rendered as transparency. This
solves the problem of unnecessary transparency areas.

The other problem is that we need to know what areas of a window's
dirty rectangles affect other windows, and where. Basically any
opaque area that is somehow below a transparent area that isn't
otherwise occluded, and any transparent area above any other window
area (transparent or opaque) needs to be marked dirty prior to
composing. This makes sure that all affected windows render these
areas in the correct order. To track these, we now have a map of
affected windows and the rectangles that are affected (because not all
of that window's transparency areas may be affected).
2021-07-18 18:39:20 +02:00
Tom
6bb1825366 WindowServer: Recompute occlusions when removing an overlay
This makes sure we don't needlessly render areas with transparency
that used to be occupied by an overlay.
2021-07-18 18:39:20 +02:00
Timothy
9e04ab936f WindowServer: Let clients mark windows as stealable by specific clients
This implements window stealing in WindowServer, which allows clients
to mark a window they own as 'stealable' by another client. Indicating
that the other client may use it for any purpose.

This also updates set_window_parent_from_id so that the client must
first mark its window as stealable before allowing other clients to
use it as a parent.
2021-07-18 17:21:28 +02:00
Timothy
f5e0475bdf FileSystemAccessServer: Add expose_window_server_client_id()
This will expose the client id of the WindowServerConnection this
instance of FileSystemAccessServer is using.
2021-07-18 17:21:28 +02:00
Timothy
38594dde79 FileSystemAccessServer+TextEditor: Implement cross-process modal prompts
This transitions from synchronous IPC calls to asynchronous IPC calls
provided through a synchronous interface in LibFileSystemAccessClient
which allows the parent Application to stay responsive.

It achieves this with Promise which is pumping the Application event
loop while waiting for the Dialog to respond with the user's action.

LibFileSystemAccessClient provides a lazy singleton which also ensures
that FileSystemAccessServer is running in the event of a crash.

This also transitions TextEditor into using LibFileSystemAccessClient.
2021-07-18 17:21:28 +02:00
Timothy
b77b631571 WindowServer: Add WindowServer::get_window_rect_from_client()
This allows a client to get the rect of a window in another client.
2021-07-18 17:21:28 +02:00
Timothy
88e6d18a61 WindowServer: Add WindowServer::async_set_window_parent_from_client()
This allows a client to set the parent for one of its local windows
where the parent window is in another client.
2021-07-18 17:21:28 +02:00
Timothy
522f6775a7 LibGUI+WindowServer: Expose WindowServer client id to the client
This allows an WindowServer client to identify itself and allow future
cross-client functionality in WindowServer.
2021-07-18 17:21:28 +02:00
Gunnar Beutner
56cbd00e94 SpiceAgent: Add Clipboard as a build dependency
SpiceAgent depends on header files built as part of the Clipboard
target.
2021-07-15 11:51:16 +02:00
Timothy Flynn
ae910e4370 LibWeb: Add OOPWV IPC for selecting all text 2021-07-14 17:16:39 +02:00
Timothy Flynn
2fda6ce159 LibWeb: Add OOPWV IPC for retrieving selected text 2021-07-14 17:16:39 +02:00
Daniel Bertalan
bb26cea291 WindowServer: Don't use GNU-style designator
Clang throws a fit when it encounters this code, since we already have
the standardized designated initializer syntax in C++20, which we should
use.
2021-07-14 13:12:25 +02:00
x-yl
c8b13bd053 SpiceAgent: Support copying and pasting images 2021-07-14 12:33:07 +02:00
x-yl
d4bb6a1a1e SpiceAgent: Add a new spice agent service :^)
A SPICE agent communicates with the host OS to provide nifty features
like clipboard sharing :^)

This patch implements only plain-text clipboard sharing.

See: github.com/freedesktop/spice-protocol/blob/master/spice/vd_agent.h
2021-07-14 12:33:07 +02:00
ForLoveOfCats
60713c5fcf KeyboardPreferenceLoader: Use correct default Num Lock config value 2021-07-13 23:25:07 +02:00
LuK1337
ac78f1e812 TaskbarWindow: Redraw start button when default font changes 2021-07-12 11:08:09 +02:00
Adam Hodgen
643ecfee73 FileSystemAccessServer: Return user_picked_value even on error
If a user picks a file which can't be opened for some reason, we should
still return the value, so client applications can report the error
along with the chosen filepath.
2021-07-11 09:46:50 +02:00
Tom
83b512789c WindowServer: Flush display buffer when flashing
If the device requires a flush and we modify the front buffer, we need
to flush those changes to the front buffer. This makes the flashing
work using the VirtIOGPU.

Also fix a minor bug where we flushed the front buffer instead of
the back buffer after flipping, which caused the VirtIOGPU to not work
as expected when using the SDL backend and disabling buffer flipping.
2021-07-10 21:24:52 +02:00
Timothy
41ce2debda FileSystemAccessServer: Add service for accessing veiled files nicely
Adds new service FileSystemAccessServer which allows programs to
request a file descriptor for any file on the file system.

The user can be prompted to choose the path with a FilePicker, or the
path can be provided by the application which will show a MessageBox
showing the pid and name of the calling process and allows the user to
approve or deny the request.
2021-07-10 15:33:46 +02:00
LuK1337
5e823d3de0 Taskbar: Scale window icon bitmap if it's not 16x16
Fixes: #5806
2021-07-10 14:04:21 +01:00
Andreas Kling
b8a204c5b9 LibThreading: Rename Lock => Mutex 2021-07-09 11:15:50 +02:00
Aziz Berkay Yesilyurt
dc833e49b0 WindowServer: Paint background when a fullscreen window is transparent
The windows in the background are ignored when the window is fullscreen.
However, we still would like to see the background if that window is
transparent.
2021-07-09 13:33:17 +04:30
Ali Mohammad Pur
0459a111b2 Revert "Userland: Add ability to screenshot rectangular region in shot (#8515)"
This reverts commit 1c06d77262.
This was squashed by mistake, the rebased version will follow.
2021-07-09 13:27:56 +04:30
Aziz Berkay Yesilyurt
1c06d77262
Userland: Add ability to screenshot rectangular region in shot (#8515)
* LibGUI: Verify m_window_id is not-zero in set_maximized

Window::set_maximized requires non-zero window id to be a valid call,
i.e. calling Window::show beforehand. A verify statement before the
server call can help developers by hinting correct usage.

* LibGUI: Paint background when the fullscreen window is transparent

The windows in the background are ignored when the window is fullscreen.
However, we still would like to see the background if that window is
transparent.

* Userland: Add ability to capture rectangular region in shot

A click and drag selectable, transparent, fullscreen window is
displayed with the command line argument -r for screenshots.
2021-07-09 13:11:24 +04:30
Andrea Martinelli
ab1caad1e9 Taskbar: Make clicks at the edges and corners work as expected
This makes it easy for the user to just throw the mouse at the corner
of the screen and obtain the desired outcome (eg. opening the start
menu), without having to precisely position the cursor over one of the
buttons.
2021-07-08 22:45:40 +02:00
networkException
dac7b25b8a WindowServer: Add missing minimize check to highlighted window callback
This patch adds a missing minimize check for highligted windows in
WindowStack::for_each_visible_window_of_type_from_front_to_back().
Minimized windows should not be treated as visible in this context.

Previously, iterating through each visible Window when recomputing
occlusions in the Compositor would cause a crash if a highlighted
Window is also minimized at the same time. As the WindowSwitcher
currently highligts Windows even when they are minimized, opening
it while any Window is minimized would cause WindowServer to crash.
2021-07-08 22:31:21 +02:00
networkException
76a18e1172 WindowServer: Remove rect behind window icon in WindowSwitcher
This patch removes the background behind window icons
in the WindowSwitcher which looked like it was being
rendered incorrectly (without alpha) previously.
2021-07-08 20:15:23 +02:00
Jan de Visser
a034774e3a LibSQL+SQLServer: Build SQLServer system service
This patch introduces the SQLServer system server. This service is
supposed to be the only process/application talking to database storage.
This makes things like locking and caching more reliable, easier to
implement, and more efficient.

In LibSQL we added a client component that does the ugly IPC nitty-
gritty for you. All that's needed is setting a number of event handler
lambdas and you can connect to databases and execute statements on them.

Applications that wish to use this SQLClient class obviously need to
link LibSQL and LibIPC.
2021-07-08 17:55:59 +04:30
Andrea Martinelli
5397845a41 WindowServer: Add a new IPC to set the cursor position 2021-07-08 14:15:07 +02:00
Daniel Bertalan
6f6b1b3ea1 ChessEngine: Don't call non-constexpr sqrt in a constexpr intiializer
GCC likely has a builtin intrinsic that evaluates the operation at
compile-time, even if the `LibM` is not declared as constexpr. Clang,
however, does not like it, and it failed to compile this code.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
2db4709c0c Everywhere: Add braces to aggregate initializers
This fixes a couple of warnings emitted by Clang.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
98a9a1d7f9 Everywhere: Add break after the last case label before default
We already do this in most places, so the style should be consistent.
Also, Clang does not like it, as this could cause an unexpected compile
error if some statements are added to the default label or a new label
is added above it.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
b0208ce433 Everywhere: Forward declare structs as structs
While structs being forward declared as classes is not strictly an
issue, Clang complains as this is not portable code, since some ABIs
treat classes declared as `class` and `struct` differently.

It's easier to fix these than to reason about explicitly disabling
another warning.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
b76ad3db90 IPCCompiler+WindowServer: Fix deleted function warning
It might be the case that we are passing non-movable/non-copyable things
through IPC. In this case, Clang will emit a warning as it can't
generate the requested default move/copy ctor for the IPC message.

To fix this, we use a `#pragma` to make the compiler silently ignore our
request.

The same was the case with the three-way comparison in `Screen`. Since
we don't use the three-way comparison operator anywhere else in our
codebase, we simply use the `==` operator instead.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
a2e0291172 WindowServer: Don't use old GNU-style designator
Since we use C++20, we can move to the new standardized designated
initializer syntax.
2021-07-08 10:11:00 +02:00
Daniel Bertalan
ca06fd658d Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
Andrew January
5598f63d0f WindowServer: Make descending into submenu make the submenu current
This fixes a bug with menu keyboard navigation. If you pressed the right
arrow to enter a submenu, then the left arrow to exit the submenu, then
right and left again it would leave no menu item selected.

Because descending into the submenu wasn't making it the current menu,
when you press the left arrow it couldn't find the "current menu" in the
stack, so didn't know what menu to pop back to.

It was an accident that it worked the first time you navigated into the
menu. Selecting the parent item also opened the submenu, and opening
an already open menu sets it as the current menu. After closing the
submenu with the left arrow, it is no longer already open, so it wasn't
getting set as the current menu.
2021-07-08 09:13:24 +02:00
Andreas Kling
f48e581eac WindowServer: When "flash flush" enabled, flash transparent rects green 2021-07-08 01:22:21 +02:00
Andreas Kling
432ab47053 WindowServer: Allow partial repaints in window frame & menubars
Before this change, invalidating any rect in a WindowFrame would cause
the entire window (including frame & drop shadow) to get invalidated,
leading to copious amounts of overdraw when mousing over menubars,
titlebars, and window buttons.

We now simply allow the partial frame invalidations through to the
window's dirty rects collection and the compositor takes care of it.
2021-07-08 01:17:06 +02:00
Andrew January
cad62230f6 WindowServer: Close submenus when hovering over separators
ec6debb changed item_index_at to return -1 when hovering over a
separator. The intent was to not send the separator to clients for
MenuItemEntered.

However, this had the unintented consequence of not closing the submenu
when you hover over a separator. Submenus ignore when the item index is
-1 in order to leave the menu open when you move the mouse outside. This
ends up leaving the submenu open without the highlight to show what menu
item the submenu belongs to.

A slightly less severe consequence is that pressing the up or down arrow
key in such a situation would now go the top or bottom of the menu
rather than the item above or below the separator.

We now push the special casing of separators into set_hovered_index so
that the rest of the code behaves as it did before ec6debb.
2021-07-08 01:17:02 +02:00
Andreas Kling
b027466f41 WindowServer+wsctl: Add a simple utility for toggling "flash flush"
You can now put the WindowServer into "flash flush" mode by doing:

$ wsctl -f 1

To disable it, somewhat obviously:

$ wsctl -f 0
2021-07-07 22:56:46 +02:00
Andreas Kling
6032b2cb2b WindowServer: When "flash flush" is enabled, stretch flash to 10 ms
Previously, this mode would flash flush/repaint rects in yellow for
however it long it took for the compositor to replace the yellow with
the final image instead.

Now we usleep() for 10 ms when flashing, so you get a chance to see
the yellow. This immediately makes "flash flush" mode super useful. :^)
2021-07-07 22:56:46 +02:00