Commit Graph

246 Commits

Author SHA1 Message Date
Andreas Kling
3c9dcec442 LibWeb: Merge Document::layout() and Document::update_layout()
There is now only Document::update_layout().
2020-12-14 10:39:57 +01:00
Andreas Kling
b9b7b2b28a LibCore: Make IODevice::read_line() return a String
Almost everyone using this API actually wanted String instead of a
ByteBuffer anyway, and there were a bunch of slightly different ways
clients would convert to String.

Let's just cut out all the confusion and make it return String. :^)
2020-12-13 11:54:11 +01:00
Andreas Kling
eda9fb13cc LibWeb+WebContent: Add on_load_finish hook to web views
This isn't entirely symmetrical with on_load_start as it will also fire
on reloads and back/forward navigations. However, it's good enough for
some basic use cases, and we can do more sophisticated notifications
later on when we need them.
2020-12-08 23:36:19 +01:00
Ben Wiederhake
4427da989f WindowServer: Initial wallpaper must not be NULL
This used to crash 'pape -c' on a fresh image. Note that the special value
is '', the empty string, and *not* NULL, i.e. an unset string. An empty
string implies that the wallpaper is not an image, but rather a solid color.
2020-12-08 09:37:30 +01:00
Andreas Kling
17e25890be WindowServer: Don't crash when pressing return after opening menu
There isn't always a hovered item, so let's not assume things.
2020-12-07 19:40:12 +01:00
Andreas Kling
484134d818 LookupServer: Put debug spam behind a macro 2020-12-06 01:16:39 +01:00
Julian Offenhäuser
503aebaefc WindowServer: Allow for more flexible tiling
The desktop can now be split up into halves (both vertical and
horizontal) and quarters by dragging a window into the corresponding
edge or corner.

This makes tiling behave more like you would expect from similiar
window managers.
2020-12-06 00:19:04 +01:00
Julian Offenhäuser
980acd0db7 AudioServer: Fix issue when adding a BufferQueue to Mixer
Previously, the Mixer class would only check for an added BufferQueue
if the list of active queues was empty. If more than one client
connected to AudioServer, its queue would never be added to the list of
active queues.

This fix adds a flag that, when set, will cause the sound thread to wait
for a new BufferQueue.
2020-12-05 10:10:27 +01:00
Andreas Kling
15e35b0d71 LibWeb: Layout viewport rect was lagging behind when resizing
Layout was using an outdated viewport rect that we set *after* doing
a layout due to resize. That meant that layout-in-response-to-resize
was always lagging behind the current size of the view.

The root of this problem was how Frame kept both a viewport rect
(with both scroll offset and size) and a frame size. To fix this,
only store the viewport scroll offset, and always use the frame size.
This way they can't get out of sync and the problem goes away. :^)

Fixes #4250.
2020-12-02 23:50:19 +01:00
Tom
f68115aba3 Taskbar: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:25 +01:00
Tom
d6174f9c79 SystemServer: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

This fixes random zombie processes sticking around after e.g. closing
Browser.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:15 +01:00
Brendan Coles
b9bbf377d6 AudioServer: Mixer: limit max volume to 100 2020-11-29 10:15:36 +01:00
Andreas Kling
5aeab9878e LibWeb: Rename LayoutNode classes and move them into Layout namespace
Bring the names of various boxes closer to spec language. This should
hopefully make things easier to understand and hack on. :^)

Some notable changes:

- LayoutNode -> Layout::Node
- LayoutBox -> Layout::Box
- LayoutBlock -> Layout::BlockBox
- LayoutReplaced -> Layout::ReplacedBox
- LayoutDocument -> Layout::InitialContainingBlockBox
- LayoutText -> Layout::TextNode
- LayoutInline -> Layout::InlineNode

Note that this is not strictly a "box tree" as we also hang inline/text
nodes in the same tree, and they don't generate boxes. (Instead, they
contribute line box fragments to their containing block!)
2020-11-22 15:56:27 +01:00
Andreas Kling
adabcf24ec Everywhere: Add missing <AK/ByteBuffer.h> includes
All of these files were getting ByteBuffer.h from someone else and then
using it. Let's include it explicitly.
2020-11-15 13:11:21 +01:00
Andreas Kling
ebaf20547c WindowServer: Show modal window's cursor over blocked windows
When a window is blocked by a modal window from the same application,
we now prefer the modal window's cursor instead of the hovered window.
2020-11-10 19:30:22 +01:00
Tom
75f61fe3d9 AK: Make RefPtr, NonnullRefPtr, WeakPtr thread safe
This makes most operations thread safe, especially so that they
can safely be used in the Kernel. This includes obtaining a strong
reference from a weak reference, which now requires an explicit
call to WeakPtr::strong_ref(). Another major change is that
Weakable::make_weak_ref() may require the explicit target type.
Previously we used reinterpret_cast in WeakPtr, assuming that it
can be properly converted. But WeakPtr does not necessarily have
the knowledge to be able to do this. Instead, we now ask the class
itself to deliver a WeakPtr to the type that we want.

Also, WeakLink is no longer specific to a target type. The reason
for this is that we want to be able to safely convert e.g. WeakPtr<T>
to WeakPtr<U>, and before this we just reinterpret_cast the internal
WeakLink<T> to WeakLink<U>, which is a bold assumption that it would
actually produce the correct code. Instead, WeakLink now operates
on just a raw pointer and we only make those constructors/operators
available if we can verify that it can be safely cast.

In order to guarantee thread safety, we now use the least significant
bit in the pointer for locking purposes. This also means that only
properly aligned pointers can be used.
2020-11-10 19:11:52 +01:00
AnotherTest
6d1e47e7dd LibGUI+WindowServer: Make DragOperation hold a MimeData instance
...instead of maybe bitmap + a single mime type and its corresponding data.
This allows drag&drop operations to hold multiple different kinds of
data, and the views/applications to choose between those.
For instance, Spreadsheet can keep the structure of the dragged cells,
and still provide text-only data to be passed to different unrelated editors.
2020-11-08 21:46:13 +01:00
Brendan Coles
fb5ea8a212 WindowServer+LibGfx: Add Gfx::StandardCursor::Hidden cursor 2020-11-02 20:58:07 +01:00
Brendan Coles
328915a279 ChessEngine: Use pledge and unveil 2020-11-02 13:16:09 +01:00
AnotherTest
812e3ecedd LibProtocol+LibGemini+LibHTTP: Provide root certificates to LibTLS
Now we (almost) verify all the sites we browse.
Certificate verification failures should not be unexpected, as the
existing CA certificates are likely not complete.
2020-10-30 23:42:03 +01:00
AnotherTest
a461526b07 LibHTTP+ProtocolServer+LibGemini: Remove Request::schedule()
This API is only used for HttpRequest, but replicated in GeminiRequest
without an actual user, so remove it and construct the job like the rest
of the protocols.
2020-10-30 23:42:03 +01:00
Uma Sankar Yedida
9ccae7a908 WindowServer+LibGfx: Added Crosshair cursor 2020-10-30 19:10:15 +01:00
Andreas Kling
3ec19ae4b6 LibGUI+LibGfx+WindowServer: Auto-generate disabled action icons :^)
This patch adds a simple filter that makes button and menu item icons
have that "'90s disabled" look when disabled. It's pretty awesome.
2020-10-27 21:25:40 +01:00
Andreas Kling
ce4ee1df1b WindowServer: Improve look of drag&drop items somewhat
This just adds a bit of padding around items. There's lots of room for
improvement here.
2020-10-27 20:45:38 +01:00
Linus Groh
7eee39b850 LookupServer: Support multiple nameservers
The configuration key [DNS] Nameserver has been renamed to Nameservers
and accepts a comma-separated list of nameserver addresses, which will
be queried in the given order until a response has been received.

The new default value is still Cloudflare's 1.1.1.1 as well as their
secondary DNS server 1.0.0.1.
2020-10-25 18:52:20 +01:00
Linus Groh
2440112d53 LookupServer: Replace unused 'did_timeout' with 'did_get_response'
did_timeout is a bool& parameter of lookup() that used to be set when
the UDP connection timed out, but this behaviour was broken in e335d73.
I replaced it with a more useful 'did_get_response' parameter that is
being set after the UDP socket connected, sent its request and got a
response - it might still be bogus data but we know the communication
was successful.
2020-10-25 18:52:20 +01:00
Linus Groh
75864b5a85 LookupServer: Replace dbg()/dbgprintf() with dbgln() 2020-10-25 18:52:20 +01:00
Andreas Kling
cfe1c132cb WindowServer: Raise menu item icons slightly when hovered :^)
Same effect as LibGUI toolbar buttons.
2020-10-25 15:32:19 +01:00
Andreas Kling
3ba6dceee3 Taskbar: Make quicklaunch buttons larger and reduce spacing
The end result is almost identical, but now it's a little easier to
hit the buttons with the cursor. :^)
2020-10-25 15:32:19 +01:00
Andreas Kling
20ca3d4a99 LibGfx+WindowServer: Handle taller window title fonts better
If the window title font is taller than the theme's specified title
height, compute the title height based on the font instead. :^)
2020-10-24 00:26:13 +02:00
Andreas Kling
5043c4a3e5 LibCore+WebServer+LibWeb: Make MIME type guesser take a StringView
This reverts my previous commit in WebServer and fixes the whole issue
in a much better way. Instead of having the MIME type guesser take a
URL (which we don't actually have in the WebServer at that point),
just take a path as a StringView.

Also, make use of the case-insensitive StringView::ends_with() :^)
2020-10-21 21:16:20 +02:00
Andreas Kling
9c14e2ea5d WebServer: Force "text/html" mimetype for directories with index.html
When you GET a directory with an index.html file, we were using the
mime type guessing logic from LibCore on the "/" filename, which gave
us "text/plain". Force the mime type to "text/html" in these cases
so browsers actually interpret it as HTML. :^)
2020-10-21 20:55:16 +02:00
Andreas Kling
f5f99ccd6a WindowServer: Return some event members by const reference 2020-10-20 18:10:22 +02:00
Linus Groh
e40135fefd LibWeb: Add OutOfProcessWebView::load_html() 2020-10-08 23:20:52 +02:00
Nico Weber
9d27644b7d DHCPClient: Remove unused UPDSocket.h include 2020-10-08 10:00:39 +02:00
Nico Weber
be693e95ff Services: Remove unused includes of {LibCore,WindowServer}/EventLoop.h 2020-10-05 23:48:33 +02:00
asynts
d5ffb51a83 AK: Don't add newline for outf/dbgf/warnf.
In the future all (normal) output should be written by any of the
following functions:

    out    (currently called new_out)
    outln
    dbg    (currently called new_dbg)
    dbgln
    warn   (currently called new_warn)
    warnln

However, there are still a ton of uses of the old out/warn/dbg in the
code base so the new functions are called new_out/new_warn/new_dbg. I am
going to rename them as soon as all the other usages are gone (this
might take a while.)

I also added raw_out/raw_dbg/raw_warn which don't do any escaping,
this should be useful if no formatting is required and if the input
contains tons of curly braces. (I am not entirely sure if this function
will stay, but I am adding it for now.)
2020-10-04 17:04:55 +02:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Tom
7399874479 AK: Add trivial structure validation to SharedBuffer
If we're sharing buffers, we only want to share trivial structures
as anything else could potentially share internal pointers, which
most likely is going to cause problems due to different address
spaces.

Fix the GUI::SystemTheme structure, which was not trivial, which
is now caught at compile time.

Fixes #3650
2020-10-02 15:38:07 +02:00
Itamar
fec4152220 LibCore: Add ensure_parent_directories to LibCore::File
Moved the implementation in SystemServer/Service.cpp to LibCore.
2020-09-30 21:46:59 +02:00
Andreas Kling
f88a7cd4e1 LibCore: Make TCPServer::listen() report failure instead of asserting 2020-09-28 22:14:23 +02:00
Andreas Kling
2946a684ef ProtocolServer+LibWeb: Support more detailed HTTP requests
This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
2020-09-28 11:55:26 +02:00
Ben Wiederhake
934d4d4033 Meta+Services: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
asynts
26f4b5e6ba TelnetServer: Use OutputMemoryStream instead of BufferStream.
I could not test these changes because I could not get my telnet client
(on Linux) to connect to the telnet server running in Serenity.

I tried the follwing:

    # Serenity
    su
    TelnetServer

    # Linux
    telnet localhost 8823

The server then immediatelly closes the connection:

    Connection closed by foreign host.

In the debug logs the following message appears:

    [NetworkTask(5:5)]: handle_tcp: unexpected flags in FinWait2 state
    [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state
    [NetworkTask(5:5)]: handle_tcp: unexpected flags in Closed state

This seems to be an unrelated bug in the TCP implementation.
2020-09-21 09:37:49 +02:00
asynts
8f06e4aaa4 LookupServer: Use DuplexMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
asynts
3fa0bba4b4 AudioServer: Use OutputMemoryStream instead of BufferStream. 2020-09-21 09:37:49 +02:00
Andreas Kling
d3fcba78b0 WindowServer: Shrink menubar menu text rects slightly
We don't want the menu titles to cover the entire menubar.
2020-09-19 19:16:22 +02:00
Tom
6212f57755 WindowServer: Make SetWindowTaskbarRect tolerant to non-existing windows
There is a window between windows disappearing (e.g. closing or crashes)
and the Taskbar process being notified. So it is entirely possible that
it may call SetWindowTaskbarRect() for a window and/or client id that no
longer exists. As the Taskbar process does not own these windows, this
should not be treated as a misbehaving application request. Instead, just
silently ignore the request. The Taskbar will be notified shortly after
that the window no longer exist and remove it from its list.

Fixes #3494
2020-09-16 15:57:12 +02:00
Andreas Kling
e2f32b8f9d LibCore: Make Core::Object properties more dynamic
Instead of everyone overriding save_to() and set_property() and doing
a pretty asymmetric job of implementing the various properties, let's
add a bit of structure here.

Object properties are now represented by a Core::Property. Properties
are registered with a getter and setter (optional) in constructors.
I've added some convenience macros for creating and registering
properties, but this does still feel a bit bulky. We'll have to
iterate on this and see where it goes.
2020-09-15 21:46:26 +02:00
Andreas Kling
d9e39cb82d LibWeb: Support window.alert() in multi-process context
Alerts are now delegated to the embedding GUI process.
2020-09-12 14:49:29 +02:00