Commit graph

703 commits

Author SHA1 Message Date
thankyouverycool
ab517aa21d WindowServer: Remove m_unmaximized_rect from Window
Superceded by m_floating_rect
2022-08-25 13:28:50 +02:00
thankyouverycool
68570e897d LibGfx+WindowServer: Remove set_size_around() from Rect and Window
Superceded by to_floating_cursor_position() as a more accurate way
to reposition windows on untile. Effectively made set_size_around()
dead code, so the remnants can be removed.
2022-08-25 13:28:50 +02:00
thankyouverycool
a1dceb5b97 WindowServer: Remove nudge_into_desktop() from Window
Positioning windows outside visible coordinates is valid if sometimes
curious behavior, but it shouldn't be considered misbehavior by default.
There are multiple ways to recover windows with obscured title bars,
and this function papers over actual resize bugs and is no longer
needed to normalize window size, so let's remove it for now.
2022-08-25 13:28:50 +02:00
thankyouverycool
b180132c87 WindowServer: Fix typo 'reminder' -> 'remainder' in WindowManager 2022-08-25 13:28:50 +02:00
thankyouverycool
24b8301a0e WindowServer: Get taskbar height from TaskbarWindow directly
Fixes incorrect hardcoded heights and a failure to get taskbar
height when tiling on new workspaces.
2022-08-25 13:28:50 +02:00
thankyouverycool
46d6347035 LibGUI+WindowServer: Initialize minimum window size to zero
And remove unnecessary workarounds to the old limit of {50, 50} and
the cautious but arbitrary limit of {1, 1} for other WindowTypes.
Null rects are already the default when calculating minimum window
size and are the least restrictive but valid value.

Also returns early during minimum size calculations for frameless
windows, and verifies against negative minimum sizes and failure to
disable widget min size before setting a minimum window size. Layout
automatically overrides this setting each relayout otherwise.
2022-08-25 13:28:50 +02:00
James Bellamy
352d6545a9 WindowServer+DisplaySettings: Capitalize display mode dropdown
Every other dropdown in settings is capitalized apart from this one.
This commit fixes that.
2022-08-24 12:17:30 +02:00
Andreas Kling
17687435ca WindowServer: Redraw menu items after client updates them somehow
This fixes an issue where the undo/redo actions in TextEditor only
updated once you hovered over them.
2022-08-21 20:04:33 +02:00
thankyouverycool
a74f512f6b LibGUI+WindowServer+DisplaySettings: Add Tooltips to SystemEffects
Tooltips can now be toggled on and off system-wide.
2022-08-16 16:53:00 +02:00
thankyouverycool
d286bf85e6 WindowServer: Remove unused header in SystemEffects 2022-08-16 16:53:00 +02:00
thankyouverycool
63b8d04100 WindowServer: Walk the open menu stack in reverse on MouseMove events
Fixes lower level menus stealing focus from higher submenus.
2022-08-16 16:52:09 +02:00
thankyouverycool
e87eb97e68 WindowServer: Do not pop-up submenus directly atop their ancestors
Previously submenus would pop-up on their immediate open ancestors in
cases of limited screen real estate. If the submenu was sufficiently
large, this could make it difficult to navigate back down the menu
stack. Now submenus display on either side of their ancestors, making
it easy to zig-zag up and down menu stacks. This is similar to how
menus operate in many other DEs.
2022-08-16 16:52:09 +02:00
thankyouverycool
4489f9dbef WindowServer: Add MenuManager helper to find closest open ancestor 2022-08-16 16:52:09 +02:00
thankyouverycool
db852548ce WindowServer: Force cursor invalidation when composing immediately
And invalidate the cursor before creating a new drag-and-drop
overlay. Fixes dnd overlay bitmaps failing to draw at the correct
location immedately after changing cursors.
2022-08-16 16:43:27 +02:00
thankyouverycool
9bcd7dc0ce WindowServer: Don't start a drag and drop unless holding Primary mouse
Adds a member to record the last processed mouse buttons. If they
do not include MouseButton::Primary, return early before creating
a new drag and drop client. This fixes race conditions in which
MouseUp events canceling or completing a drop could be swallowed
by Overlay creation or postponed by an executing DragOperation,
leaving the operation in limbo.
2022-08-16 16:43:27 +02:00
thankyouverycool
7c1995993f WindowServer: Use correct config group for workspace settings
WindowServer.ini already contained the correct pluralized group by
default, but was left unused by a typo.
2022-08-16 16:41:47 +02:00
thankyouverycool
1f1ac99ef9 WindowServer+WorkspacePicker: Adjust active and inactive colors
Now uses the Selection ColorRole for the active desktop and a
slightly darkened Window for inactive ones. Several themes use
the same color for thread highlighting and inactive windows which
was causing frames to draw without the correct perception of depth.
2022-08-16 16:41:47 +02:00
Andreas Kling
072dde9387 WindowServer: Always use the automatic cursor tracking window's cursor
Whenever we're in the "automatic cursor tracking" state, we should only
display the tracking window's cursor, as the state is globally modal.
2022-08-16 00:58:26 +02:00
Andreas Kling
296e68fdbf WindowServer: Move "automatic cursor tracking window" to WindowManager
It didn't make sense for this to be a per-WindowStack concept, since
automatic cursor tracking is globally modal.
2022-08-16 00:58:26 +02:00
Andreas Kling
add4f42d21 WindowServer: Rename "active input tracking window"
...to "automatic cursor tracking window". This matches what we call its
sibling concept in LibGUI ("automatic cursor tracking widget").
2022-08-16 00:58:26 +02:00
thankyouverycool
d11ce1d808 WindowServer: Let WindowManager set serverside effects
Menu and Window animations can now be disabled and the geometry
overlay made conditional. Shadow options are dependent on the
current theme actually supplying bitmaps, but they provide a fast
way to toggle those that do without having to edit theme files.
2022-08-09 12:08:21 +02:00
thankyouverycool
841d06f676 LibGUI+WindowServer: Create IPC calls for passing SystemEffects
SystemEffects are sent to the WindowManager through
set_system_effects() and broadcast to Desktop clients with
update_system_effects(). WindowManager is reponsible for saving,
loading and rebroadcasting effects from WindowServer.ini on
config changes.
2022-08-09 12:08:21 +02:00
thankyouverycool
8904a61d71 LibGUI+WindowServer: Add a SystemEffects wrapper and helpers
SystemEffects provides a tidy way to work with system-wide
visual options passed through IPC.
2022-08-09 12:08:21 +02:00
networkException
ad060befad WindowServer+LibGUI: Remove awkward roundtrip for set wallpaper response
Previously we would wait for a separate message confirming that a
wallpaper got set instead of just calling a synchronous api.

I'm guessing that this was a limitation of the IPC system when
WindowServer got ported to using it.

This patch removes the SetWallpaperFinished message and updates the
set_wallpaper api to synchronously return a success boolean.
2022-08-02 04:04:08 +00:00
Andreas Kling
548081ea23 Userland+Base: Make the window titlebar font configurable separately
Instead of defaulting to "bold variant of the system default font",
let's allow the user to set any font they want as the titlebar font.
2022-08-01 10:29:53 +02:00
Sam Atkins
11cb7c7b28 WindowServer: Ensure windows are wide enough to show title buttons :^)
Previously, windows without a defined minimum size (or one produced from
the minimum sizes of their contents) would be shrunk down to 0 x 0,
which makes the title buttons stick out the side and become impossible
to interact with.

This patch uses the theme metrics to calculate a minimum size that is as
small as possible while still keeping the title buttons and app icon
usable. This is combined with the minimum size requested by the app
itself.

Switching themes automatically updates the calculated minimum sizes for
all existing windows. As noted, if the new theme has narrower title
buttons then the old minimum is kept, but this shouldn't be noticeable
unless you're looking for it.
2022-07-27 00:01:42 +01:00
Liav A
977aa81310 Kernel+Userland: Add ioctl to set process ownership of DisplayConnector
Now that the infrastructure of the Graphics subsystem is quite stable,
it is time to try to fix a long-standing problem, which is the lack of
locking on display connector devices. Reading and writing from multiple
processes to a framebuffer controlled by the display connector is not a
huge problem - it could be solved with POSIX locking.

The real problem is some program that will try to do ioctl operations on
a display connector without the WindowServer being aware of that which
can lead to very bad situations, for example - assuming a framebuffer is
encoded at a known resolution and certain display timings, but another
process changed the ModeSetting of the display connector, leading to
inconsistency on the properties of the current ModeSetting.

To solve this, there's a new "master" ioctl to take "ownership" and
another one to release that ownership of a display connector device. To
ensure we will not hold a Process object forever just because it has an
ownership over a display connector, we hold it with a weak reference,
and if the process is gone, someone else can take an ownership.
2022-07-23 10:42:08 +01:00
Liav A
1968aba69b Kernel+Userland: Rename FB.h => Graphics.h
This header file represents the entire interface between the kernel and
userland, and as such, no longer should be called FB.h but something
that represents the whole graphics subsystem.
2022-07-23 10:42:08 +01:00
Liav A
b5e5b299c4 Userland: Remove stale remainders of old framebuffer devices 2022-07-23 10:42:08 +01:00
Timur Sultanov
9906f41e01 Keymap+WindowServer: Add context menu to keymap applet
Adding a context menu which lists configured keymaps and allows
setting the active keymap
2022-07-21 16:40:47 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
kleines Filmröllchen
69218b92a5 LibCore+Userland: Use StringViews when calling Core::System::open
For some reason we used raw char pointers sometimes, which caused at
least one heap buffer overflow detected in fuzzing.
2022-07-09 09:25:20 +01:00
DexesTTP
7ceeb74535 AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes.

In particular, this does not fix any of the wrong uses of the previous
default parameter (which used to be 'false', meaning "only replace the
first occurence in the string"). It simply replaces the default uses by
String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
2022-07-06 11:12:45 +02:00
Lucas CHOLLET
1ba9c821fb WindowServer: Make window stealing related functions synchronous
This allows us to make sure that those operations are performed
in the right order. Affected functions are:
 - add_window_stealing_for_client
 - set_window_parent_from_client
 - remove_window_stealing_for_client
 - remove_window_stealing
2022-06-27 20:22:15 +01:00
Mike Akers
9a908748e0 WindowServer: Prevent menubar menus from appearing off screen
Adds some logic to reposition menus that would appear off the right or
bottom edge of the screen so they appear completely on screen.

Co-authored-by: Sam Atkins <atkinssj@gmail.com>
2022-06-20 16:49:31 +01:00
networkException
976b6156d4 WindowServer: Allow temporarily overriding the system theme
This patch adds a new api to override the current system theme with an
in memory override theme.
2022-06-17 19:46:30 +01:00
MacDue
5caf307ec0 WindowServer+MouseSettings: Toggle cursor highlighting with Super+H
Rather than enabling/disabling cursor highlighting by going into mouse
settings, you can now instead toggle it any time with Super+H. Mouse
settings now is only for customising the look of the highlighting.
2022-06-10 23:02:34 +01:00
MacDue
44cd973148 WindowServer+MouseSettings: Make default cursor highlight more visible
A litte smaller, and red with a slightly higher opacity, which
is much easier to make out.
2022-06-10 23:02:34 +01:00
MacDue
d3ed490cb4 WindowServer: Fix the cursor being offset with highlighting enabled 2022-06-10 23:02:34 +01:00
MacDue
c2f94b92c4 WindowServer: Fix animated cursor not starting after cursor theme switch
Simply setting m_current_cursor in current_cursor_was_reloaded() does
not setup the cursor animation, that has to be done in change_cursor().

This also fixes the cursor disappearing after switching from an animated
cursor back to a normal one (which was due to it trying to draw a cursor
frame that did not exist).
2022-06-10 20:51:55 +01:00
Liav A
f62cd52d12 WindowServer: Drop support for the DisplayConnector write interface
All DisplayConnectors should support the mmap interface and it should
provide better performance now, so let's just use it and drop support
for the DisplayConnector's write interface from the WindowServer side.
2022-06-06 20:11:05 +01:00
MacDue
5fc13e1d53 WindowServer: Add IPC calls for changing the cursor highlighting 2022-06-05 22:42:35 +01:00
MacDue
29d8ec1b18 WindowServer: Implement cursor highlighting
This allows drawing a nice cursor highlight with an arbitrary color
and radius in the compositor. The highlight circle is, of course,
antialiased :^).
2022-06-05 22:42:35 +01:00
MacDue
2a49b58269 WindowServer: Factor out config sync check to sync_config_to_disk() 2022-06-05 22:42:35 +01:00
MacDue
fddff5f4f6 LibCore: Remove ConfigFile::write_color_entry()
This method is currently unused and adds an unwanted dependency on
LibGfx.

This also adds some missing `LibGfx/Color.h` includes.
2022-06-05 22:42:35 +01:00
Lorenzo Concas
a67a7229f8 WindowServer: Check that a menu is not null
If an application menu is null, WindowServer crashes
2022-06-03 12:30:32 +01:00
MacDue
5e5a055455 Services: Use Core::Process::spawn() for common process spawn pattern 2022-06-03 12:29:56 +01:00
Olivier De Cannière
5a3321b899 Taskbar+Desktop: Add super+D keyboard shortcut
This shortcut has the same effect as pressing the "Show Desktop" button
in the taskbar. This shortcut already exists in Windows.
2022-06-01 19:31:34 +02:00
networkException
524f4be5af LibGUI+WindowServer: Propagate action icon changes to buttons and menus
Previously when setting an action's icon we would only change the bitmap
stored by the action. This patch adds logic to propagate that change to
toolbar buttons as well as window menus.

This fixes an issue in SoundPlayer that would cause the play button not
to reflect the play state.
2022-06-01 12:33:06 +01:00
montiagne
9e694c9d83 WindowServer: Call screen_resolution_changed after window screens clear
When the user executes chres to change to a new resolution, the
WindowManager removes for each window its intersections with the
screens (window.screens()) and recalculates its rect. Finally, a
Window::set_rect call sets the window's new rectangle. The set_rect
call also triggers a call to Compositor::invalidate_occlusions which
fills for each window the intersections with the screens again in
window.screens().
In case chres switches to an already present resolution the set_rect
call exits prematurely as it checks if the window's rect really
changed. This means that nobody calls invalidate_occlusions
resulting in a rendering issue for each window.

Moving the call to Compositor::screen_resolution_changed after the
clearing of window.screens() and recalc of the window rect for each
window resolves the rendering issue as screen_resolution_changed
calls invalidate_occlusions.
2022-05-29 00:26:20 +01:00
Liav A
102ac09ad7 WindowServer: Stop spurious debug spam after flushing the framebuffer
This became apparent when using the VirtIO graphics device, because the
HardwareScreenBackend object needs to allow flushing of the framebuffer
constantly, and due to incorrect if-else flow, even a non-error response
from the ioctl was leading to a debug spam.
2022-05-25 23:33:31 +01:00
MacDue
857a767ab4 WindowServer: Fix crash when hovering over title buttons
This fixes a crash where if you switched to a theme that has hover
icons for title buttons, then back to a theme that does not. Then
when you next hover over the title buttons the window server would
crash.

This was due to the hover_bitmap multi-scale bitmap pointer being
non-null, but not containing any bitmaps, so hitting an assertion
when painting.
2022-05-18 19:05:18 +02:00
Sam Atkins
6ba03dec35 WindowServer: Save config file when mouse cursor theme is changed
When user code requests the current cursor theme name with
`GUI::ConnectionToWindowServer::the().get_cursor_theme()`, that reads
the name from the config file. If we don't write that out when it's
changed, then users get given an outdated cursor theme instead of the
current one.

In particular, changing the theme in MouseSettings, saving and closing
it, then reopening MouseSettings, would show the wrong theme selected.
So, that's fixed now. :^)
2022-05-12 13:10:49 +02:00
kleines Filmröllchen
bc2f738a84 WindowServer: Make window frame flashing use the highlight color
Now, when windows flash, the "active" color of the window title frame's
flash is the highlight color instead of the standard window color. The
"inactive" color of the flash is still the disabled color as before.

Reasoning behind this change in aesthetics: There are four [1] window
title frame colors with specific UI purposes:
1. "Active" for the normal active window, obvious purpose.
2. "Moving" for the window that is being dragged or resized by the user.
   Responsible for acting as a visual click feedback as a kind of
   subdued button.
3. "Inactive" for any inactive windows, obvious purpose.
4. "Highlight".

The purpose of "Highlight" is in the name, though it's non-obvious what
that exactly entails. Before, only alt-tab selecting windows would use
the highlight color for showing the current target window. In my opinion
this points to the purpose of "highlight" being to move the user's focus
to another window when the simple active state is not enough. Then it
makes sense to have the window flashing use the highlight color. The
entire purpose of window flashing is to shift the user's focus to a
dialog window that might not be close to the window they just clicked.
Using the highlight color enables an even stronger emphasis than before.
It enables a cleaner separation between the purpose of the two frame
colors, as well as making the "Highlight" frame more common.

[1] Technically there are eight, as the title frame has a gradient by
default. We can count the gradient as one color for this purpose.
2022-05-11 21:00:39 +02:00
offtkp
70e2b42b9d WindowServer: Consider screen scaling when getting color under cursor
Multiply the cursor position by the current scaling mode multiplier when
getting the color under the cursor. Also multiply the screen rectangle
before checking if the cursor is within bounds.

Color picker would not account for scaling when getting the color under
the cursor.

Fixes #13906.
2022-05-08 16:36:24 +02:00
Liav A
b69c8b48fc WindowServer: Separate physical resolution from scaling factors
Physical hardware doesn't care about scale factors as this is a concept
being related to WindowServer and userland applications. To ensure we
provide the correct display resolution details to HardwareScreenBackend
objects, we must keep a separate Gfx::IntRect object that reserve the
correct details.
2022-05-06 23:38:08 +02:00
Liav A
659b0d7fb4 WindowServer: Remove hack to restore graphics after switch from console
This hack is not necessary anymore, because WindowServer will try
constantly to write the framebuffer contents to the display connector
devices. After a switch from console mode to graphical mode, the write
syscall on these devices will not be silently ignored but will actually
write to the framebuffer screen.
2022-05-06 18:05:14 +02:00
Linus Groh
e5196c8e3d WindowServer: Take vertical menu offset into account when adjusting pos
Unconditionally adding the item height offset to the adjusted vertical
position of a menu leads to an incorrect position if we previously
clamped the translation offset so the menu doesn't go off-screen.

Also add some comments to this coordinate math. Always add comments to
coordinate math.
2022-05-05 21:54:53 +02:00
Liav A
e301af8352 Everywhere: Purge all support and usage of framebuffer devices
Long live the DisplayConnector object!
2022-05-05 20:55:57 +02:00
Liav A
aad968cc5e Everywhere: Rename fb prefix function names => graphics_connector 2022-05-05 20:55:57 +02:00
Liav A
10adc27eda Everywhere: Rename FB prefix structure names => Graphics 2022-05-05 20:55:57 +02:00
Liav A
4ff6150f1b WindowServer: Use FB_IOCTL_FLUSH_HEAD to flush a framebuffer if possible
This ioctl is more appropriate when the hardware supports flushing of
the entire framebuffer, so we use that instead of the previous default
FB_IOCTL_FLUSH_HEAD_BUFFERS ioctl.
2022-05-05 20:55:57 +02:00
Liav A
6d7e2596e0 WindowServer: Implement mechanism to restore safe mode setting
Such mechanism will be used by the Intel Graphics driver, because we
lack support of changing the resolution on this driver currently, so,
when WindowServer will try to mode-set the display then it will fail,
and will use the safe mode-setting call instead to be able to show
something on screen.
2022-05-05 20:55:57 +02:00
Liav A
d9a2706079 DisplaySettings+WindowServer: Add support for display connector devices 2022-05-05 20:55:57 +02:00
MacDue
44c0672d59 WindowServer: Support hover icons for title buttons
This allows adding "-hover.png" variants of the title button icons.
This can be useful for themes which use the TitleButtonsIconOnly
flag, which otherwise don't have a way of showing the hover state.
2022-05-03 22:00:14 +02:00
Peter Elliott
12c7b954e1 Kernel+WindowServer: Move setting tty graphical mode to Userspace
This will allow using the console tty and WindowServer regardless of
your kernel command line. Also this fixes a bug where, when booting in
text mode, the console was in graphical mode, and would not accept
input.
2022-04-29 19:52:32 +02:00
MacDue
9b30fe9864 LibGfx+WindowServer: Add theme flag TitleButtonsIconOnly
With this flag set to true only the icon of the title button is painted.
This is useful for themes with a more non-serenity look such as
Coffee and Cupertino (that currently try to hide the button).
2022-04-25 23:45:24 +02:00
kleines Filmröllchen
935f401714 WindowServer: Create the VirtualScreenBackend
This screen backend is just memory-backed and doesn't connect to any
screen hardware. That way, we can boot Serenity without video hardware
but in full graphical mode :^)

To create a virtual screen, put something like this in your
WindowServer.ini. There's no way yet to do this through Display
Settings, though an existing virtual screen's settings can be changed
there.
```ini
[Screen0]
Mode=Virtual
Left=1024
Top=0
Width=1920
Height=1080
ScaleFactor=1
```
2022-04-21 13:41:55 +02:00
kleines Filmröllchen
be98ce0f9f WindowServer: Add the screen mode property in the screen configuration
This will allow us to change between a couple of properties, for now
it's only Device and Virtual. (How about Remote :^) ) These get handled
by a different screen backend in the Screen.
2022-04-21 13:41:55 +02:00
kleines Filmröllchen
e95ae4a143 WindowServer: Make Screen use ScreenBackend
This will allow us to use other screen backends in the future instead.
2022-04-21 13:41:55 +02:00
kleines Filmröllchen
0acffa5ef4 WindowServer: Introduce the ScreenBackend concept
The ScreenBackend is a thin wrapper around the actual screen hardware
connection. It contains all the variables specific to that hardware and
abstracts away operations that deal with controlling the hardware. The
standard ScreenBackend implementor is HardwareScreenBackend, which
contains all the existing frame buffer & ioctl handling code of Screen.
I took this opportunity to introduce ErrorOr wherever sensible.
2022-04-21 13:41:55 +02:00
kleines Filmröllchen
1fce201d15 WindowServer: Rename fb_data and friends to flush_rect etc
This was very badly named. All that the "FBData" struct contains is the
currently to-be-flushed rectangles plus a fullness flag, so it should
better be called FlushRectData. This rename is similarly applied to all
variable names.
2022-04-21 13:41:55 +02:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Andreas Kling
1a38ab0ca1 WindowServer+LibGUI: Notify windows when their maximized state changes
Previously, GUI::Window::is_maximized() had to make a synchronous IPC
request to WindowServer in order to find out if the window was indeed
maximized.

This patch removes the need for synchronous IPC by instead pushing the
maximization state to clients when it changes.

The motivation for this change was that GUI::Statusbar was checking
if the containing window was maximized in its resize_event(), causing
all windows with a statusbar to block on sync IPC *during* resize.
Browser would typically block for ~15 milliseconds here every time
on my machine, continuously during live resize.
2022-04-05 17:45:07 +02:00
Ben Maxwell
8070a98288 DisplaySettings+WindowServer: Allow updating theme without background
With this change you can now set the theme and background color at the
same time in the Display Settings. Before if both were changed
before hitting 'apply' the theme background color would overwrite
the custom background.
2022-04-03 12:58:46 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
circl
eeeaf410fb WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held
items using the scroll wheel. In order to implement this, they
previously would have to either add a hard-coded division by 4, or look
up your mouse settings to adjust correctly.

This commit adds an MouseEvent.wheel_raw_delta_x() and
MouseEvent.wheel_raw_delta_y().
2022-03-27 01:11:27 +01:00
Lenny Maiorani
0b7baa7e5a Services: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-24 20:09:26 -07:00
Tom
9f59d7d9a0 WindowServer: Fix animation crash
If an Animation's on_stop handler cleared itself inside the on_stop
event handler, it would remove itself from the animation map that was
still being iterated, leading to a crash.

To solve this, we'll iterate over the animations using the
remove_all_matching function, which enables us to delete it by simply
returning true when the animation finished. In the event that the
Animation is kept alive elsewhere and the on_stop event clears its own
reference, we need to temporarily bump the reference count. Another
advantage is that we only need to bump the reference count when an
animation is finished, whereas before this we bumped it
unconditionally.
2022-03-18 20:00:30 +01:00
Lenny Maiorani
f912a48315 Userland: Change static const variables to static constexpr
`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.

This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
2022-03-18 19:58:57 +01:00
Karol Kosek
a5e149c012 WindowServer: Update menu buttons' rects on font change
Prior to this change, after changing the system font, the menu rects
stayed the same, making the menu bar look a bit cramped on larger fonts.
2022-03-14 22:29:57 +01:00
Karol Kosek
fe47e66438 WindowServer: Use font height for item heights in Menus
The height of menu items was relatively small on larger fonts.
2022-03-14 22:29:57 +01:00
Andreas Kling
5ace66a903 LibGfx: Rename RGBA32 => ARGB32
The ARGB32 typedef is used for 32-bit #AARRGGBB quadruplets. As such,
the name RGBA32 was misleading, so let's call it ARGB32 instead.

Since endianness is a thing, let's not encode any assumptions about byte
order in the name of this type. ARGB32 is basically a "machine word"
of color.
2022-03-04 23:40:21 +01:00
Lenny Maiorani
d5fdc6096c Libraries: Make CharacterBitmap instances at compile-time
`CharacterBitmap` instances are generated at run-time and put on the
heap, but they can be created in a `constexpr` context and stored in
static memory.

Also, remove additional `width` and `height` `static` values in favor
of using the `constexpr` member functions of `CharacterBitmap`.

These changes also include the removal of some initialization code
which tests if the `CharacterBitmap` is created since it is always
created and removes function-local `static` values which cause
run-time branches to ensure it is initialized each time the function
is called.
2022-03-04 17:41:08 +01:00
MacDue
6ff041dcfc WindowServer: Treat window frames with a border radius as transparent
Without this, there are repainting artefacts when the window is moved.
2022-03-02 21:56:57 +01:00
MacDue
c2fcc3a621 WindowServer: Disable shadow rendering for themes with a border-radius
The current shadow renderer only works for purely rectangular windows,
when enabled with border radiuses the corners are wrong.
2022-03-02 21:56:57 +01:00
Itamar
935d023967 Userland: Rename WindowServerConnection=>ConnectionToWindowServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
3a71748e5d Userland: Rename IPC ClientConnection => ConnectionFromClient
This was done with CLion's automatic rename feature and with:
find . -name ClientConnection.h
    | rename 's/ClientConnection\.h/ConnectionFromClient.h/'

find . -name ClientConnection.cpp
    | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
2022-02-25 22:35:12 +01:00
Jan Grau
6992a07afc LibGUI+WindowServer: Add new WMEvent Super+Digit
This adds a keyboard event for Super+0 to Super+9. Later to be consumed
in the taskbar.

Currently only this keyboard sequence is supported:
  - Super key down
  - Digit key down

But not this:
  - Super key down
  - Digit key down
  - Digit key up
  - Digit key down
2022-02-24 18:57:20 +00:00
Tom
97e18a6ce1 WindowServer: Mark window frame as invalidated when updating title
We need to set Window::m_invalidated_frame to true when invalidating
the title, otherwise we may miss re-rendering the frame if nothing
else triggers it.
2022-02-21 20:34:36 -08:00
Marco Cutecchia
8ede1a6a6f WindowServer: Add IPC call to remove a menu's item 2022-02-21 16:31:56 +01:00
Sam Atkins
cd0ffe5460 LibCore+Everywhere: Return ErrorOr from ConfigFile::sync()
Currently this method always succeeds, but that won't be true once we
switch to the Core::Stream API. :^)

Some of these places would ideally show an error message to the user,
since failure to save a file is significant, but let's not get
distracted right now.
2022-02-16 19:49:41 -05:00
Sam Atkins
8260135d4d LibCore+Everywhere: Return ErrorOr from ConfigFile factory methods
I've attempted to handle the errors gracefully where it was clear how to
do so, and simple, but a lot of this was just adding
`release_value_but_fixme_should_propagate_errors()` in places.
2022-02-16 19:49:41 -05:00
James Puleo
e4c182d855 WindowServer: Remove extraneous whitespace in WindowServer.ipc 2022-02-14 16:38:42 +03:30
James Puleo
a0e7a4b9a8 WindowServer+Userland: Pass wallpapers as Gfx::Bitmap instead of path
The WindowServer _really_ does not need to know the filesystem path to
it's wallpaper, and allows setting arbitrary wallpapers (those outside
of `/res/wallpapers`).

The GUI::Desktop will keep track of the path to the wallpaper (if any),
and save it to config if desired (to be persisted).

This avoids the need to `unveil` paths to the wallpaper, fixing #11158
2022-02-14 16:38:42 +03:30
Vitaly Dyachkov
53ff271c6f WindowServer: Consolidate tiled and maximized window rects calculation
Calculating tiled and miximized window frame have a lot in common. In
fact, we can look at maximized window state as a special case of the
tile type. It simplifies the code since there is a lot of cases when
we take an action only if the window is maximized or tiled.
2022-02-14 11:41:06 +01:00
thankyouverycool
1cd77fd1b4 WindowServer: Preserve cursor position when dragging between states
Previously windows would end up in awkward positions relative to
the move cursor when dragging between tile types or unmaximizing.
This feels a bit more ergonomic.
2022-02-08 16:37:46 +01:00
thankyouverycool
ee637b44fb WindowServer: Add Vertically/HorizontallyMaximized WindowTileTypes
VerticallyMaximized tiling replaces set_vertically_maximized() to
take advantage of tiling ergonomics.

Middle-clicking a window's maximize button now tiles vertically;
secondary-clicking tiles horizontally.

Adds Super+Alt+Arrow shortcuts for both. Super+Left/Right tiling
shortcuts now let windows shift between tile types directly.
2022-02-08 16:37:46 +01:00
thankyouverycool
32be05957a WindowServer: Fix comments in WindowManager 2022-02-08 16:37:46 +01:00
thankyouverycool
1607fd511f WindowServer: Unify Window restore rects
Previously, different rects were used to restore tiled and maximized
windows, creating edge cases for inconsistent restoration. All states
now restore m_floating_rect, which saves the last valid size and
location of a window while free-floating.
2022-02-08 16:37:46 +01:00
thankyouverycool
3d7e701451 WindowServer: Rename Window::tiled() => tile_type() and add is_tiled()
This seems more consistent with naming conventions across the system
and makes conditionals easier to read.
2022-02-08 16:37:46 +01:00
Timur Sultanov
c7bd47c87c Base+WindowsServer+keymap: Store multiple keymaps in a config 2022-02-03 00:47:22 +01:00
Timur Sultanov
b9c558f6c6 WindowServer+Keymap+LibGUI: Add widget to display current keymap 2022-02-03 00:47:22 +01:00
Timur Sultanov
68a01f0e27 WindowManager: Basic support for system keymap switching 2022-02-03 00:47:22 +01:00
thankyouverycool
96895cd22c Everywhere: Fully qualify font names by including their slope
Fixes typefaces of the same weight but different slopes being
incorrectly returned for each other by FontDatabase.
2022-02-01 10:06:26 +01:00
networkException
e2df145e14 WindowServer: Allow checking checkable entries in a menu using space 2022-01-29 11:22:02 +01:00
Valtteri Koskivuori
7a537ad08f WindowServer: Rename default_positioned() -> is_default_positioned()
Tiny change, but it really bothered me that this was the only function
not named like the rest.
2022-01-25 23:22:10 +00:00
thankyouverycool
918dfa51a2 WindowServer: Paint menu checkboxes as such instead of as frames
Fixes disabled checkboxes appearing enabled in menus.
2022-01-23 00:30:00 +00:00
Dmitry Petrov
1662213737 Userland: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Dmitry Petrov
d61cc47055 Kernel: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Tom
a9ec0c30eb WindowServer: Pick font with glyphs for digits for ScreenNumberOverlay
We want to make sure we pick a font that has at least glyphs defined
for all the digits that we may need to display.
2022-01-17 02:10:09 +01:00
creator1creeper1
19d9d5bfe1 Everywhere: Mark Vector of mutable references as mutable
The point of a reference type is to behave just like the referred-to
type. So, a Foo& should behave just like a Foo.

In these cases, we had a const Vector. If it was a const Vector of Foo,
iterating over the Vector would only permit taking const references to
the individual Foos.

However, we had a const Vector of Foo&. The behavior should not
change. We should still only be permitted to take const references to
the individual Foos. Otherwise, we would be allowed to mutate the
individual Foos, which would mutate the elements of the const Vector.
This wouldn't modify the stored pointers, but it would modify the
objects that the references refer to. Since references should be
transparent, this should not be legal.

So it should be impossible to get mutable references into a const
Vector. Since we need mutable references in these cases to call the
mutating member functions, we need to mark the Vector as mutable as
well.
2022-01-16 00:38:21 +03:30
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Andreas Kling
611733af0d WindowServer: Don't try to flash menubar in deleted windows
Capture the window weakly when setting up the menubar flash timer.
2022-01-13 16:15:37 +01:00
electrikmilk
983c784a80 Base+WindowServer: Add icon to window menu move action 2022-01-12 10:55:04 +01:00
bugreport0
6c049ea4c4 LibGUI+WindowServer: Flash menubar menu when using a keyboard shortcut
Briefly flash the menubar menu containing the keyboard shortcut action
to give the user immediate visual feedback on their interaction with the
system.
2022-01-09 00:54:46 +01:00
mjz19910
3102d8e160 Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
Tom
857c8850f3 WindowServer: Fix loading MainScreen setting from configuration 2022-01-04 06:31:59 +00:00
bugreport0
99e0b69c0c WindowServer: Tighten pledged promises 2022-01-03 15:56:41 +01:00
networkException
b46ea5158d WindowsServer+LibGUI: Avoid getting color under cursor outside screen
This patch fixes a crash in ColorPicker caused by the ColorSelectOverlay
trying to request the color for a pixel outside the screen rect.
2022-01-01 14:32:11 +01:00
Sam Atkins
fd7163b125 WindowServer: Stop trying to close windows that are already destroyed 2021-12-27 21:27:16 +01:00
Sam Atkins
a330a070d4 WindowServer: Use is_internal() instead of checking if the client exists 2021-12-27 21:27:16 +01:00
Andreas Kling
50e090071c WindowServer: Skip over destroyed windows in WindowSwitcher::draw()
I encountered a WindowServer crash due to null-pointer dereference in
this function, so let's protect against it by simply skipping over
nulled-out WeakPtrs.

I added a FIXME about how we ideally wouldn't be in this situation in
the first place, but that will require some more investigation.
2021-12-25 10:41:06 +01:00
Andreas Kling
6d0f504822 LibIPC: Add IPC::MultiServer convenience class
This encapsulates what our multi-client IPC servers typically do on
startup:

    1. Create a Core::LocalServer
    2. Take over a listening socket file descriptor from SystemServer
    3. Set up an accept handler for incoming connections

IPC::MultiServer does all this for you! All you have to do is provide
the relevant client connection type as a template argument.
2021-12-06 19:22:16 +01:00
Andreas Kling
81047d8f9c LibCore: Make LocalServer::take_over_from_system_server() return ErrorOr
This allows us to use TRY() or MUST() when calling it.
2021-12-06 19:22:16 +01:00
Sam Atkins
d2024f04bd Userland: Cast unused BackgroundAction::construct() results to void
User code does not need to keep this alive, so casting to void is safe.
But maybe a bit weird.
2021-12-05 15:31:03 +01:00
Sam Atkins
92f8514a85 Services: Cast unused IPC::new_client_connection() results to void
These ones all manage their storage internally, whereas the WebContent
and ImageDecoder ones require the caller to manage their lifetime. This
distinction is not obvious to the user without looking through the code,
so an API that makes this clearer would be nice.
2021-12-05 15:31:03 +01:00
Andreas Kling
fe00393941 LibCore: Change Core::LocalServer::on_ready_to_accept => on_accept
Everyone used this hook in the same way: immediately accept() on the
socket and then do something with the newly accepted fd.

This patch simplifies the hook by having LocalServer do the accepting
automatically.
2021-11-30 23:34:40 +01:00
Andreas Kling
cb9cac4e40 LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>
This allows us to use TRY() in decoding helpers, leading to a nice
reduction in line count.
2021-11-28 23:14:19 +01:00
Andreas Kling
8d76eb773f LibIPC: Make IPC::Connection::post_message() return ErrorOr 2021-11-28 23:14:18 +01:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00
Karol Kosek
65f3a259d2 WindowServer: Clear wallpaper if the requested path is empty
235f39e449 secretly added an if check that ignores all the files that
couldn't be loaded into bitmaps.  Unfortunately, we send an empty path
as a way to unset the wallpaper, which meant that we couldn't go back
to the default background color anymore.
2021-11-26 11:30:55 -08:00
Andreas Kling
21a5fb0fa2 LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().

Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
2021-11-23 11:33:36 +01:00
Andreas Kling
9cf874ef9a WindowServer: Port to LibMain :^)
This simplifies some pledge(), unveil() and sigaction() calls.
2021-11-22 23:52:47 +01:00
Andreas Kling
9387271049 Everywhere: Fix spelling of "offsetted"
This word is actually pretty awkward in context, but this patch merely
fixes the spelling instead of finding a better word.
2021-11-21 20:22:48 +01:00
Andreas Kling
7e5b22333e WindowServer: Make window switcher look more like other overlays
Render the window switcher with the same background and shadow as other
WindowServer overlays.

Note that we don't actually render it as a WindowServer::Overlay, as the
window switcher uses mouse and keyboard events, and there's currently
no way for an overlay to receive events.
2021-11-14 12:23:04 +01:00
Andreas Kling
7fb2540ffe WindowServer: Clear window switcher's hovered item when cursor leaves
When the mouse cursor leaves the switcher window, we'll want to clear
the hovered item index so it stops showing as hovered. :^)
2021-11-14 12:23:04 +01:00
Andreas Kling
6f80d91850 WindowServer: Reset the window switcher's hovered item between uses
Before this, the last hovered item would still appear hovered when
bringing up the window switcher after having dismissed it.
2021-11-14 12:23:04 +01:00
Andreas Kling
9f7f7e69bb WindowServer: Allow server-internal windows with alpha channel
We were not creating backing stores with alpha for server-internal
windows. There was no reason for this limitation.
2021-11-14 12:23:04 +01:00
Andreas Kling
583fbf7111 WindowServer: Make WindowFrame::shadow_bitmap() const
There is no reason for callers to mutate the shadow bitmaps returned by
this function.
2021-11-14 12:23:04 +01:00
Andreas Kling
a8fed919e7 WindowServer: Clear active input tracking window on menu popup
This fixes an issue with menus not being immediately "usable" with the
the right mouse button after opening a context menu.

The bug was that we were clearing a local pointer to the active input
tracking window instead of the pointer in WindowStack.
2021-11-13 12:48:43 +01:00
Andreas Kling
68dc2e62fb WindowServer: Replace "Pin/Unpin Window" => "Always on Top" 2021-11-13 12:48:43 +01:00
Andreas Kling
d21dc1f451 Everywhere: Replace "virtual desktop" => "workspace" 2021-11-13 12:48:43 +01:00
Tom
32d59257d6 WindowServer: Ensure menu visibility after pushing menu to the stack
We need to make sure the menu was pushed to the open menu stack before
calling set_visible, as this may trigger cursor re-evaluation, which
in turn expects the menu to be considered open.

Fixes #10836
2021-11-13 00:38:36 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Andreas Kling
8262bbf624 LibGfx: Use ErrorOr<T> for Bitmap::cropped() 2021-11-08 00:35:27 +01:00
Andreas Kling
83d1460ee8 LibGfx: Use ErrorOr<T> for Bitmap::try_create_wrapper() 2021-11-08 00:35:27 +01:00
Andreas Kling
f23f99d51b LibGfx: Use ErrorOr<T> for Bitmap::try_create_with_anonymous_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
e2eabb4132 LibCore: Use ErrorOr<T> in Core::AnonymousBuffer 2021-11-08 00:35:27 +01:00
Simon Woertz
727cdcf82c Revert "WindowServer: Remove redundant Window::set_visible()..."
This reverts commit 239520ae54.

The call to set_visible() is not redundant. Removing the call leads
to the "start" button in the taskbar not being painted as "pressed" even
when it is.
2021-11-07 00:49:48 +01:00
Andreas Kling
7a1a8d267d WindowServer: Add menus to open menu stack before making them visible
This prevents an issue where the first mouse event in a newly opened
would not get handled because we didn't think the menu was open yet.
2021-11-05 01:37:00 +01:00
Andreas Kling
239520ae54 WindowServer: Remove redundant Window::set_visible() in Menu::do_popup()
We're already calling MenuManager::open_menu(), which will take care of
making the menu window visible if needed.
2021-11-05 01:37:00 +01:00
Andreas Kling
5f8c949ea1 WindowServer: Remove redundant check in MenuManager::open_menu()
We've already returned early if the menu is open, so there's no need to
verify that it isn't present in the stack of open menus before pushing
it onto said stack.
2021-11-05 01:37:00 +01:00
Aziz Berkay Yesilyurt
bfb36fec89 WindowServer: Return ShareableBitmap() on fail
WindowServer returns {} on non-existing screen index,
however shot program hangs instead of retriving an empty
ShareableBitmap. With this change, the function returns an empty
ShareableBitmap and shot exits gracefully.
2021-11-05 00:10:23 +01:00
Andreas Kling
f7f6526082 WindowServer: Reevaluate hover state after dismissing window switcher
This makes the cursor update properly if it was above the window
switcher while it was visible, and something underneath it wants to use
something other than the default arrow cursor.
2021-11-04 16:10:40 +01:00
Andreas Kling
6c64721955 WindowServer: Reevaluate hover state when switching highlight windows
This makes the mouse cursor update nicely when another window is brought
directly under it by using the window switcher. :^)
2021-11-04 16:10:40 +01:00
Andreas Kling
dd8a459a1f WindowServer: Rename reevaluate_hovered_window()
...to reevaluate_hover_state_for_window(). This name is not super great
either, but at least it doesn't sound like the window is necessarily
currently being hovered.
2021-11-04 16:10:40 +01:00
sin-ack
edb3e71c1b WindowServer: Add missing window_was_constructed call
In 2e6bb987a3 the "did_construct" API in
Core::Object was removed, since it had only one user. For a replacement,
the Window would manually call the frame's "frame_was_constructed"
method. However, WindowServer::Window has two constructors, and only one
of them called this method. This caused windows to spawn without
buttons and various other breakage that spawned from this.
2021-11-03 09:05:09 +01:00
Ben Wiederhake
0e3397aabe WindowServer: Fix visibility of WindowSwitcher constructor
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.

This commit is separate from the other Servives changes because it
required additional adaption of the code. Note that the old code did
precisely what these changes try to prevent: Create and handle a
ref-counted object with a refcount of zero.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
4e55d649d7 Services: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
2e6bb987a3 AK+WindowServer: Remove did_construct() framework used only once
There is also make_ref_counted(), which does not call did_construct(),
so the method was not guaranteed to be run. Since there is only a single
user, and `WindowServer::Window` is a final class anyway (so there is no
need to separate the constructor and post-constructor phases), let's get
rid of this concept.

(The following commits reduce the opportunities to call
make_ref_counted, but still.)
2021-11-02 22:56:53 +01:00
Ben Wiederhake
59619572d6 LibThreading: Remove redundant method 2021-11-02 11:07:26 +01:00
Marco Cutecchia
7653be6062 WindowServer: Remove some commented code in WindowManager.cpp 2021-10-31 12:37:49 +01:00
Sam Atkins
885ca2f968 LibGfx+WindowServer: Move shadow-painting code to StylePainter
Specifically, this is to make it accessible to ThemeEditor, but there's
nothing about it that is especially window-specific.
2021-10-28 11:23:44 +02:00
Filiph Sandström
c6247fe414 Everywhere: Rename back-click to backward-click
This matches the current forward-click terminology.
2021-10-27 22:05:58 +03:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Liav A
8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Andreas Kling
fac6d220c3 WindowServer: Don't re-open screen device immediately after opening it
The Screen constructor already calls open_device(), so there's no need
to call it again right after creating a new Screen in apply_layout().

This makes the first screen compose happen ~50ms earlier on my machine.
2021-10-26 01:00:54 +02:00
Andreas Kling
693423bbe8 WindowServer: Remove Screen::init()
This function only did one thing: call Screen::set_resolution().
We always call that function when opening the underlying device anyway,
so this was completely redundant.

This makes the first screen compose happen ~60ms earlier on my machine.
2021-10-26 01:00:54 +02:00
Andrew Pardoe
0e68550c05 MouseSettings: Add option to reverse buttons
Add option to reverse primary and secondary buttons in Mouse Settings.
- WindowServer.ini: add default entry
- switch-mouse-buttons.png: new icon for settings entry
- Mouse.gml/MouseWidget.*: new settings dialog
- ClientConnection/WindowManager/Server: window message for settings
- EventLoop.cpp: swap buttons 1 and 2 if settings are on
2021-10-25 19:20:33 +03:00
Jelle Raaijmakers
40a0a995af WindowServer: Prevent sending duplicate MousePackets when clicking
If a mouse button was clicked, `EventLoop::drain_mouse()` would always
send the last MousePacket state to the screen input - even if that
state is equivalent to the last state sent as part of the button logic.

By remembering if the state was already sent, we prevent sending that
state a second time saving some resources in the process.
2021-10-24 22:00:34 +02:00
Jelle Raaijmakers
38b09ba133 WindowServer: Deduplicate code for mouse Z state in EventLoop 2021-10-24 22:00:34 +02:00
Jelle Raaijmakers
bbaf8e3b70 WindowServer: Simplify mouse button handling logic in EventLoop
The `buttons` variable is a bit superfluous here.
2021-10-24 22:00:34 +02:00
Timothy Flynn
857cac6d1d WindowServer: Support displaying window titles when there are no buttons
Currently, if there are not titlebar buttons, we fail to paint the title
because we treat the leftmost titlebar button as the empty rect. We will
now use the rightmost edge of the titlebar when there are no buttons.
2021-10-22 14:46:08 +01:00
Andreas Kling
09b08d8e35 WindowServer: Re-evaluate hover state when active window changes
This effectively makes us send a "mouse move" event to windows when they
become active, even if the mouse didn't actually move. By doing this, we
trigger hover/tooltip/etc logic immediately, instead of doing it on the
next 1px mouse movement.

It's a small detail but my goodness does it feel better this way. :^)
2021-10-22 13:22:09 +02:00
Timothy Flynn
176155c695 LibGUI+WindowServer: Add option to hide a widow's close button
This allows windows to be closed only programatically, and not from e.g.
the user clicking the X button on the window frame.
2021-10-21 14:45:30 +01:00
David Isaksson
f261b68408 WindowServer: Apply screen scaling when getting bitmap around cursor
This fixes an issue for the magnifier that when the screen scaling is
increased to 2 the magnifier doesn't center around the cursor.

Since booting Serenity with multiple displays doesn't work at the moment
the rescaling is only added for the one display case.
2021-09-20 22:25:24 +02:00
Idan Horowitz
6704961c82 AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.

As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
2021-09-11 20:36:43 +03:00
Mustafa Quraish
69d708fb21 WindowServer: Add IPC endpoint to get the color under cursor
This allows any client to ask the WindowServer to give it the color
of the screen bitmap under the cursor.

There's currently no way to get the screen bitmap *without* the
cursor already drawn on it, so for now we just take a pixel
beside the actual cursor position to avoid just getting the cursors
color.
2021-09-11 19:05:46 +02:00
Mustafa Quraish
3da4fdd0eb Compositor: Add API to get the color of a pixel
This just returns the color of a given pixel position from the
front bitmap of the corresponding screen.
2021-09-11 19:05:46 +02:00
Ben Wiederhake
7684e4f726 WindowServer: Fix 'sticky' mouse after resize
This fixes #9933 and some dead code I accidentally left over.
Thanks, @Maato!
2021-09-10 22:09:23 +02:00
Ali Mohammad Pur
5a0cdb15b0 AK+Everywhere: Reduce the number of template parameters of IntrusiveList
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Ben Wiederhake
c6e56612f5 LibGUI+WindowServer: Remove now-obsolete cursor tracking feature
This feature was problematic for several reasons:
- Tracking *all* the user activity seems like a privacy nightmare.
- LibGUI actually only supports one globally tracking widget per window,
  even if no window is necessary, or if multiple callbacks are desired.
- Widgets can easily get confused whether an event is actually directed
  at it, or is actually just the result of global tracking.

The third item caused an issue where right-clicking CatDog opened two
context menus instead of one.
2021-09-08 10:53:49 +02:00
Ben Wiederhake
45126655cd LibGUI+WindowServer: Introduce new mouse tracking mechanism 2021-09-08 10:53:49 +02:00
Mustafa Quraish
30e91ecff6 Cursors: Add new Magnifying glass cursor
There are a few places in the system where this could be useful,
such as PixelPaint and the MandelBrot demo. It seems general enough
that it is probably useful to have it as a system-wide cursor rather
than loading it manually each time.
2021-09-04 03:35:23 +02:00
Mustafa Quraish
30ce1d8562 Cursors: Add new Eyedropper cursor
This can be used immediately in PixelPaint (separate commit), but
I am adding this as a system-wide cursor since it may also be useful
for other applications that want to use it.
2021-09-04 03:35:23 +02:00
sin-ack
8ea22121ac Userland: Migrate to argument-less deferred_invoke
Only one place used this argument and it was to hold on to a strong ref
for the object. Since we already do that now, there's no need to keep
this argument around since this can be easily captured.

This commit contains no changes.
2021-09-02 03:47:47 +04:30
Joe Bentley
9df79a77da WindowServer: Add message to notify clients of applet area resize
Applets and windows would like to be able to know when the applet
area has been resized. For example, this happens asynchronously after
an applet has been resized, so we cannot then rely on the applet area
position synchronously after resizing. This adds a new message
applet_area_rect_changed and associated Event AppletAreaRectChange,
and the appropriate virtual functions.
2021-08-31 16:49:22 +02:00
Andreas Kling
087bd7f767 Userland: Use Rect::centered_within() where useful 2021-08-31 01:35:08 +02:00
Mustafa Quraish
5f23958abd WindowServer: Always return properly cropped bitmap
Previously, when `screen_index` was not provided when calling
`ClientConnection::get_screen_bitmap`, the bitmap that was created
was always the size of the bounding rect of the screen. The actual
screen bitmap was being cropped, but the bitmap being returned was
of the original size with just black pixels everywhere else.
2021-08-28 08:18:41 +01:00
Maciej Zygmanowski
3597b6eb9d WindowServer+LibGfx: Move CursorParams to LibGfx
They will be used by MouseSettings in the next commit.
2021-08-23 01:41:53 +02:00
Maciej Zygmanowski
0363cd3d55 WindowServer: Add IPC calls for controlling cursor theme
This commit adds two new IPC calls for WindowServer: apply_cursor_theme
and get_cursor_theme.
2021-08-23 01:41:53 +02:00
Maciej Zygmanowski
040a723f1f WindowServer: Add support for cursor themes
Now you can specify a CursorTheme key in /etc/WindowServer.ini. The
cursors are loaded from /res/cursor-themes/<name> directory. This
directory contains a Config.ini file with format similar to previous
Cursor section, except it uses relative paths.

This commit adds also Default theme, which uses cursors being
previously in /res/cursors.

The WidgetGallery is updated to match the new cursor path format.
2021-08-23 01:41:53 +02:00
networkException
938051feb8 Everywhere: Use Core::ConfigFile::AllowWriting::Yes to allow writing 2021-08-22 01:32:25 +02:00
sin-ack
705e5a3d87 WindowServer: Only clear the hovered item if the item was enabled
Otherwise, we emit a menu_item_left to the WindowServer client even
though the mouse never left the menu item (as is the case when a
disabled menu item is clicked).
2021-08-19 00:11:42 +02:00
Daniel Bertalan
f94532ea4e WindowServer: Fix Clang crash when compiling Compositor.cpp
Due to a bug in Clang 12, the compilation would fail with an 'unexpected
end-of-file' error when it encounters some of the nested generic lambdas
in `Compositor.cpp`.

Co-authored-by: Peter Bindels <dascandy@gmail.com>
2021-08-08 10:55:36 +02:00