Commit graph

1331 commits

Author SHA1 Message Date
Patrick Meyer
5510b98dc8 DHCPClient: Don't crash if DHCP options contain no gateway
Fixes #13879
2022-05-03 12:37:51 +04:30
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
Peter Elliott
287c6228b5 LoginServer: Change login fail message to avoid enumeration attacks
The current message distinguishes between a user that doesn't exist, and
an invalid password. This is considered to be bad practice, because an
attack can first check if a user exists before guessing that users
password.

Also it's just tradition or something.
2022-04-26 21:57:24 -07:00
Moustafa Raafat
0a3467d665 LibConfig+ConfigServer: Write config values synchronously
This patch fixes the issue of pressing the ok button of a settings menu
without saving the changes, or not reverting the changes when pressing
the cancel button because the app has died before the new values make
it to the other end.
2022-04-26 22:51:49 +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
Andrew Kaster
f1d47ea618 LibWeb+AudioServer: Remove unused spaceship operators
We aren't actually using these for anything, and the spaceship operator
requires ``<compare>`` from the STL, which we'd rather not include.
2022-04-23 10:43:32 -07:00
kleines Filmröllchen
612dbdc671 AudioServer: Auto-pause new clients
This fixes a bunch of audio clients that don't actually play audio.
2022-04-21 13:55:00 +02:00
kleines Filmröllchen
49b087f3cd LibAudio+Userland: Use new audio queue in client-server communication
Previously, we were sending Buffers to the server whenever we had new
audio data for it. This meant that for every audio enqueue action, we
needed to create a new shared memory anonymous buffer, send that
buffer's file descriptor over IPC (+recfd on the other side) and then
map the buffer into the audio server's memory to be able to play it.
This was fine for sending large chunks of audio data, like when playing
existing audio files. However, in the future we want to move to
real-time audio in some applications like Piano. This means that the
size of buffers that are sent need to be very small, as just the size of
a buffer itself is part of the audio latency. If we were to try
real-time audio with the existing system, we would run into problems
really quickly. Dealing with a continuous stream of new anonymous files
like the current audio system is rather expensive, as we need Kernel
help in multiple places. Additionally, every enqueue incurs an IPC call,
which are not optimized for >1000 calls/second (which would be needed
for real-time audio with buffer sizes of ~40 samples). So a fundamental
change in how we handle audio sending in userspace is necessary.

This commit moves the audio sending system onto a shared single producer
circular queue (SSPCQ) (introduced with one of the previous commits).
This queue is intended to live in shared memory and be accessed by
multiple processes at the same time. It was specifically written to
support the audio sending case, so e.g. it only supports a single
producer (the audio client). Now, audio sending follows these general
steps:
- The audio client connects to the audio server.
- The audio client creates a SSPCQ in shared memory.
- The audio client sends the SSPCQ's file descriptor to the audio server
  with the set_buffer() IPC call.
- The audio server receives the SSPCQ and maps it.
- The audio client signals start of playback with start_playback().
- At the same time:
  - The audio client writes its audio data into the shared-memory queue.
  - The audio server reads audio data from the shared-memory queue(s).
  Both sides have additional before-queue/after-queue buffers, depending
  on the exact application.
- Pausing playback is just an IPC call, nothing happens to the buffer
  except that the server stops reading from it until playback is
  resumed.
- Muting has nothing to do with whether audio data is read or not.
- When the connection closes, the queues are unmapped on both sides.

This should already improve audio playback performance in a bunch of
places.

Implementation & commit notes:
- Audio loaders don't create LegacyBuffers anymore. LegacyBuffer is kept
  for WavLoader, see previous commit message.
- Most intra-process audio data passing is done with FixedArray<Sample>
  or Vector<Sample>.
- Improvements to most audio-enqueuing applications. (If necessary I can
  try to extract some of the aplay improvements.)
- New APIs on LibAudio/ClientConnection which allows non-realtime
  applications to enqueue audio in big chunks like before.
- Removal of status APIs from the audio server connection for
  information that can be directly obtained from the shared queue.
- Split the pause playback API into two APIs with more intuitive names.

I know this is a large commit, and you can kinda tell from the commit
message. It's basically impossible to break this up without hacks, so
please forgive me. These are some of the best changes to the audio
subsystem and I hope that that makes up for this :yaktangle: commit.

:yakring:
2022-04-21 13:55:00 +02:00
kleines Filmröllchen
cb0e95c928 LibAudio+Everywhere: Rename Audio::Buffer -> Audio::LegacyBuffer
With the following change in how we send audio, the old Buffer type is
not really needed anymore. However, moving WavLoader to the new system
is a bit more involved and out of the scope of this PR. Therefore, we
need to keep Buffer around, but to make it clear that it's the old
buffer type which will be removed soon, we rename it to LegacyBuffer.
Most of the users will be gone after the next commit anyways.
2022-04-21 13:55:00 +02:00
kleines Filmröllchen
d463f6e00a SystemServer: Boot into graphical mode even if there's no video hardware
SystemServer had safety fallbacks to boot into text mode if the user
errorneously specified graphical mode but no video hardware was present.
As it's now possible to do exactly this intentionally, we should allow
it. This would of course make WindowServer fall over and die if
configured improperly, but if you're messing with the kernel command
line in strange ways, you should be able to fix that.
2022-04-21 13:41:55 +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
Sam Atkins
73552c1856 Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
Thitat Auareesuksakul
c949a4db2d DHCPClient: Send ParameterRequestList option with DHCPRequest packet
We'll need SubnetMask and Router options to be returned with the ACK
packet. So, it's a good idea to request them explicitly in this packet.
2022-04-17 10:25:01 +04:30
Thitat Auareesuksakul
01a602cb51 DHCPClient: Send ServerIdentifier option with DHCPRequest packet
Some DHCP servers (including Mikrotik ones) will NAK the request if the
ServerIdentifier option is not sent with the DHCPRequest packet.
2022-04-17 10:25:01 +04:30
Sam Atkins
c4134e9794 LibCore+Everywhere: Make Core::Stream read_until() return Bytes
This affects BufferedSeekable::read_until() and ::read_until_any_of().
For the reasoning, see the previous commit about Core::Stream::read().
2022-04-16 13:27:51 -04:00
Sam Atkins
3b1e063d30 LibCore+Everywhere: Make Core::Stream::read() return Bytes
A mistake I've repeatedly made is along these lines:
```c++
auto nread = TRY(source_file->read(buffer));
TRY(destination_file->write(buffer));
```

It's a little clunky to have to create a Bytes or StringView from the
buffer's data pointer and the nread, and easy to forget and just use
the buffer. So, this patch changes the read() function to return a
Bytes of the data that were just read.

The other read_foo() methods will be modified in the same way in
subsequent commits.

Fixes #13687
2022-04-16 13:27:51 -04:00
Tom
49de4d5f33 LibDNS: Remove the 'DNS' prefix from the various type and class names
Since all types and class names live in the DNS namespace, we don't
need to spell it out twice each time.
2022-04-15 16:34:26 +01:00
Tom
be4a4144f2 LookupServer: Move DNS related code into new LibDNS library
This allows other code to use the DNSPacket class, e.g. when sent
over IPC.
2022-04-15 16:34:26 +01:00
Aatos Majava
85da8cbb07 TelnetServer: Ignore null and \n when parsing
This fixes issues with carriage return sequences.

Before, using <CR><NUL> as the return sequence wouldn't work at all,
and when using <CR><LF> there was an extra newline after every newline.

After this patch, the behaviour should be closer to the Telnet RFC.
2022-04-14 16:12:16 +02:00
Tim Schumacher
1bdaee475b DHCPClient: Close outgoing sockets after use 2022-04-11 00:15:06 +02:00
kleines Filmröllchen
5319e3a03f LibCore+Userland: Remove File::ensure_parent_directories
We have a much safer and more powerful alternative now, so let's move
the few users over.
2022-04-11 00:08:48 +02:00
kleines Filmröllchen
0fd09b2381 LibCore: Automatically create config directories if necessary
If the .config directory (or its children, like lib) was deleted,
ConfigFile would crash because it would try to open or create a file in
a directory that didn't exist. Therefore, for user and library configs
(but not system configs), ensure that the parent directories exist. This
allows the user to delete the entire .config folder and all apps still
work. (Except those which can't handle missing config. That's a separate
issue though.)

Fixes #13555

Note: Some changes to pledges and unveils are necessary for this to
work. The only one who can recreate .config at the moment is
ConfigServer, as others probably don't pledge the user home directory.
2022-04-11 00:08:48 +02:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Ali Mohammad Pur
a42e03b01a Browser+LibWeb+WebContent: Implement per-URL-pattern proxies
...at least for SOCKS5.
2022-04-09 12:21:43 +02:00
Ali Mohammad Pur
45867435c4 RequestServer+LibProtocol: Allow users to specify a per-request proxy 2022-04-09 12:21:43 +02:00
Ali Mohammad Pur
cd9d740107 LibCore+RequestServer: Add support for SOCKS5 proxies 2022-04-09 12:21:43 +02:00
Lady Gegga
e34f199997 WebServer: Add utf-8 charset to Content-Type header for text/plain 2022-04-09 01:14:14 +02:00
Andreas Kling
59e8dedea2 LibWeb: Remove the InProcessWebView widget
Let's simplify our offering by only having the OutOfProcessWebView.
2022-04-06 19:35:07 +02:00
sin-ack
359365a06a InspectorServer: Defer removal of InspectableProcess from table
This prevents a crash when the inspected process closes the socket (i.e.
when the app is exited). This crash was caused by the InspectableProcess
removing itself from the global process table within a callback Function
that is stored as part of the InspectableProcess.
2022-04-06 13:04:03 +02:00
Andreas Kling
217993b1d1 Revert "WebContent: Use ConsoleGlobalObject for the console's global object :^)"
This reverts commit 8296dd9955.
2022-04-05 17:47:52 +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
Andreas Kling
463dc91049 WebContent: Cancel pending paint requests when removing a backing store
If there are pending paint requests waiting to be processed when the
client asks us to remove a backing store, we now prune them from the
request queue.

This avoids doing completely wasted painting work while resizing the
browser window. :^)
2022-04-05 17:28:33 +02:00
Sam Atkins
8296dd9955 WebContent: Use ConsoleGlobalObject for the console's global object :^)
Seems like this got missed when ESOs were implemented. Now we can use
`$0` again!
2022-04-05 13:02:12 +01:00
cflip
5bb0b6ba7a ClockSettings+Taskbar: Add settings for taskbar clock format 2022-04-04 13:15:13 +02:00
Brian Gianforcaro
09fe9b546f Services: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
Valtteri Koskivuori
45a81f5a2c Browser+LibWeb+WebContent: Add ability to inspect local storage
The storage inspector now has a new tab for local storage. The next step
would be to persist local storage and receive real-time notifications
for changes to update the table view.
2022-04-03 13:13:10 +01: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
Ben Maxwell
8fa0409ae1 LibGfx: Add list_installed_system_themes() to SystemTheme 2022-04-02 21:50:41 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Linus Groh
04e40b7aaa Browser+WebContent: Add a Debug menu action to disable scripting :^) 2022-03-31 17:08:38 +02:00
Linus Groh
780e5441b4 WebContent: Add plumbing for 'is scripting enabled' setting 2022-03-31 17:08:38 +02:00
Linus Groh
46ad69cd1e LookupServer: Fix confusing copy/paste error in debug message 2022-03-27 18:39:47 +01:00
Timur Sultanov
46710d9efa LookupServer: Use case-insensitive comparison for domain names
Some ISPs may MITM DNS requests coming from clients, changing the case
of domain name in response. LookupServer will refuse responses from
any DNS server in that case. This commit changes the behaviour to
perform a case-insensitive equality check.
2022-03-27 17:36:13 +02: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
Andreas Kling
bd44d9d641 LibWeb: Show correct element margin values in Inspector "Box Model" view
We were showing the margin-top value for all 4 margin values.
2022-03-25 11:57:30 +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
Andreas Kling
c2d7ef057d WebContent: Remove accidentally committed unveil() call 2022-03-24 23:17:49 +01:00
Andreas Kling
195ef5e26f LibWeb: Bring CSS line-height implementation closer to spec
We now distribute the line-height evenly between the space above and
below inline-level boxes. This noticeably improves our baseline
alignment in many cases.

Note that the "vertical-align: <length>" case is quite awkward, as the
extra height added by the offset baseline must count towards the line
box height.

There's a lot of room for improvement here, but this makes the buckets
container on Acid3 show up in the right place, with the right size.
2022-03-24 22:52:44 +01:00
Kenneth Myhra
4a57be824c Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to
ErrorOr<String>.

The rest of the change is to support the potential of an Error being
returned and subsequent release of the value when no Error is returned.
Unfortunately at this stage none of the places affected can utililize
our TRY() macro.
2022-03-24 11:57:51 +01:00
Andreas Kling
ca85ac26d4 WebContent: Fill OOPWV with palette base color when there's no content 2022-03-23 17:27:20 +01:00
Liav A
e508073168 SystemServer: Create /dev/tty as a character device instead of a symlink
The new device has major number 5, minor number 0, and is represented by
the SelfTTYDevice class in the Kernel.
2022-03-22 20:26:05 +01:00
sin-ack
e212514bbf LookupServer: Return with failure result when lookup fails
This was missed in 4ca0669d1e and the
error condition would still fall through to an ErrorOr unwrapping which
caused a crash.
2022-03-20 12:09:31 +03:30
Ali Mohammad Pur
dff8344336 RequestServer: Keep the EnsureConnection job alive until it finishes
Fixes #12906.
2022-03-19 22:04:35 +01:00
Maciej
c1ca009939 WebServer: Add Content-Length header to HTTP responses
This makes the browser know how much data it should expect.
2022-03-19 22:03:51 +01: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
Linus Groh
9422ae9bb2 LibJS: Add infallible variant of VM::push_execution_context()
It makes no sense to require passing a global object and doing a stack
space check in some cases where running out of stack is highly unlikely,
we can't recover from errors, and currently ignore the result anyway.

This is most commonly in constructors and when setting things up, rather
than regular function calls.
2022-03-18 01:12:12 +01:00
Andreas Kling
e31fe3eeb8 LibWeb: Rename Element::specified_css_values() => computed_css_values()
Let's make it very clear that these are *computed* values, and not at
all the specified values. The specified values are currently discarded
by the CSS cascade algorithm.
2022-03-15 19:48:19 +01:00
Andreas Kling
43ef813f3d LibWeb: Rename Element::computed_style() to resolved_css_values()
This more accurately reflects what's actually being returned.
2022-03-15 19:48:19 +01:00
kleines Filmröllchen
79deb7d6c7 AudioServer: Decrease sample headroom to 5%
This might still be too much, but it's better than what we had before.
2022-03-14 22:46:46 +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
Sam Atkins
7535398dbf FileOperation: Port to Core::Stream 2022-03-13 22:38:48 +01:00
Andreas Kling
5779a910e5 LibWeb: Move hit testing to the painting tree 2022-03-11 00:21:49 +01:00
Andreas Kling
ba606d9057 LibWeb: Move PaintingBox to its own .cpp and .h files 2022-03-11 00:21:49 +01:00
Andreas Kling
9461e44afa LibWeb: Use Layout::Box::paint_box() accessor in more places 2022-03-11 00:21:49 +01:00
Andreas Kling
f6497b64ac LibWeb: Rename Painting::Box => Paintable
Calling this "Box" made it very confusing to look at code that used both
Layout::Box and Painting::Box. Let's try calling it Paintable instead.
2022-03-11 00:21:49 +01:00
Andreas Kling
9f5cbcaad3 LibWeb: Hang StackingContext off of the paint boxes
Stacking contexts have nothing to do with layout and everything with
painting, so let's keep them in Painting::Box.
2022-03-11 00:21:49 +01:00
Andreas Kling
a4d51b3dc2 LibWeb: Add Painting::Box and move things from Layout::Box into it
The "paintable" state in Layout::Box was actually not safe to access
until after layout had been performed.

As a first step towards making this harder to mess up accidentally,
this patch moves painting information from Layout::Box to a new class:
Painting::Box. Every layout can have a corresponding paint box, and
it holds the final used metrics determined by layout.

The paint box is created and populated by FormattingState::commit().

I've also added DOM::Node::paint_box() as a convenient way to access
the paint box (if available) of a given DOM node.

Going forward, I believe this will allow us to better separate data
that belongs to layout vs painting, and also open up opportunities
for naturally invalidating caches in the paint box (since it's
reconstituted by every layout.)
2022-03-11 00:21:49 +01:00
Sam Atkins
10429e1043 WebContent: Return empty JSON object if element has no box model
The blank string "" does not parse as JSON, and so the InspectorWidget
would fail to update the box-model information when inspecting elements
with no box, (for example, `<head>`) showing stale values instead. Now,
they show all 0s.

You could argue that InspectorWidget should be more resilient when given
invalid JSON strings, but making sure we only pass valid ones works
too.
2022-03-10 17:30:09 +01:00
Sam Atkins
b5ea14b884 WebContent: Show box-model metrics for (some) pseudo-elements
This only applies to pseudo-elements which have a Layout::Box, so this
excludes any that are InlineNodes.
2022-03-10 17:30:09 +01:00
Sam Atkins
0326ad34df Browser+LibWeb+WebContent: Show style for pseudo-elements :^)
This expands the InspectorWidget::Selection to include an optional
PseudoElement, which is then passed over IPC to request style
information for it.

As noted, this has some pretty big limitations because pseudo-elements
don't have DOM nodes:
- Declared style has to be recalculated when it's requested.
- We don't display the computed style.
- We don't display custom properties.
2022-03-10 17:30:09 +01:00
Ben Abraham
7594350376 Browser: Show currently loading host and remaining resource count 2022-03-10 00:51:05 +01:00
Sahan Fernando
2939f65753 SystemServer: Create device files for gpus on startup
We are adding a new class of file, a GPU device. These devices have
major number 28, and are bound to files named /dev/gpuN.
2022-03-09 14:58:48 +03:30
javabird25
9246ad96b3 LoginServer: Add a label for login fail messages 2022-03-08 22:12:21 +01:00
Vrins
39a5076f40 Browser+LibWeb: Add an Element size preview widget to inspector
This Adds an element size preview widget to the inspector widget
in a new tab. This functions similar to chrome and firefox and
shows the margin, border, padding, and content size of the selected
element in the inspector.

The colors for the size preview widget are taken from the chrome
browser.
2022-03-08 22:09:52 +01:00
Linus Groh
1422bd45eb LibWeb: Move Window from DOM directory & namespace to HTML
The Window object is part of the HTML spec. :^)
https://html.spec.whatwg.org/multipage/window-object.html
2022-03-08 00:30:30 +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
Lenny Maiorani
f5fd2f3857 Services: Port FileOperation to LibMain 2022-02-28 13:57:26 +01:00
Idan Horowitz
feb00b7105 Everywhere: Make JSON serialization fallible
This allows us to eliminate a major source of infallible allocation in
the Kernel, as well as lay down the groundwork for OOM fallibility in
userland.
2022-02-27 20:37:57 +01:00
Itamar
493f604dba SpiceAgent: Rename ClipboardServerConnection
Rename ClipboardServerConnection=>ConnectionToClipboardServer.

This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +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
af132fdbd1 Userland: Rename WindowManagerServerConnection
Rename WindowManagerServerConnection=>ConnectionToWindowManagerServer.

This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
d88da82e28 Userland: Rename IPC::ServerConnection=>IPC::ConnectionToServer
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
thankyouverycool
e1a72c6df8 Taskbar: Update ClockWidget FrameShape and adjust dimensions
Uses the new Window FrameShape. Fixes some erroneously elided text
and incorrect calendar window placement.
2022-02-25 19:38:23 +01:00
Jan Grau
9311b685fe Taskbar: Minimize/activate window on Super+Digit event
Handle the SuperDigitKeyPressed event in the taskbar. Toggle the
respective taskbar button.
2022-02-24 18:57:20 +00: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
Linus Groh
929074ddea WebContent: Push execution context before ConsoleGlobalObject init
This fixes a crash of the browser when loading any page. LibWeb
immediately pops the 'running execution context' after creating an
interpreter, but it's needed to have a 'current realm' during
initialization of the ConsoleGlobalObject for NativeFunction::create()
to work.
Once this is done, we can immediately pop the execution context again.
2022-02-21 13:51:34 +00:00
Linus Groh
f2ca64cecd WebContent: Remove unused JS Lexer/Parser includes 2022-02-21 13:51:34 +00:00
Ali Mohammad Pur
ce057115fc RequestServer: Bump the ConnectionCache concurrent connection limit to 4
With ECDHE, our TLS handshake performance has increased, so we can
afford to bump this limit to 4, and get some faster loads :^)
2022-02-18 16:12:42 +03:30
Ali Mohammad Pur
0e173da86f WebServer: Close the socket if Connection: keep-alive isn't requested 2022-02-18 13:19:26 +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
Andreas Kling
9c78c1bf81 WebContent: Exit peacefully when client dies during synchronous IPC
If we're waiting for the client (typically Browser) to respond to a
synchronous IPC message from our side (e.g window.alert()) and the
client disconnects instead, just exit peacefully.

Ultimately a WebContent process lives to serve its client. When the
client dies, there is no need for WebContent anymore.
2022-02-16 12:03:05 +01:00
Liav A
6c0467f56b SystemServer: Remove now unnecessary call to chmod on /dev/audio
Don't use chmod now that DevTmpFS honors permission mode when creating
new directories.
2022-02-14 08:45:32 -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
sin-ack
72ef1d7c06 SystemServer: Remove Socket.h header + use Core::System in some places
Various Core::System functions are still missing so not all raw syscalls
were converted just yet.
2022-02-14 11:44:09 +01:00
sin-ack
4ca0669d1e LookupServer: Convert to Core::Stream::UDPSocket 2022-02-14 11:44:09 +01:00
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
Liav A
bf8c93fe0a AudioServer: Use first audio channel in the /dev/audio directory
For now, just use the first audio channel in the /dev/audio directory.
In the future we can add support for watching and loading other channels
so we can route audio to multiple sound cards on the system.
2022-02-14 11:39:19 +01:00
Liav A
a1f3a48ed5 SystemServer: Create audio channel device nodes in /dev/audio directory 2022-02-14 11:39:19 +01:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Andreas Kling
8b8a1449c4 RequestServer: Make value copy of the URL in ensure_connection()
I saw what looked like a UAF of this URL in a RequestServer crash,
and it seems reasonable to make a copy here since we end up passing
them to Core::deferred_invoke().
2022-02-12 22:30:50 +01:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
Idan Horowitz
873f4d5de6 RequestServer: Recreate socket if it reached EOF
This ensures we don't continue using a socket that has EOF'ed (meaning
the protocol has disconnected in the case of TCP) for new requests.
2022-02-11 18:11:32 +02:00
Timothy Flynn
2397836f8e LibSQL+SQLServer: Introduce and use ResultOr<ValueType>
The result of a SQL statement execution is either:
    1. An error.
    2. The list of rows inserted, deleted, selected, etc.

(2) is currently represented by a combination of the Result class and
the ResultSet list it holds. This worked okay, but issues start to
arise when trying to use Result in non-statement contexts (for example,
when introducing Result to SQL expression execution).

What we really need is for Result to be a thin wrapper that represents
both (1) and (2), and to not have any explicit members like a ResultSet.
So this commit removes ResultSet from Result, and introduces ResultOr,
which is just an alias for AK::ErrorOrr. Statement execution now returns
ResultOr<ResultSet> instead of Result. This further opens the door for
expression execution to return ResultOr<Value> in the future.

Lastly, this moves some other context held by Result over to ResultSet.
This includes the row count (which is really just the size of ResultSet)
and the command for which the result is for.
2022-02-10 23:11:13 +01:00
Andreas Kling
8d104b7de2 LibWeb: Perform CSS custom property cascade once instead of per-property
Previously we would re-run the entire CSS selector machinery for each
property resolved. Instead of doing that, we now resolve a final set of
custom property key/value pairs at the start of the cascade.
2022-02-10 20:52:11 +01:00
Timothy Flynn
373b467302 LibSQL+SQLServer: Move LibSQL/SQLResult.[h,cpp] to LibSQL/Result.[h,cpp]
Rename the file to match the new class name.
2022-02-10 12:20:35 +00:00
Timothy Flynn
6620f19979 LibSQL+SQLServer: Return the new Result class from statement executions
We can now TRY anything that returns a SQL::Result or an AK::Error.
2022-02-10 12:20:35 +00:00
Ali Mohammad Pur
cb7becb067 LibTLS+RequestServer: Add an option to dump TLS keys to a log file
This file allows us to decrypt TLS messages in wireshark, which can help
immensely in debugging network stuff :^)
2022-02-09 21:23:25 +01:00
Linus Groh
bc183dbbcb LibJS: Replace uses of MarkedValueList with MarkedVector<Value>
This is effectively a drop-in replacement.
2022-02-09 12:25:27 +00:00
Andreas Kling
3f9fc0f690 Browser+LibWeb: Add "Dump Local Storage" item to Browser's Debug menu 2022-02-08 21:53:20 +01:00
Ali Mohammad Pur
5dceba29a4 RequestServer: Avoid Vector OOB access in ConnectionCache
`it.is_end()` could be updated to return false for a previously-invalid
iterator after we append a new socket, copy its value out to a local
variable to not hit this behaviour.
2022-02-08 18:47:19 +00:00
Luke Wilde
f71f404e0c LibWeb: Introduce the Environment Settings Object
The environment settings object is effectively the context a piece of
script is running under, for example, it contains the origin,
responsible document, realm, global object and event loop for the
current context. This effectively replaces ScriptExecutionContext, but
it cannot be removed in this commit as EventTarget still depends on it.

https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
2022-02-08 17:47:44 +00: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
davidot
1c4c251be3 LibJS+Everywhere: Remove all VM::clear_exception() calls
Since VM::exception() no longer exists this is now useless. All of these
calls to clear_exception were just to clear the VM state after some
(potentially) failed evaluation and did not use the exception itself.
2022-02-08 09:12:42 +00:00
Ali Mohammad Pur
3bf828e0f9 RequestServer: Reenable socket notifications unconditionally
There's a possible window where the notifications are disabled, and any
request coming at that time will never get any data if it relies on
socket notifications.
2022-02-07 21:52:23 +01:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
Andreas Kling
65bd4477db LibWeb: Plumb OOPWV focus state across the IPC boundary
This makes focus outlines show up in OOPWV at last! :^)
2022-02-06 22:13:13 +01:00
sin-ack
64f135d90f LibCore+Userland: Remove Core::TCPSocket :^)
This was deprecated in favor of Core::Stream::TCPSocket, and now has no
users.
2022-02-06 17:28:17 +00:00
Ali Mohammad Pur
63b4c35ec7 WebSocket: Pledge rpath and unveil /etc/timezone
This is required for timezone stuff, otherwise we'd just crash.
2022-02-06 13:10:10 +01:00
Ali Mohammad Pur
aafc451016 Userland: Convert TLS::TLSv12 to a Core::Stream::Socket
This commit converts TLS::TLSv12 to a Core::Stream object, and in the
process allows TLS to now wrap other Core::Stream::Socket objects.
As a large part of LibHTTP and LibGemini depend on LibTLS's interface,
this also converts those to support Core::Stream, which leads to a
simplification of LibHTTP (as there's no need to care about the
underlying socket type anymore).
Note that RequestServer now controls the TLS socket options, which is a
better place anyway, as RS is the first receiver of the user-requested
options (though this is currently not particularly useful).
2022-02-06 13:10:10 +01:00
Andreas Kling
270aa9e5d0 Browser: Add Debug menu action for dumping the stacking context tree 2022-02-05 22:50:39 +01:00
Rummskartoffel
85c3852b8f KeyboardPreferenceLoader: Don't crash when "Keymaps" is empty 2022-02-03 14:57: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
Lenny Maiorani
b0a54518d8 Everywhere: Remove redundant inline keyword
`constexpr` implies `inline` so when both are used it is redundant.
2022-01-29 21:45:17 +02:00
networkException
e2df145e14 WindowServer: Allow checking checkable entries in a menu using space 2022-01-29 11:22:02 +01:00
Daniel Bertalan
7d11edbe17 Userland: Fix unnecessary heap allocation of singleton objects
In order to avoid having multiple instances, we were keeping a pointer
to these singleton objects and only allocating them when it was null.

We have `__cxa_guard_{acquire,release}` in the userland, so there's no
need to do this dance, as the compiler will ensure that the constructors
are only called once.
2022-01-28 23:31:00 +01:00
Ali Mohammad Pur
c1184c1fde RequestServer: Replace disconnected sockets in the grace period too
We previously only replaced disconnected sockets on the queued-request
path, leading to attempts to send requests on a disconnected socket if
the disconnection happened in the deletion grace period.
2022-01-28 23:29:32 +01:00
Timothy Flynn
acfcad0b06 Revert "FileSystemAccessServer: Display times in the local time zone"
This reverts commit fa016a72fd.
2022-01-28 15:13:35 +00:00
Timothy Flynn
8599ee3049 Revert "Userland: Invoke tzset in apps that care about time zones"
This reverts most of commit ede5c9548e.
The one change not reverted is ClockWidget.h, so that the taskbar clock
can continue to notice time zone changes.
2022-01-28 15:13:35 +00:00
Timothy Flynn
fa016a72fd FileSystemAccessServer: Display times in the user's local time zone 2022-01-28 12:25:20 +00:00
Andreas Kling
b7d316d291 RequestServer: Make Request::url() virtual
Let the Request subclass decide how they store the URL instead of
storing it in a Request member.
2022-01-27 09:56:24 +01:00
Andreas Kling
f73eae1245 WebServer: Unveil /etc/timezone for reading 2022-01-27 09:56:24 +01:00
thankyouverycool
7beea36052 LibGUI+LoginServer: Use default buttons in InputBox and LoginWindow 2022-01-26 23:19:54 +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
Timothy Flynn
ede5c9548e Userland: Invoke tzset in applications that care about time zones
In most applications, we invoke tzset once at startup for now. Most of
these are short lived and don't need to know about time zone changes.

The exception is the ClockWidget in the taskbar. Here, we invoke tzset
each time we update the system time. This way, any time zone changes can
take effect immediately.
2022-01-25 18:39:36 +00:00
Sam Atkins
45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
Timothy Flynn
9684ae460c RequestServer: Unveil /etc/timezone for date-time usage 2022-01-23 20:57:01 +00:00
Timothy Flynn
bcf4ec9c61 Userland: Add promises to programs that will read /etc/timezone
This will require unveiling /etc/timezone itself for reading, as well as
the rpath pledge promise.
2022-01-23 12:48:26 +00:00
Liav A
4da7b543c6 SystemServer: Create /dev/devctl and create devices based on its events
We first create the /dev/devctl based on the information from the SysFS.
Then, we create block devices and character devices based on the events
we read from that device.
2022-01-23 00:38:02 +00:00
Liav A
eaad77b286 SystemServer: Rename devfs => devtmpfs
We used to have a static devfs, but now it's called devtmpfs which is
completely dynamic.
2022-01-23 00:38:02 +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
Nico Weber
6d532649d4 RequestServer+AK: Move happy-path logging behind REQUESTSERVER_DEBUG
vdbgln() was responsible for ~10% of samples on pv's flamegraph for
RequestServer (under request_did_finish) when loading github.com in
Browser and recording a whole-system profile. This makes that almost
completely disappear.
2022-01-22 01:28:01 +00:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
Maciej
2cda579b07 Taskbar: Remove QuickLaunch entries if corresponding file was deleted 2022-01-21 13:44:36 +01:00
Maciej
0252c1f8fa Taskbar: Support arbitrary *files* as QuickLaunch entries 2022-01-21 13:44:36 +01:00
Maciej
3022baddc2 Taskbar: Support arbitrary executables as QuickLaunch entries 2022-01-21 13:44:36 +01:00
Maciej
2e8e959896 Taskbar: Abstract out quick launch entries
... into QuickLaunchEntry class. It will be used to implement adding
plain executables to the taskbar. For now, it adds TRY() error handling
to app launching :^)
2022-01-21 13:44:36 +01: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
Jan de Visser
7fc901d1b3 LibSQL+SQLServer: Implement first cut of SELECT ... ORDER BY foo
Ordering is done by replacing the straight Vector holding the query
result in the SQLResult object with a dedicated Vector subclass that
inserts result rows according to their sort key using a binary search.
This is done in the ResultSet class.

There are limitations:
- "SELECT ... ORDER BY 1" (or 2 or 3 etc) is supposed to sort by the
n-th result column. This doesn't work yet
- "SELECT ... column-expression alias ... ORDER BY alias" is supposed to
sort by the column with the given alias. This doesn't work yet

What does work however is something like
```SELECT foo FROM bar SORT BY quux```
i.e. sorted by a column not in the result set. Once functions are
supported it should be possible to sort by random functions.
2022-01-16 11:17:15 +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
Maciej
08e5c6f349 WebServer: Add charset declaration to directory listings 2022-01-14 21:32:55 +01:00
kleines Filmröllchen
be6418cc50 Everywhere: Use my new serenityos.org e-mail :^) 2022-01-14 11:54:09 +01:00
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
sin-ack
dbd25916a3 LibCore+Userland+Tests: Convert Stream APIs to construct on heap
As per previous discussion, it was decided that the Stream classes
should be constructed on the heap.

While I don't personally agree with this change, it does have the
benefit of avoiding Function object reconstructions due to the lambda
passed to Notifier pointing to a stale object reference. This also has
the benefit of not having to "box" objects for virtual usage, as the
objects come pre-boxed.

However, it means that we now hit the heap everytime we construct a
TCPSocket for instance, which might not be desirable.
2022-01-13 15:16:12 +03:30
Jelle Raaijmakers
263348ff2d Taskbar: Include ScreenLayout.h from Services directory
While trying to include `Desktop.h` for the SDL2 port, compilation
failed on finding this include. Specify the full include path to make
it work.
2022-01-12 20:26:46 +02:00
electrikmilk
983c784a80 Base+WindowServer: Add icon to window menu move action 2022-01-12 10:55:04 +01:00
Andreas Kling
d7475449cc Taskbar: Tweak taskbar button progress bar rendering
The rects didn't take the "thin cap" button style into account, causing
in-button progress bars to look a little off.
2022-01-10 16:22:37 +01:00
Michel Hermier
69cabb3ead Everywhere: Add serenity_dev_{makedev,major,minor}
Add them in `<Kernel/API/Device.h>` and use these to provides
`{makedev,major,minor}` in `<sys/sysmacros.h>`. It aims to be more in
line with other Unix implementations and avoid code duplication in user
land.
2022-01-09 00:58:44 +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
Sviatoslav Peleshko
46f6c86362 InspectorServer: Use the 32-bit data length when sending a request
`length` was inheriting `size_t` type of the `String::length()`, while
everywhere else in the Inspector we expect fixed 32-bit field. On the
architectures where `sizeof(size_t) != sizeof(u32)` this broke the
Inspector communication completely.
2022-01-08 23:48:46 +01:00
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
mjz19910
10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +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
bugreport0
764f455d21 Taskbar: Tighten pledged promises, remove incorrect comment 2022-01-03 15:56:41 +01:00
bugreport0
0d78693b6a RequestServer: Tighten pledged promises 2022-01-03 15:56:41 +01:00
bugreport0
1d6ed50dd0 ChessEngine: Remove unused 'rpath' promise 2022-01-03 15:56:41 +01:00
Maciej
e824a2da90 WebServer: Make ErrorOr unwrapping more idiomatic
This still not propagates errors properly, but is at least (more)
consistent with the codebase.
2022-01-03 15:44:56 +01:00
Ben Wiederhake
95c21977b4 LookupServer: Avoid unnecessary copies 2022-01-01 15:40:39 +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
Timothy Flynn
565a880ce5 Userland: Link directly against LibUnicodeData where needed
This is partially a revert of commits:
    10a8b6d411
    561b67a1ad

Rather than adding the prot_exec pledge requried to use dlopen(), we can
link directly against LibUnicodeData in applications that we know need
that library.

This might make the dlopen() dance a bit unnecessary. The same purpose
might now be fulfilled with weak symbols. That can be revisted next, but
for now, this at least removes the potential security risk of apps like
the Browser having prot_exec privileges.
2021-12-30 14:18:12 +01:00
faxe1008
7d6058415e Taskbar: Add context menu to remove quicklaunch items
This change adds a context menu for each app button to remove items
from the quicklaunch section of the Taskbar.
2021-12-28 00:57:48 -08:00
faxe1008
c74afdde26 Taskbar: Add dropping of AppFiles to QuickLaunch
This change adds the capability to drop AppFiles to the quick launch
section of the Taskbar. All logic was moved to a new
QuickLaunchWidget.
2021-12-28 00:57:48 -08:00
Sam Atkins
8600d89407 LibCore+Services: Make TCPServer propagate errors 2021-12-27 22:00:01 +01:00
Sam Atkins
143f820c68 TelnetServer: Port to LibMain
This is only a very basic change, since the fallible function calls are
all inside the `on_ready_to_accept` callback.
2021-12-27 22:00:01 +01:00
Sam Atkins
98c8eca70c EchoServer: Port to LibMain 2021-12-27 22:00:01 +01:00
Sam Atkins
d702678d16 LibJS+WebContent+Browser+js: Implement console.group() methods
This implements:
- console.group()
- console.groupCollapsed()
- console.groupEnd()

In the Browser, we use `<details>` for the groups, which is not actually
implemented yet, so groups are always open.

In the REPL, groups are non-interactive, but still indent any output.
This looks weird since the console prompt and return values remain on
the far left, but this matches what Node does so it's probably fine. :^)
I expect `console.group()` is not used much outside of browsers.
2021-12-27 21:44:07 +01:00
Sam Atkins
ff5e07d718 LibJS+WebContent+js: Bring console.trace() to spec
The spec very kindly defines `Printer` as accepting
"Implementation-specific representations of printable things such as a
stack trace or group." for the `args`. We make use of that here by
passing the `Trace` itself to `Printer`, instead of having to produce a
representation of the stack trace in advance and then pass that to
`Printer`. That both avoids the hassle of tracking whether the data has
been html-encoded or not, and means clients don't have to implement the
whole `trace()` algorithm, but only the code needed to output the trace.
2021-12-27 21:44:07 +01:00
Sam Atkins
ce694490f3 LibJS+WebContent+js: Bring console.assert() to spec 2021-12-27 21:44:07 +01:00
Sam Atkins
9b78e287b0 LibJS+WebContent+js: Bring console.clear() to spec
This is identical to before, since we don't have "group stacks" yet, but
clear() now uses ThrowCompletionOr.
2021-12-27 21:44:07 +01:00
Sam Atkins
834ced82d4 LibJS+WebContent+js: Bring console.count[Reset]() to spec
The `CountReset` log level is displayed as a warning, since the message
is always to warn that the counter doesn't exist. This is also in line
with the table at https://console.spec.whatwg.org/#loglevel-severity
2021-12-27 21:44:07 +01:00
Sam Atkins
260836135a LibJS+WebContent+js: Reimplement console.log() and friends to spec
This implements the Logger and Printer abstract operations defined in
the console spec, and stubs out the Formatter AO. These are then used
for the "output a categorized log message" functions.
2021-12-27 21:44:07 +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
Elyse
fb109ab3b4 AudioServer: Ignore 'muted' clients when computing the 'output mix' 2021-12-24 00:19:01 -08:00
Elyse
bb747c471f AudioServer: Add a 'self_muted' state to each client connection
This new state will allow us to ignore muted clients when computing the
'output mix' in the Mixer.
2021-12-24 00:19:01 -08:00
Elyse
ce5f5f543f AudioServer: Add 'mute' member and methods to ClientAudioStream
When computing the 'output mix', the Mixer iterates over all client
audio streams and computes a 'mixed sample' taking into account mainly
the client's volume.

This new member and methods will allow us to ignore a muted client
when computing that mix.
2021-12-24 00:19:01 -08:00
Elyse
c78a8b94c5 Everywhere: Refactor 'muted' to 'main_mix_muted' in all AudioConnections
The 'muted' methods referred to the 'main mix muted' but it wasn't
really clear from the name. This change will be useful because in the
next commit, a 'self muted' state will be added to each audio client
connection.
2021-12-24 00:19:01 -08:00
Max Trussell
60fa8ac109 AudioServer/Mixer: Fix remaining samples underflow
The `m_remaining_samples` attribute was underflowing at the end of an
audio stream. This fix guards against the underflow by only decrementing
the attribute when it is greater than zero.

I found this bug because the SoundPlayer userland application was not
correctly detecting when an audio stream was completed. This was
happening because the remaining samples being returned from the client
audio connection was an underflowed 16 bit integer instead of zero.
2021-12-24 00:05:35 -08:00
Timothy Flynn
10a8b6d411 Userland: Add unveil/pledge requisites for dynamic Unicode data loading
Loading libunicodedata.so will require dlopen(), which in turn requires
mmap(). The 'prot_exec' pledge is needed for this.

Further, the .so itself must be unveiled for reading. The "real" path is
unveiled (libunicodedata.so.serenity) as the symlink (libunicodedata.so)
itself cannot be unveiled.
2021-12-21 13:09:49 -08:00
Jonta
18dab0384d SystemServer: Fixed grammatical error "a charm" 2021-12-19 13:43:34 -08:00
Andreas Kling
87b1ad2356 SystemServer: Use more LibCore syscall wrappers :^) 2021-12-16 22:48:17 +01:00
Andreas Kling
e923762afc SystemServer: Port to LibMain :^) 2021-12-16 22:48:17 +01:00
sin-ack
dfdb52efa7 LibCore+Userland: Convert TCPServer to use the Serenity Stream API
This is intended as a real-usecase test of the Serenity Stream API, and
seemed like a good candidate due to its low amount of users.
2021-12-16 22:21:35 +03:30
sin-ack
0cca6cef95 LibCore+LookupServer: Implement and use UDPServer::send 2021-12-16 22:21:35 +03:30
Daniel Bertalan
8dd11ae717 Kernel+SystemServer: Add /dev/tty
This file refers to the controlling terminal associated with the current
process. It's specified by POSIX, and is used by ports like openssh to
interface with the terminal even if the standard input/output is
redirected to somewhere else.

Our implementation leverages ProcFS's existing facilities to create
process-specific symbolic links. In our setup, `/dev/tty` is a symbolic
link to `/proc/self/tty`, which itself is a symlink to the appropriate
`/dev/pts` entry. If no TTY is attached, `/dev/tty` is left dangling.
2021-12-12 22:32:35 +01:00
Sam Atkins
54bbb97ac6 Browser+LibWeb+WebContent: Add variables display to Inspector
This allows us to see which custom properties apply to a given element,
which previously wasn't shown.
2021-12-10 06:52:17 +01:00
Ben Wiederhake
f59f7674c8 LibHTTP: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Hendiadyoin1
67a1a9db1d WebContent: Add missing TRY on client initialization 2021-12-07 00:44:57 +01:00
Andreas Kling
971b3645ef LibIPC: Add IPC::take_over_accepted_client_from_system_server<Client>()
This is an encapsulation of the common work done by all of our
single-client IPC servers on startup:

    1. Create a Core::LocalSocket, taking over an accepted fd.
    2. Create an application-specific ClientConnection object,
       wrapping the socket.

It's not a huge change in terms of lines saved, but I do feel that it
improves expressiveness. :^)
2021-12-06 19:22:16 +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
Andreas Kling
229a45ab14 SQLServer: Port to LibMain :^) 2021-12-06 19:22:16 +01:00
Andreas Kling
69ea1ff743 LaunchServer: Port to LibMain :^) 2021-12-06 19:22:16 +01:00
Sam Atkins
2aa0885220 DHCP4Client: Cast unused Timer return values to void
Timers attach themselves to the provided parent, so they are safely kept
alive.
2021-12-05 15:31:03 +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
Jan de Visser
001949d77a LibSQL: Improve error handling
The handling of filesystem level errors was basically non-existing or
consisting of `VERIFY_NOT_REACHED` assertions. Addressed this by
* Adding `open` methods to `Heap` and `Database` which return errors.
* Changing the interface of methods of these classes and clients
downstream to propagate these errors.

The constructors of `Heap` and `Database` don't open the underlying
filesystem file anymore.

The SQL statement handlers return an `SQLErrorCode::InternalError`
error code if an error comes back from the lower levels. Note that some
of these errors are things like duplicate index entry errors that should
be caught before the SQL layer attempts to actually update the database.

Added tests to catch attempts to open weird or non-existent files as
databases.

Finally, in between me writing this patch and submitting the PR the
AK::Result<Foo, Bar> template got deprecated in favour of ErrorOr<Foo>.
This resulted in more busywork.
2021-12-04 20:49:22 +03:30
Hendiadyoin1
713a9ca5f1 LookupServer: Remove unused this capture in a lambda function
this was causing CI to fail
2021-11-30 16:15:52 -08:00
Andreas Kling
2b0c2360bb KeyboardPreferenceLoader: Use Core::System::ioctl() 2021-11-30 23:34:40 +01:00
Andreas Kling
74a6fb64b2 DHCPClient: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
2bb27184b4 KeyboardPreferenceLoader: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
a93205199b AudioServer: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
e399835466 ChessEngine: Port to LibMain :^) 2021-11-30 23:34:40 +01:00
Andreas Kling
6e2f7a15fb InspectorServer: Port to LibMain :^) 2021-11-30 23:34:40 +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
6cb3092b42 WebContent: Remove unnecessary client map
WebContent processes only serve a single client, so we don't need to
keep a map of them.
2021-11-30 23:34:40 +01:00
Andreas Kling
314a687eeb ImageDecoder: Remove unnecessary client map
ImageDecoder processes only serve a single client, so we don't need to
keep a map of them.
2021-11-30 23:34:40 +01:00
Jelle Raaijmakers
e187207610 Kernel: Register Virtio console ports with device management
Previously, Virtio console ports would not show up in `/sys/dev/char/`.
Also adds support to `SystemServer` to create more than one console
port device in `/dev/` in the multiport case.
2021-11-30 10:53:41 +01:00
Andreas Kling
da42c1552c ImageDecoder: Fix assertion after failed decode
We were calling value() on an ErrorOr containing an error when trying
to extract the frame duration after a failed decode.

This fixes ImageDecoder crashing on various websites.
2021-11-29 13:21:27 +01:00
Andreas Kling
16746efcf8 SpiceAgent: Port to LibMain :^) 2021-11-28 23:14:19 +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
kleines Filmröllchen
96d02a3e75 LibAudio: New error propagation API in Loader and Buffer
Previously, a libc-like out-of-line error information was used in the
loader and its plugins. Now, all functions that may fail to do their job
return some sort of Result. The universally-used error type ist the new
LoaderError, which can contain information about the general error
category (such as file format, I/O, unimplemented features), an error
description, and location information, such as file index or sample
index.

Additionally, the loader plugins try to do as little work as possible in
their constructors. Right after being constructed, a user should call
initialize() and check the errors returned from there. (This is done
transparently by Loader itself.) If a constructor caused an error, the
call to initialize should check and return it immediately.

This opportunity was used to rework a lot of the internal error
propagation in both loader classes, especially FlacLoader. Therefore, a
couple of other refactorings may have sneaked in as well.

The adoption of LibAudio users is minimal. Piano's adoption is not
important, as the code will receive major refactoring in the near future
anyways. SoundPlayer's adoption is also less important, as changes to
refactor it are in the works as well. aplay's adoption is the best and
may serve as an example for other users. It also includes new buffering
behavior.

Buffer also gets some attention, making it OOM-safe and thereby also
propagating its errors to the user.
2021-11-28 13:33:51 -08:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00