Commit Graph

238 Commits

Author SHA1 Message Date
Andreas Kling
d924d93fa2 WindowServer: Fix unnecessary local variable shadowing in WindowFrame 2021-06-16 21:53:10 +02:00
Brian Gianforcaro
8f1e7c5a72 WindowServer: Remove unused AK::InlineLinkedList header includes 2021-06-16 10:40:01 +02:00
Sreelakshmi
aa68c12cfc WindowManager: Close tooltip child_windows of previously active window
This closes the autocomplete_box used in applications like GML
Playground and HackStudio when the user switches focus to a new window.
2021-06-12 23:54:08 +04:30
Andreas Kling
0a98964600 WindowServer+LibGUI: Make window creation asynchronous :^)
Let clients manage their own window ID's. If you try to create a new
window with an existing ID, WindowServer will simply disconnect you
for misbehaving.

This removes the need for window creation to be synchronous, which
means that most GUI applications can now batch their entire GUI
initialization sequence without having to block waiting for responses.
2021-06-12 12:01:54 +02:00
Marcus Nilsson
2f7dc29ab7 LibGUI/WindowServer: Add set_maximized IPC call
Add an IPC call to enable the client to manually maximize it's own
window.
2021-06-09 22:58:10 +02:00
Ali Mohammad Pur
7ac196974d Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&> 2021-06-08 19:14:24 +02:00
Andreas Kling
cb295ab644 WindowServer+Magnifier: Make Magnifier buttery smooth :^)
This patch moves the magnifier rect computation over to the server side
to ensure that the mouse cursor position and the screen image never get
out of sync.
2021-06-07 10:22:25 +02:00
Eugene Barnett
4ef85de9dc WindowServer: Add a GetDesktopDisplayScale IPC request
Tells you which scale factor is configured in window manager.
2021-06-06 15:56:43 +02:00
Tom
2c8309c841 WindowServer: Simplify determining transparent/opaque occlusions
By moving the logic to determine what window areas (shadow, frame,
content) into WindowFrame::opaque/transparent_render_rects we can
simplify the occlusion calculation and properly handle more
arbitrary opaque/transparent areas.

This also solves the problem where we would render the entire
window frame as transparency only because the frame had a window
shadow.
2021-06-06 09:37:27 +01:00
Max Wipfli
bc8d16ad28 Everywhere: Replace ctype.h to avoid narrowing conversions
This replaces ctype.h with CharacterType.h everywhere I could find
issues with narrowing conversions. While using it will probably make
sense almost everywhere in the future, the most critical places should
have been addressed.
2021-06-03 13:31:46 +02:00
Brian Gianforcaro
d0dbb014a0 WindowServer: Switch Window to IntrusiveList from InlineLinkedList
Another small step towards unifying IntrusiveList / InlineLinkedList.
2021-06-03 13:27:40 +02:00
Matthew Jones
0ff09d4f74 WindowServer: Add sanity checks to create_window IPC 2021-06-03 08:27:57 +02:00
Matthew Jones
b0682a73ee WindowServer: Position popup menu with offset of 1 pixel 2021-06-03 08:21:01 +02:00
Matthew Jones
ea4116f5bd LibGUI+LibGfx+WindowServer: Sanity check window size dimensions
Previous to this commit, if a `Window` wanted to set its width or height
greater than `INT16_MAX` (32768), both the application owning the Window
and the WindowServer would crash.

The root of this issue is that `size_would_overflow` check in `Bitmap`
has checks for `INT16_MAX`, and `Window.cpp:786` that is called by
`Gfx::Bitmap::create_with_anonymous_buffer` would get null back, then
causing a chain of events resulting in crashes.

Crashes can still occur but with `VERIFY` and `did_misbehave` the
causes of the crash can be more readily identified.
2021-06-02 23:59:57 +01:00
Gunnar Beutner
b5778675a5 WindowServer: Use RefPtr instead of raw pointers
Now that we have static initializers and destructors we can use
RefPtr here.
2021-06-02 18:08:11 +02:00
Gunnar Beutner
cdb070cdfb WindowServer: Don't crash when we can't allocate a bitmap
When the client specifies an absurdly large window size
render_to_cache() fails to allocate a bitmap and crashes.

Refs #7688.
2021-06-02 10:17:42 +01:00
Matthew Jones
33eb9a6ddc WindowServer: Use user-defined background color, if defined
Use the configured desktop background color, if defined, otherwise
default to the current theme's background color. If a user chooses
a background color via "desktop settings", then this new color
will always be used.

Switching themes will delete the user-defined background color, so
the background color resets to the theme's defined color.
2021-06-02 09:40:53 +02:00
Jean-Baptiste Boric
e4394b1605 LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::Bitmap
Instead of using a low-level, proprietary API inside LibGfx, let's use
Core::AnonymousBuffer which already abstracts anon_fd and offers a
higher-level API too.
2021-05-24 13:31:01 +02:00
Andreas Kling
c9e849a968 LibCore: Make all processes opt out of InspectorServer by default
This functionality, while neat, isn't really something you need enabled
all the time. Let's make it opt-in instead. Pass MakeInspectable::Yes
to the Core::EventLoop constructor if you want your program to become
inspectable.
2021-05-22 23:30:40 +02:00
Andreas Kling
b5d73c834f Userland: Rename LibThread => LibThreading
Also rename the "LibThread" namespace to "Threading"
2021-05-22 18:54:22 +02:00
Andreas Kling
636c43db6c WindowServer: Notify window-less clients about theme/font changes 2021-05-22 10:21:52 +02:00
Andreas Kling
59fd1f40ce WindowServer: Store system font queries in WindowServer.ini :^)
Changes to the system font settings are now persisted in /etc.
Note that you still need to restart the system for changes to fully
apply in all programs.
2021-05-21 20:15:51 +02:00
Andreas Kling
c778130d63 WindowServer+LibGUI: Add an IPC API to change the current system fonts
This patch adds a set_system_fonts() IPC API that takes the two main
font queries as parameters. We'll probably expand this with additional
queries when we figure out what they should be.

Note that changing the system fonts on a live system mostly takes
effect in newly launched programs. This is because GUI::Widget will
currently cache a pointer to the Gfx::FontDatabase::default_font()
when first constructed. This is something we'll have to fix somehow.

Also note that the settings are not yet persisted.
2021-05-21 20:15:51 +02:00
Andreas Kling
bb23e61fbf LibGfx+WindowServer: Have WindowServer broadcast system font settings
Instead of everybody getting their system fonts from Gfx::FontDatabase
(where it's all hardcoded), they now get it from WindowServer.

These are then plumbed into the usual Gfx::FontDatabase places so that
the old default_font() and default_fixed_width_font() APIs keep working.
2021-05-21 20:15:51 +02:00
Linus Groh
d60ebbbba6 Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96.

Booting the system no longer worked after these changes.
2021-05-21 10:30:52 +01:00
Lenny Maiorani
800ea8ea96 Userland: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-21 10:07:06 +01:00
Andreas Kling
ec8363aec3 WindowServer+LibGUI: Make client/server greeting faster
Instead of doing a full IPC round-trip for the client and server to
greet each other upon connecting, the server now automatically sends
a "fast_greet" message when a client connects.

The client simply waits for that message to arrive before proceeding.
(Waiting is necessary since LibGUI relies on the palette information
included in the greeting.)
2021-05-20 22:12:42 +02:00
Andreas Kling
6a012ad79f LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
2021-05-20 20:55:29 +02:00
Andreas Kling
93ef661914 WindowServer+DisplaySettings: Remove the weird "simple" wallpaper mode
Painting the wallpaper at 100% scale in the top left corner is a weird
mode and I don't think we need it. :^)
2021-05-20 17:52:38 +02:00
Andreas Kling
5f342c41b9 WindowServer: Don't attempt to make WindowServer inspectable 2021-05-17 23:32:37 +02:00
Andreas Kling
5d0c3bd564 WindowServer: Add Menu::is_open() to improve readability
"menu.is_open()" instead of "MenuManager::the().is_open(menu)"
2021-05-17 23:28:15 +02:00
Andreas Kling
7e799529b9 WindowServer+LibGUI: Make menubar allocation asynchronous
Same as with menu allocation, move menubar ID management to the client
side, removing more IPC stalls during application startup.
2021-05-17 13:33:41 +02:00
Andreas Kling
baab0a5bef WindowServer+LibGUI: Make menu allocation asynchronous
This was only synchronous since WindowServer managed the ID allocation.
Doing this on the client side instead allows us to make create_menu()
an asynchronous IPC call, removing a bunch of IPC stalls during
application startup.
2021-05-17 13:33:41 +02:00
Andreas Kling
2083d1a3d6 WindowServer: Ignore window base size in aspect ratio enforcement
This makes windows with an aspect ratio behave more naturally if they
also have a base size (e.g from the main widget being a GUI::Frame.)
2021-05-17 12:01:17 +02:00
Andreas Kling
31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Linus Groh
9a27ef6523 WindowServer: Re-render window frame when setting unresponsive status
Otherwise "(not responding)" would not appear in the window title until
the window is moved/resized.
2021-05-12 22:51:56 +01:00
Valtteri Koskivuori
4864ef9440 WindowServer: Add Optional<Gfx::IntRect> argument to get_screen_bitmap()
This way, we can optionally specify a region of the display to capture.
Defaults to entire screen if no rectangle is given.
2021-05-11 10:18:29 +01:00
Andreas Kling
bfeacb5728 WindowServer+Taskbar: Make all the IPC used by Taskbar asynchronous 2021-05-10 12:26:35 +02:00
Andreas Kling
11dc790d69 WindowServer: Make set_background_color and set_wallpaper_mode async
Both of these were already used asynchonrously by GUI::Desktop.
2021-05-10 12:21:42 +02:00
Andreas Kling
b8411d1ef6 WindowServer: Make dismiss_menu() an asynchronous IPC call
This was already being used asynchronously by LibGUI, which meant that
WindowServer would generate a response, and the client would ignore it.
2021-05-10 12:20:28 +02:00
Andreas Kling
f556bd1045 WindowServer: Make popup_menu() an asynchronous IPC call
This was already being used asynchronously by LibGUI, which meant that
WindowServer would generate a response, and the client would ignore it.

This patch simplifies the WindowServer side so it no longer generates
the unnecessary response.
2021-05-10 12:20:28 +02:00
Andreas Kling
8684fca9df WindowServer+LibGUI: Make "move window to front" asynchronous 2021-05-10 12:20:28 +02:00
Andreas Kling
fb93535419 WindowServer+LibGUI: Make menu and menubar teardown asynchronous
Clients don't need to wait for WindowServer to tear down a menu or
menubar before continuing.
2021-05-10 11:53:26 +02:00
Andreas Kling
634e652b6c WindowServer: Add "Move" action to window menus
This can be used to initiate a window move. It's only enabled while
the window is normal (not minimized, maximized or fullscreen.)
2021-05-10 09:06:37 +02:00
Andreas Kling
2bc3cc4cab WindowServer: Add separator above "Close" in window menus 2021-05-10 08:43:44 +02:00
Andreas Kling
353a831c8c WindowServer: Compute final window title before passing to WM clients
We were not substituting the window modified marker ("[*]") in the
title strings we were sending to WM clients. This caused the Taskbar
to show pre-substitution window titles for the Text Editor application.

This patch moves the window title resolution to Window::compute_title()
which is then used throughout.
2021-05-10 00:02:05 +02:00
Andreas Kling
1f24ab91f2 WindowServer: Notify WM clients when a window's modified state changes
Also update the window switcher for good measure. The window switcher
doesn't visualize this information at the moment, but we generally do
this when any window state changes.
2021-05-09 23:59:35 +02:00
Andreas Kling
a47d576e94 WindowServer: Tweak width/height of automatic window tile rects
The resulting window rects when snapping to some edges/corners were
a bit lopsided. This patch makes them symmetrical. :^)
2021-05-09 21:48:38 +02:00
Andreas Kling
5497b7a718 WindowServer: Tweak spacing above maximized windows
Nudge maximized windows 1px upwards. This prevents the outer window
border from showing up above the title bar.
2021-05-09 21:48:38 +02:00
Andreas Kling
5aa9f128fc WindowServer: Simplify the way we update items in the window menu
Instead of trying to update only the little bit that changes, let's
have a function that updates all the window menu items in one go.

It's just a couple of string and boolean assignment, and the real
cost is performing the subsequent menu redraw, which remains the same.
2021-05-09 21:48:38 +02:00