Commit Graph

485 Commits

Author SHA1 Message Date
Andreas Kling
fa9846ec6f WindowServer: Simplify how we determine the hovered window
Instead of plumbing a Window* through the entire mouse event processing
logic, just do a hit test and say that the window under the cursor is
the hovered window.

It's funny how much easier this is now that we have a way to hit test
the entire window stack with one call.
2021-06-18 17:40:05 +02:00
Andreas Kling
7b3fdd178e WindowServer: Simplify processing of window-specific mouse events
Move the logic for processing a mouse event that hits a specific window
into its own function.

If the window is blocked by a modal child, we now get that out of the
way first, so we don't have to think about it later.
2021-06-18 17:40:05 +02:00
Andreas Kling
2f9e8a982c WindowServer: Unify hit testing between fullscreen/regular windows
Even if a window is in fullscreen mode, we still want hit testing to
walk the window stack. Otherwise child windows of the fullscreen
window will not receive mouse events.
2021-06-18 17:40:05 +02:00
Andreas Kling
09dacf4cd1 WindowServer: Move titlebar button mouse event handling to a function
The button widgets internally rendered by WindowServer are only used
in titlebars, and require a bit of mouse event handling. Instead of
mixing it with the window-oriented mouse event handling, get the
button event stuff out of the way first.
2021-06-18 17:40:05 +02:00
Andreas Kling
5d73e16edf WindowServer: Make deliver_mouse_event() perform coordinate translation
Instead of expecting callers to provide a window-relative position,
just take care of it inside deliver_mouse_event() instead.
2021-06-18 17:40:05 +02:00
Andreas Kling
300711d013 WindowServer: Preserve all members in MouseEvent::translated()
We were forgetting to preserve the m_drag and m_mime_data members of
WindowServer::MouseEvent when making a translated copy.

This didn't affect any reachable code paths before this change.
2021-06-18 17:40:05 +02:00
Andreas Kling
58823c474e WindowServer: Don't let super key open system menu while tracking input
Previously it was possible to open the system menu while tracking mouse
input after a mousedown event.
2021-06-18 17:40:05 +02:00
Andreas Kling
82a945fa7e WindowServer: Always send mouse events to active input tracker first
If a window is currently actively tracking input events (because
sent it a MouseDown and haven't sent it a MouseUp yet), we now simply
send mouse events to that window right away before doing any other
event processing.

This makes it much easier to reason about mouse events.
2021-06-18 17:40:05 +02:00
Andreas Kling
69dad3b996 WindowServer: Remove an unnecessary temporary variable 2021-06-18 17:40:05 +02:00
Andreas Kling
ad828b3cfc WindowServer: Split up WindowFrame::handle_mouse_event()
Break this function into a couple of smaller functions, one for each
of these areas:

- The titlebar
- The titlebar icon
- The menubar
- The border
2021-06-18 17:40:05 +02:00
Andreas Kling
f88361fc28 WindowServer: Add WindowStack::window_at() and use it a bunch
This performs a hit test on the window stack to find the window under
a given cursor position.
2021-06-18 17:40:05 +02:00
Andreas Kling
4133caba78 WindowServer: Make hit test results richer
Instead of just answering hit/no-hit when hit testing windows, we now
return a HitTestResult object which tells you which window was hit,
where it was hit, and whether you hit the frame or the content.
2021-06-18 17:40:05 +02:00
Andreas Kling
370d3749e5 WindowServer: Remove weird feature where Ctrl+Wheel changed opacity
This feature had been there since early on and was not actually useful
for anything. I just added it because it was fun. In retrospect, it's
not a very good feature and I only ever activated it by accident.
2021-06-18 17:40:05 +02:00
Andreas Kling
e4e94cd43d WindowServer: Allow each WindowStack to have an active window
A window with an inner stack needs to keep track of which inner window
is active.
2021-06-18 17:40:05 +02:00
Andreas Kling
2b0e0b602c WindowServer: Keep track of which WindowStack a Window is part of
Each Window now knows which WindowStack it's part of. We call this the
Window::outer_stack(), in preparation for supporting inner stacks. :^)
2021-06-18 17:40:05 +02:00
Andreas Kling
d0bc3d6002 WindowServer: Convert WindowManager to east-const style 2021-06-18 17:40:05 +02:00
Andreas Kling
d257f58306 WindowServer: Add WindowStack concept
This patch moves the window stack out of WindowManager and into its own
WindowStack class.

A WindowStack is an ordered list of windows with an optional highlight
window. The highlight window mechanism is used during Super+Tab window
switching to temporarily bring a window to the front.

This is mostly mechanical, just moving the code to its own class.
2021-06-18 17:40:05 +02:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Gunnar Beutner
0ca5a393d1 SystemServer: Improve error message when execv() fails
Previously perror() would just tell us that the file specified
for execv() doesn't exist.
2021-06-17 11:03:51 +02:00
Andreas Kling
88b168ff16 WindowServer: Simplify WindowFrame shadow logic a little bit
Remove the confusingly-named inflate_for_shadow() function and inline
its logic into render_to_cache(). And remove the m_shadow_offset
member variable since it was only needed locally in one place.

Also improve some variable names to make it more understandable what
is going on.
2021-06-16 21:53:10 +02:00
Andreas Kling
d924d93fa2 WindowServer: Fix unnecessary local variable shadowing in WindowFrame 2021-06-16 21:53:10 +02:00
Gunnar Beutner
f589acaac9 AudioServer: Put the m_zero_filled_buffer variable into the .bss segment
This way we don't have to allocate this at runtime. I'm intentionally
not using static constexpr here because that would put the variable
into the .rodata segment and would therefore increase the binary by
4kB.

The old code also failed to free() the buffer in the destructor, however
that wasn't much of an issue because the Mixer object exists throughout
the program's entire lifetime.
2021-06-16 20:07:37 +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
dc65f54c06 AK: Rename Vector::append(Vector) => Vector::extend(Vector)
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
2021-06-12 13:24:45 +02:00
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
Max Wipfli
79a47d9bd3 WebServer: Add support for HTTP basic authentication
This enables the WebServer to run protected by a username and password.
While it isn't possible to access such a protected server from inside
Serenity as of now (because neither the Browser nor pro(1) support
this), this may very well be the case in the future. :^)
2021-06-11 11:37:15 +02:00
Max Wipfli
e77ca79897 WebServer: Move server configuration into WebServer::Configuration
This moves the configuration of the web server, which currently only
consists of the root path, into a new class, Configuration. Since the
configuration is global and not per client, it is accessed by a
singleton getter.

This change simplifies future extensions of the configurable parameters.
2021-06-11 11:37:15 +02:00
Max Wipfli
2d18d3f329 WebServer: Use canonical reasons phrases for error responses
This changes the Client::set_error_response() to not take a "message"
anymore. It now uses the canonical reason phrase which is derived from
the response code.
2021-06-11 11:37:15 +02:00
Max Wipfli
977b3509f2 WebServer: Sort entries in directory listing 2021-06-11 11:37:15 +02:00
Max Wipfli
2c5a8462ec WebServer: Append trailing slash for directory links
This adds trailing slashes to all links to directories (when listing the
directory contents). This avoids the redirect that would otherwise
happen when browsing to those directories.
2021-06-11 11:37:15 +02:00
Max Wipfli
e4f3a5fe37 WebServer: Make ".." equal to "." in server root directory
In the web server root directory, ".." has to be handled specially,
since everything above it does not exist from the point of view of the
user. The most sensible thing to do is to make ".." equal to ".". This
is also what ls(1) does for "/" and what "http://localhost/../"
evaluates to.

This also fixes a bug where stat() would fail on the directory above the
root directory, since it hasn't been unveiled for the process.
2021-06-11 11:37:15 +02:00
Max Wipfli
450a24c8c9 WebServer: Refuse to respond to requests for device files
Responding with some device files such as /dev/random never terminates,
so let's just refuse that.
2021-06-11 11:37:15 +02:00
Max Wipfli
eb6adbabef WebServer: Use outln() instead of printf() 2021-06-11 11:37:15 +02:00
Max Wipfli
6e6ff844d3 WebServer: Defer invocation of Client::remove_from_parent()
This is necessary to avoid trying to destruct the on_ready_to_read
function from inside the function. This fixes #7810.
2021-06-11 11:37:15 +02:00
Max Wipfli
5408111aff WebServer: Use east const style in Client.{cpp,h}
This also removes two unused headers.
2021-06-11 11:37:15 +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
Max Wipfli
4efccbd030 LookupServer: Watch /etc/hosts for changes during runtime
This adds a FileWatcher to the LookupServer which watches '/etc/hosts'
for changes during runtime and reloads its contents. If the file is
deleted, m_etc_hosts will be cleared.

Since we now need to access '/etc/hosts' later during runtime, it needs
to be unveiled with read permissions.
2021-06-09 17:43:32 +04:30
Max Wipfli
7b39db3bf4 LookupServer: Check for hostname after /etc/hosts
If the hostname is not in /etc/hosts, looking it up should return
127.0.0.1.
2021-06-09 17:43:32 +04:30
Max Wipfli
12feb79cef LookupServer: Make DNSName::operator== ignore case 2021-06-09 17:43:32 +04:30
Max Wipfli
95d4d36b5c LookupServer: Modernize load_etc_hosts()
This reworks the LookupServer::load_etc_hosts() method to use the
IPv4Address APIs instead of trying to parse an IPv4 address itself.

It also adds a few error checks for invalid entries in /etc/hosts,
trims away leading and trailing whitespace from lines and tries to use
StringView over String.
2021-06-09 17:43:32 +04:30
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
Andreas Kling
4c47b3951d Clipboard: Tighten pledge promises a bit earlier :^) 2021-06-06 17:56:34 +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
Ali Mohammad Pur
51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Gunnar Beutner
d840608a51 Taskbar: Make sure LibGUI/Desktop.h is usable in ports
Now that Desktop.h includes Services/Taskbar/TaskbarWindow.h we have
to install Taskbar's header files so that Desktop.h can be used in
ports or when building software in-target.
2021-06-04 19:11:13 +02:00
Gunnar Beutner
19c4e74f70 Taskbar: Allow creating menus for sub-categories
This change allows creating sub-categories in app files, e.g. with
Category=Games/Puzzles.
2021-06-04 09:38:25 +02: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