Commit Graph

335 Commits

Author SHA1 Message Date
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
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
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
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
Andrea Martinelli
5397845a41 WindowServer: Add a new IPC to set the cursor position 2021-07-08 14:15:07 +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
Andreas Kling
092e5b75ba WindowServer: Add WindowFrame::invalidate_menubar() and use it
Clean up a FIXME about overly aggressive invalidation.
2021-07-07 21:06:15 +02:00
Andreas Kling
86d0145260 LibGfx+LibGUI+WindowServer: Use move() on Core::AnonymousBuffer more 2021-07-07 18:02:43 +02:00
Andres Crucitti
f6f14777ac WindowServer: Allow windows to be pinnable (always on top)
This patch adds the concept of a window being "Pinnable" (always drawn
on top of other windows). This can be toggled through a new checkable
action in the top left corner's window menu.
2021-07-07 15:38:59 +02:00
Tom
96155009dd WindowServer: Fix crash removing modal windows
Calling Window::is_modal requires the window to be on a window stack,
so we need to check this before removing it from the window stack.
2021-07-05 19:31:48 +02:00
Tom
fdf701ed96 WindowServer: Improve screen invalidation on window state changes
Because window states and various flags can affect the windows'
rendered areas it's safer to use the last computed occlusion rectangles
to invalidate areas on the screen that may have to be re-rendered due
to e.g. a window size change.

Fixes #6723
2021-07-05 00:03:13 +02:00
Tom
6e792553f2 WindowServer: Query driver for framebuffer offset
Depending on the driver, the second buffer may not be located right
after the first, e.g. it may be page aligned. This removes this
assumption and queries the driver for the appropriate offset.
2021-07-04 23:59:17 +02:00
Tom
fdae117600 WindowServer: Implement support for combined buffer flipping + flushing
Some devices may require DMA transfers to flush the updated buffer
areas prior to flipping. For those devices we track the areas that
require flushing prior to the next flip. For devices that do not
support flipping, but require flushing, we'll simply flush after
updating the front buffer.

This also adds a small optimization that skips these steps entirely for
a screen that doesn't have any updates that need to be rendered.
2021-07-04 23:59:17 +02:00
Andreas Kling
c2dfa9d54c WindowServer+LibGUI: Add a way to force a window to have a drop shadow 2021-07-04 23:15:17 +02:00
Andreas Kling
782a5c88ce WindowServer: Make most remaining WindowServer IPC calls async
The only remaining sync call from client to server is now the call
that switches a window's backing store. That one actually relies on
the synchronization to hand over ownership of the backing stores,
so it has to stay synchronous for now.
2021-07-04 23:15:16 +02:00
Tom
814195b060 WindowServer: Only run window animation for windows on current desktop
We should only run the minimize and launch animations for windows that
are actually rendered on the currently visible virtual desktop.
2021-07-04 20:23:56 +02:00
Tom
812ee194b7 WindowServer: Toggling desktop should only toggle current desktop
We should only show/hide the windows on the current virtual desktop.
2021-07-04 20:23:56 +02:00
ForLoveOfCats
271840ca22 WindowServer: Add show desktop toggle IPC call
Differentiates between normal minimization and hidden windows. A window
which is hidden is still minimized, but can be seen as another stage
of being minimized.
2021-07-04 13:58:56 +02:00
Tom
0fcb048448 WindowServer: Rename Window::outer_stack -> Window::window_stack
Also, make it return a reference as aside from only three special
situations (creating, destroying, and moving a window between stacks)
a window should always be on a window stack. Any access during those
brief situations would be a bug, so we should VERIFY this.
2021-07-03 12:27:23 +02:00
Tom
6ec35c91bc WindowServer: Improve occlusion calculations
This solves two problems:
* A window was sometimes deemed occluded when the window rect was
  entirely covered by other rectangles, transparent or opaque. This
  caused a window to stop rendering even if a small portion was still
  visible, e.g. when it was merely covered by a window shadow.
* The window switcher is interested in window updates even when a
  window is entirely covered by another one, or when it is on another
  desktop. This forces windows to be not occluded in those cases.
2021-07-03 12:27:23 +02:00
Tom
c06e765a5a WindowServer: Show window's desktop in window switcher if needed
If there are windows on more than one desktop then the window switcher
should show on which one they are located.
2021-07-03 12:27:23 +02:00
Tom
6472ee0eff WindowServer: Support two window switcher modes: all or current desktop
When using the Super+Tab hotkey then all windows will be displayed,
and we will switch to another virtual desktop if needed.

When using the Alt+Tab hotkey then only the windows on the current
desktop will be displayed.
2021-07-03 12:27:23 +02:00
Tom
7984c2836d WindowServer: Add API to change virtual desktop settings
This also adds the ability to query how many virtual desktops are
set up, and for the Taskbar to be notified when the active virtual
desktop has changed.
2021-07-03 12:27:23 +02:00
Tom
584b144953 WindowServer: Add basic virtual desktop support
This creates a 2-dimensional array of WindowStack instances, one for
each virtual desktop. The main desktop 0,0 is the main desktop, which
is the desktop used for all stationary windows (e.g. taskbar, desktop).
When adding windows to a desktop, stationary windows are always added
to the main desktop.

When composing the desktop, there are usually two WindowStacks
involved. For stationary windows, the main desktop will be traversed,
and for everything else the current virtual desktop will be iterated.
Iteration is interweaved to preserve the correct order. During the
transition animation, two WindowStacks will be iterated at the same
time.
2021-07-03 12:27:23 +02:00
Timothy
944e5cfb35 Everywhere: Use IPC include syntax
Remove superfluous includes from IPCCompiler's generated output and
add include directives in IPC definitions where appropriate.
2021-07-03 12:16:00 +02:00
Max Wipfli
3bdaed501e AK+Everywhere: Remove StringView::find_{first,last}_of(char) methods
This removes StringView::find_first_of(char) and find_last_of(char) and
replaces all its usages with find and find_last respectively. This is
because those two methods are functionally equivalent.
find_{first,last}_of should only be used if searching for multiple
different characters, which is never the case with the char argument.

This also adds the [[nodiscard]] to the remaining find_{first,last}_of
methods.
2021-07-02 21:54:21 +02:00
Spencer Dixon
00f93b2545 LibThreading: Add ability to cancel ongoing BackgroundActions
Handlers of the BackgroundAction are responsible for checking if the
action has been cancelled and returning early.
2021-07-02 16:47:14 +02:00
Tom
26e9140ea1 WindowServer: Fix redrawing menu window that already existed
This fixes redrawing a menu where the window menu is reused at a
different location or with different content.
2021-07-02 13:12:29 +02:00
Max Wipfli
9b8f35259c AK: Remove the LexicalPath::is_valid() API
Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
2021-06-30 11:13:54 +02:00
Tom
85bb13e081 WindowServer: Fix animations not triggering rendering
When starting the first animation and while animations are ongoing we
need to make sure we trigger rendering.
2021-06-29 10:03:53 +02:00
Erik Sommer
b12e5de047 WindowServer: Change animation time to duration
The time interval for animations is most often described as `duration`
in animation contexts and the `WindowServer::Animation` class
should reflect that.
2021-06-28 22:29:39 +02:00
Tom
30f531a55f WindowServer: Fix menu location on screens other than main screen
The menus always thought they were being outside of the main screen,
which caused them to be left and/or top aligned. This also fixes the
calculation of the available space by using the screen rectangle where
it will be displayed.
2021-06-28 17:02:37 +02:00
Tom
a55cf08ef9 WindowServer: Fix regression flushing scaled displays
This accidentally was broken by 38af4c29e
2021-06-28 16:40:15 +02:00
Tom
4c8f7113ff WindowServer: Make vertical maximize work on other screens
This doesn't yet restrict rendering to the screen it's being maximized
on.
2021-06-28 16:40:04 +02:00
Spencer Dixon
4f11138e8e LibGUI+WindowServer: Add new WMEvent Super+Space
To make Assistant useful we need a way to quickly trigger it. I've
added a new specialized event coming from the window server for when a
user is holding down 'Super' and hits 'Space'.

The Taskbar will be able to listen for this event and spawn a new
instance of the Assistant if it's not already running.
2021-06-28 16:29:02 +02:00
Tom
091628202f WindowServer: Un-tile window if resizing warrants it
Since being tiled means we restrict rendering a window to the screen it
is on (so that we don't "bleed" into an adjacent screen), we need to
untile it if the window either can't fit into the screen, or it is
detached from the screen edges.
2021-06-27 22:35:12 +02:00
Andreas Kling
6a132d8672 WindowServer+LibGUI: Allow specifying a "launch origin" for new windows
The launch_origin_rect parameter to create_window() specifies where on
screen the window was launched from. It's optional, but if you provide
it, the new window will have a short wireframe animation from the origin
to the initial window frame rect.

GUI::Window looks for the "__libgui_launch_origin_rect" environment
variable. Put your launch origin rect in there with the format
"<x>,<y>,<width>,<height>" and the first GUI::Window shown by the app
will use that as the launch origin rect.

Also it looks pretty neat, although I'm sure we can improve it. :^)
2021-06-27 19:38:11 +02:00
Andreas Kling
75f870a93f WindowServer: Add a more generic mechanism for animations
This patch adds the WindowServer::Animation class, which represents
a simple animation driven by the compositor.

An animation has a length (in milliseconds) and two hooks:

- on_update: called whenever the animation should render something.
- on_stop: called when the animation is finished and/or stopped.

This patch also ports the window minimization animation to this new
mechanism. :^)
2021-06-27 19:38:11 +02:00