Commit Graph

294 Commits

Author SHA1 Message Date
Mart G
86a9e26996 LibC: Prevent remove from calling rmdir when unlink succeeds. 2021-01-23 15:26:44 +01:00
Andreas Kling
8363b3ae99 LibWeb: Generate JS bindings for XMLHttpRequest from IDL :^)
Remove the hand-written XHR bindings in favor of generated ones.
2021-01-23 15:06:09 +01:00
Andreas Kling
25056830f0 LibWeb: Add very basic support for IDL constants
You can now put constants on an IDL interface and they will pop up on
both the constructor and prototype objects.
2021-01-23 13:20:24 +01:00
Andreas Kling
5b91362d4e LibWeb: Move XMLHttpRequest to separate XHR directory
In keeping with the one-directory-per-web-spec layout, let's move XHR
into its own clubhouse.
2021-01-23 11:51:36 +01:00
Ben Wiederhake
e8997e1de9 LibGfx: Implement Rect resizing around a fixed point 2021-01-23 08:34:17 +01:00
Nico Weber
345909c009 WindowServer: Don't crash on wallpapers smaller than the desktop with fill mode 'simple'
blit() calls draw_scaled_bitmap() behind the scenes in scaled contexts,
and that doesn't  like src_rect to be outside of the source bitmap's
bounds. Implicitly clip with the source rect, like the non-scaled
codepath already does.

Fixes #5017 even more.
2021-01-23 08:31:41 +01:00
Nico Weber
dcc967d1ad LibGfx: Make draw_tiled_bitmap() in scaled contexts actually work 2021-01-23 08:31:41 +01:00
Zac
dfa3f5fbc8 Vim: Added a Basic Implementation of Visual Mode 2021-01-23 08:29:13 +01:00
AnotherTest
2bd77bc93b Shell: Make the parser read consecutive sequences without recursing
This fixes (the easy) part of #4976.
2021-01-23 08:28:58 +01:00
Emanuele Torre
68c8b52612 Build: Use cmake's make_directory utility instead of env(1) and mkdir(1)
..in CMake files.

Also, the `-S`s were unnecessary here since "mkdir" doesn't have any
spaces and these are not shebangs.
2021-01-22 22:14:42 +01:00
asynts
ea7b7d8ceb Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
3f23a58fa1 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
7d783d8b84 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
5c5665c1e7 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
6dc2c38fd0 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
7dc3a5ce3f Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
d69a8a9958 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
9229ba0fe9 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
asynts
27bc48e06c Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Nico Weber
2ec6bbd7a1 LibGfx: Add a draw_scaled_bitmap() variant that takes a FloatRect as src_rect
Consider

    draw_scaled_bitmap({0, 0, 10, 10}, source, {0, 0, 5, 5}).

Imagine wanting to split that up into two calls, like e.g. the
compositor when redrawing the background with damage rects. You really
want to be able to say

    draw_scaled_bitmap({0, 0, 5, 10}, source, {0, 0, 2.5, 5})

but up to now you couldn't. Now you can.

This makes painting very low-res images (such as tile.png) in mode
"stretch" work much better.
2021-01-22 22:13:53 +01:00
Nico Weber
7278ff6605 LibGfx: Allow comparing Points, Sizes, and Rects of different type 2021-01-22 22:13:53 +01:00
Ben Wiederhake
67cda61b7f Libraries: Add missing headers
A C++ source file containing just
    #include <LibFoo/Bar.h>
should always compile cleanly.

This patch adds missing header inclusions that could have caused weird error
messages if they were used in a different context. Also, this confused QtCreator.
2021-01-22 21:49:54 +01:00
Ben Wiederhake
1e7adf5cb6 LibGUI: Resolve cyclic inclusion
Application.h includes Widget.h which includes Application.h. I'm not entirely
sure what the semantics are in this case, but avoiding this seems to be the
safer approach. In this case, Widget does not actually use Application, so let's
just remove the unused include.
2021-01-22 21:49:54 +01:00
Ben Wiederhake
1ec225f5ba LibCrypto: Make PEM.h able to stand alone
These headers should probably all be converted into proper functions of
LibCrypto, especially since we have shared objects.
2021-01-22 21:49:54 +01:00
Pierre
a1d7739607 LibGfx: adding a very simple PNG writer
With this patch it is possible to create PNG files. Only minimal options
are supported. The PNG is created with one big IDAT chunk containing
only non-compressible DEFLATE blocks.
2021-01-22 20:39:25 +01:00
Nico Weber
d1ea418e43 LibGfx: Implement scaling support for draw_tiled_bitmap()
Closes #5017.
2021-01-22 20:39:14 +01:00
Andreas Kling
b0f19c2af4 LibC: Templatize unique filename enumeration for mkstemp() et al
This allows us to implement mkstemp() with open() directly, instead of
first lstat()'ing, and then open()'ing the filename.

Also implement tmpfile() in terms of mkstemp() instead of mktemp().
2021-01-22 19:39:44 +01:00
Linus Groh
421587c15c Everywhere: Fix typos 2021-01-22 18:41:29 +01:00
Jonathan Turner
0bf5669ba3
Meta: Get building on NixOS (#5005) 2021-01-22 17:44:05 +01:00
Nico Weber
2fe6a313c2 LibGfx: Implement blit_offset() in terms of blit()
It's less code, and blit() already handles scaled painters.

Fixes the window server asserting in highdpi mode with a centered
background image. Part of #5017.
2021-01-22 17:32:44 +01:00
Maciej Zygmanowski
586c0aa043 LibDebug: Don't assert when running on non-existent executable 2021-01-22 17:00:24 +01:00
Nico Weber
c98055de75 LibGfx: Remove Painter::blit_scaled() in favor of Painter::draw_scaled_bitmap()
draw_scaled_bitmap() has a clearer API (just source and dest rects --
blit_scaled() took those and scale factors and then ignored width and
height on the source rect and it was less clear what it was supposed to
do), and they do mostly the same thing.

The draw_scaled_bitmap() API takes an IntRect as source rect, so it's
currently not always possible to split a big draw_scaled_bitmap() into
two (or more) smaller draw_scaled_bitmap() calls that do the same thing
-- that'd require FloatRects. The compositor kind of wants this to be
possible, but there's already a FIXME about this not looking quite right
with the previous approach either.

draw_scaled_bitmap() handles transparent sources, so after this change
wallpapers with transparency will be blended instead of copied. But that
seems fine, and if not, the Right Fix for that is to remove the alpha
channel from wallpapers after loading them anyways.

As an added bonus, draw_scaled_bitmap() already handles display scale,
so this fixes window server asserts for background images that are shown
as "stretch" (#5017). The window server still asserts for "tile" and
"offset" for now though.

Calling draw_scaled_bitmap() here exposed a bug in it fixed by #5041.
Before that is merged, this change here will cause smearing on the
background image when moving windows around.
2021-01-22 16:58:41 +01:00
Nico Weber
6a78e7e6a8 LibGfx: Correctly handle source rect offset in draw_scaled_bitmap
The do_draw_integer_scaled_bitmap() fastpath already handled this
correctly, but the arbitrary scale path did not.
2021-01-22 16:58:23 +01:00
Nico Weber
d5f403663b LibGfx: Compute hscale/vscale inside do_draw_scaled_bitmap instead of passing it in
They're both read only inside do_draw_scaled_bitmap(), so there's no
point in computing them earlier.

No behavior change.
2021-01-22 16:54:31 +01:00
Ben Wiederhake
58f25092c7 Meta: Fix silly copyright line 2021-01-22 11:28:07 +01:00
Tom
9943816e83 LibPthread: Fix asserting futex return value
FUTEX_WAIT returns the number of threads woken (if any).

Fixes #5032
2021-01-22 11:17:07 +01:00
Andreas Kling
3b80358142 LibCore: Always fail Account authentication on missing shadow entry
If a user is missing from /etc/shadow, we used to just allow anyone to
authenticate as that user without a password.

With this patch, authentication will instead always fail.
2021-01-21 11:34:39 +01:00
Andreas Kling
439f447ba8 LibCore+su+passwd: Don't keep /etc/passwd and /etc/shadow open
Now that we've moved to atomic replacement of these files when altering
them, we don't need to keep them open for the lifetime of Core::Account
so just simplify this and close them when they are not needed.
2021-01-21 11:17:06 +01:00
Andreas Kling
77e0598c6d passwd+LibCore: Make passwd replace /etc files atomically
Before this patch, we had a nasty race condition when changing a user's
password: there was a time window between truncating /etc/shadow and
writing out its new contents, where you could simply "su" to root
without using a password.

Instead of writing directly to /etc/passwd and /etc/shadow, we now
create temporary files in /etc and fill them with the new contents.
Those files are then atomically renamed to /etc/passwd and /etc/shadow.

Sadly, fixing this race requires giving the passwd program a lot more
privileges. This is something we can and should improve upon. :^)
2021-01-21 11:08:20 +01:00
Nico Weber
65570216b4 oss-fuzz: Try harder to fix build
Apparently memfd_create() is newish in glibc, and oss-fuzz
uses Ubuntu 16.04 as base for its docker images, which doens't
yet have memfd_create(). But, not to worry, it does have the syscall
define and that's all we really need :/
2021-01-20 23:41:38 +01:00
Andreas Kling
19d3f8cab7 Kernel+LibC: Turn errno codes into a strongly typed enum
..and allow implicit creation of KResult and KResultOr from ErrnoCode.
This means that kernel functions that return those types can finally
do "return EINVAL;" and it will just work.

There's a handful of functions that still deal with signed integers
that should be converted to return KResults.
2021-01-20 23:20:02 +01:00
Nico Weber
91aa0d9997 LibGfx/Painter: Keep translation and clip_rect in logical coordinates
Moves Painter away from general affine transport support a bit, but
this scale factor business does feel like it's a bit different.

This is conceptually cleaner (everything should use logical coordinates
as much as possible), and it means the code in GUI::Painter() will work
without changes due to that, but the draw function implementations
overall get a bit murkier (draw_rect() becomes nicer though). Still,
feels like the right direction.

No behavior change.
2021-01-20 21:01:48 +01:00
Linus Groh
678919e9c1 Kernel: Set "pledge_violation" coredump metadata in REQUIRE_PROMISE()
Similar to LibC storing an assertion message before aborting, process
death by pledge violation now sets a "pledge_violation" key with the
respective pledge name as value in its coredump metadata, which the
CrashReporter will then show.
2021-01-20 21:01:15 +01:00
Nico Weber
2f82854e4a Revert "LibCore: Try to fix fuzzer build"
This reverts commit c5709c0aed.
2021-01-20 21:00:46 +01:00
Nico Weber
8ccd8b4a6f LibJS: Include <typeinfo> in AST.cpp
Without this, the oss-fuzz build says:

../Userland/Libraries/LibJS/AST.cpp:58:34: error: member access into incomplete type 'const std::type_info'
    return demangle(typeid(*this).name()).substring(4);
                                 ^
2021-01-20 21:00:27 +01:00
Ben Wiederhake
ab07a713bf LibC: Implement uniform random sampling without modulo bias 2021-01-20 19:19:34 +01:00
Nico Weber
c5709c0aed LibCore: Try to fix fuzzer build
This might fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29675
See also `man memfd_create`.
2021-01-20 19:14:04 +01:00
Nico Weber
98637bd549 WindowServer: In HighDPI mode, load high-res window buttons and high-res cursors
Bitmap::load_from_file("foo.png", 2) will now look for "foo-2x.png" and
try load that as a bitmap with scale factor 2 if it exists. If it
doesn't, it falls back to the 1x bitmap as normal.
Only places that know that they'll draw the bitmap to a 2x painter
should pass "2" for the second argument.

Use this new API in WindowServer for loading window buttons and
cursors.

As a testing aid, ctrl-shift-super-i can force HighDPI icons off in
HighDPI mode. Toggling between low-res and high-res icons makes it easy
to see if the high-res version of an icon looks right: It should look
like the low-res version, just less jaggy.

We'll likely have to grow a better API for loading scaled resources, but
for now this suffices.

Things to check:
- `chres 640 480` followed by `chres 640 480 2` followed by
  `chres 640 480`
- window buttons in window context menu (in task bar and on title bar)
  still have low-res icons
- ctrl-shift-super-i in high-res mode toggles sharpness of window
  buttons and of arrow cursorf
- arrow cursor hotspot is still where you'd expect
2021-01-20 10:28:27 +01:00
Nico Weber
5f9c42c404 LibGfx: Give Bitmap a scale factor
Gfx::Bitmap can now store its scale factor. Normally it's 1, but
in high dpi mode it can be 2.

If a Bitmap with a scale factor of 2 is blitted to a Painter with
scale factor of 2, the pixels can be copied over without any resampling.
(When blitting a Bitmap with a scale factor of 1 to a Painter with scale
factor of 2, the Bitmap is painted at twice its width and height at
paint time. Blitting a Bitmap with a scale factor of 2 to a Painter with
scale factor 1 is not supported.)

A Bitmap with scale factor of 2 reports the same width() and height() as
one with scale factor 1. That's important because many places in the
codebase use a bitmap's width() and height() to layout Widgets, and all
widget coordinates are in logical coordinates as well, per
Documentation/HighDPI.md.

Bitmap grows physical_width() / physical_height() to access the actual
pixel size. Update a few callers that work with pixels to call this
instead.

Make Painter's constructor take its scale factor from the target bitmap
that's passed in, and update its various blit() methods to handle
blitting a 2x bitmap to a 2x painter. This allows removing some gnarly
code in Compositor. (In return, put some new gnarly code in
LibGfxScaleDemo to preserve behavior there.)

No intended behavior change.
2021-01-20 10:28:27 +01:00
Linus Groh
c46056122a LibM: Add nextafter() and nexttoward() stubs
Only thing missing for Python to build the _math module! :^)
2021-01-18 22:28:56 +01:00
Linus Groh
8db54f9ef4 LibC: Return ENOSYS from clock_getres() rather than asserting
This is only a stub function for now, but we can make it even more
useful by just hardcoding an error return value rather than asserting.
2021-01-18 22:28:56 +01:00
Linus Groh
22b56d6a82 LibC: Make tzset() set daylight to 0
Quoting POSIX:

    https://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html

    The tzset() function also shall set the external variable daylight
    to 0 if Daylight Savings Time conversions should never be applied
    for the timezone in use; otherwise, non-zero.

We're already pretending to be in UTC+0 and setting timezone to 0
accordingly, we can also fake the absence of Daylight Savings Time.
2021-01-18 22:28:56 +01:00
Linus Groh
0d58e75910 LibC: Make tzset() set tzname to { "UTC", "UTC" }
Since tzset() itself pretends to succeed (it just sets timezone = 0 for
now), it seems unwise to leave tzname uninitialized. Since Serenity
already assumes UTC pretty much everywhere time is used, let's continue
that trend here. Quoting POSIX:

    https://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html

    The tzset() function shall use the value of the environment variable
    TZ to set time conversion information used by ctime(), localtime(),
    mktime(), and strftime(). If TZ is absent from the environment,
    implementation-defined default timezone information shall be used.

So we still don't care about TZ at all, but the program doesn't need to
know! :^)

This matches what musl libc ("UTC") and glibc ("GMT") do, see:

- https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c
- https://git.musl-libc.org/cgit/musl/tree/src/time/__tz.c
2021-01-18 22:28:56 +01:00
Linus Groh
3c68f557a9 LibC: Add wcstol() and wcstoll() stubs 2021-01-18 22:28:56 +01:00
Linus Groh
ec42f864d4 LibC: Add wcsncmp()
Taken from strncmp(), like wcscmp() in ef40ebb. :^)
2021-01-18 22:28:56 +01:00
Linus Groh
2cc3d68615 Kernel+LibC: Add _SC_TTY_NAME_MAX 2021-01-18 22:28:56 +01:00
Linus Groh
b432fd0bc0 LibC: Add TTY_NAME_MAX (32) 2021-01-18 22:28:56 +01:00
Andreas Kling
93831ef456 LibWeb: Very basic support for CSS flex-direction
The FFC now supports both vertical and horizontal flex layout, based on
the flex-direction property. It's still extremely naive, but at least
now you can be naive in two directions! :^)

This implementation of flexbox is going to take a lot of work, but at
least now we've gotten started.
2021-01-18 20:20:24 +01:00
Andreas Kling
3e8873b63e LibWeb: Add Layout::Box::margin_box_height() 2021-01-18 20:20:20 +01:00
Andreas Kling
149f10b0b9 LibWeb: Parse the CSS "flex-direction" property 2021-01-18 20:20:16 +01:00
Andreas Kling
fd7920fa8f LibWeb: Add a very naive Layout::FlexFormattingContext :^)
This is very dumb and only lays out its child boxes on a horizontal
line with their shrink-to-fit widths.

You have to start somewhere! :^)
2021-01-18 20:20:13 +01:00
Andreas Kling
d18bc9ccd2 LibWeb: Add Layout::Box::margin_box_width() 2021-01-18 20:20:07 +01:00
Andreas Kling
140463e833 LibWeb: Parse "display: flex" and create BlockBox layout nodes for them
I'm not 100% sure that BlockBox is the right layout node for flex
containers, but it's the most obviously fitting one we already have.
2021-01-18 20:20:00 +01:00
Linus Groh
6715ca3e16 LibELF: Remove unused m_global_symbol_lookup_func from DynamicObject
This was refactored in 3e815ad, leaving this unused member behind.
2021-01-18 19:17:52 +01:00
Andreas Kling
9e45594dc8 LibWeb: Stub out the PerformanceTiming object from Navigation Timing
Just have all the timing functions return 0 for now.

We can now run the Shynet JS on https://linus.dev/ although the XHR
is rejected by our same-origin policy.
2021-01-18 15:11:20 +01:00
Andreas Kling
c99e35485a LibWeb: Add support for XMLHttpRequest request headers
Implement XMLHttpRequest.setRequestHeader() and include the headers in
the outgoing HTTP request.
2021-01-18 14:02:58 +01:00
Andreas Kling
0639e77898 LibWeb: Make the Window object "inherit" from EventTarget :^)
Since Web::Bindings::WindowObject inherits from JS::GlobalObject, it
cannot also inherit from Web::Bindings::EventTargetWrapper.

However, that's not actually necessary. Instead, we simply set the
Window object's prototype to the EventTargetPrototype, and add a little
extra branch in the impl_from() function that turns the JS "this" value
into a DOM::EventTarget*.

With this, you can now call window.addEventListener()! Very cool :^)

Fixes #4758.
2021-01-18 12:18:29 +01:00
Andreas Kling
fd83918476 LibWeb: Move IDL attributes and functions to the prototype
Instead of each IDL interface wrapper having its own set of all the
attributes and functions, they are moved to the prototype. This matches
what we already do in LibJS.

Also, this should be spec compliant with the web as well, though there
may be *some* content out there that expects some things to be directly
on the wrapper since that's how things used to work in major browsers
a long time ago. But let's just not worry about that for now.

More work towards #4789
2021-01-18 12:18:29 +01:00
Andreas Kling
630cbc947a LibWeb: Construct the IDL interface prototype chains automatically
Have each IDL prototype trigger the construction of its own prototype.
2021-01-18 12:18:29 +01:00
Andreas Kling
ee7fa49b88 LibWeb: Actually instantiate all the web constructors/prototypes
We now instantiate all the generated web API constructors and expose
them on the window object. We also set the generated prototypes on
instantiated wrappers.

Also, we should obviously find a way to generate this code. :^)
2021-01-18 12:18:29 +01:00
Andreas Kling
252a98042d LibWeb: Generate constructor and prototype classes for IDL interfaces
This patch adds a FooPrototype and FooConstructor class for each IDL
interface we generate JS bindings for.

These classes are very primitive and don't do everything they should
yet, but we have to start somewhere. :^)

Work towards #4789
2021-01-18 12:18:29 +01:00
Andreas Kling
81839ea1bd LibJS: Add JS::NativeFunction to the forwarding header 2021-01-18 12:18:29 +01:00
Andreas Kling
0db6835e73 LibWeb: Move HTML::SubmitEvent functions out of line 2021-01-18 12:18:29 +01:00
Tom
1d621ab172 Kernel: Some futex improvements
This adds support for FUTEX_WAKE_OP, FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET,
FUTEX_REQUEUE, and FUTEX_CMP_REQUEUE, as well well as global and private
futex and absolute/relative timeouts against the appropriate clock. This
also changes the implementation so that kernel resources are only used when
a thread is blocked on a futex.

Global futexes are implemented as offsets in VMObjects, so that different
processes can share a futex against the same VMObject despite potentially
being mapped at different virtual addresses.
2021-01-17 20:30:31 +01:00
Nico Weber
1382bbfc57 LibGfx: Make Painter take the scale factor as constructor argument
I want to give Bitmap an intrinsic scale factor and this is a step
in that direction.

No behavior change.
2021-01-17 16:10:21 +01:00
Andreas Kling
7a0bc2fdb8 LibGfx: Convert all the dbg() in BMPLoader to dbgln()
Also get rid of the awkward IF_BMP_DEBUG macro while we're here.
2021-01-17 15:42:10 +01:00
Andreas Kling
fd441b954d LibWeb: Add fast_is<T>() for some DOM and layout node subclasses
The generic is<T>() uses dynamic_cast which is fine in the majority
of cases, but when one of them shows up in profiles, we can make it
faster by answering the is-a question manually.
2021-01-17 14:42:50 +01:00
Andreas Kling
4da913bfab LibJS: Replace ASTNode::class_name() with RTTI
This is only used for debugging anyway, so performance doesn't matter
too much.
2021-01-17 14:36:53 +01:00
Andreas Kling
bf0719092f Kernel+Userland: Remove shared buffers (shbufs)
All users of this mechanism have been switched to anonymous files and
passing file descriptors with sendfd()/recvfd().

Shbufs got us where we are today, but it's time we say good-bye to them
and welcome a much more idiomatic replacement. :^)
2021-01-17 09:07:32 +01:00
Andreas Kling
2cd16778b5 AudioServer+LibAudio: Pass audio buffers as Core::AnonymousBuffer
This was the last remaining user of shbufs! :^)
2021-01-17 09:07:32 +01:00
Linus Groh
b42f0b9650 LibC: Change a couple of ASSERT_NOT_REACHED() to TODO()
Just for semantic correctness and better visibility of those
unimplemented stub functions.
2021-01-17 08:43:46 +01:00
Linus Groh
95988b44a0 LibGfx: Let PNGLoader handle failed chunk decoding gracefully
decode_png_chunks() is not handling "critical" chunks, unlike
decode_png_size() for example. When we encounter a chunk decoding
failure, e.g. because not enough bytes were left to read, just continue
with decoding the bitmap - which will fail on its own, if we're missing
some required chunk(s).

Fixes #4984.
2021-01-17 08:09:20 +01:00
Andreas Kling
05dbfe9ab6 Kernel: Remove sys$shbuf_seal() and userland wrappers
There are no remaining users of this syscall so let it go. :^)
2021-01-17 00:18:01 +01:00
Andreas Kling
5522e8f59d Clipboard+LibGUI: Move clipboard service to anonymous files 2021-01-17 00:14:37 +01:00
Andreas Kling
1cb44ec5ee Everywhere: Remove more <AK/SharedBuffer.h> includes 2021-01-17 00:04:42 +01:00
Andreas Kling
fe96418a70 LibGfx: Remove remaining SharedBuffer support in Gfx::Bitmap 2021-01-17 00:03:33 +01:00
Andreas Kling
447e6da52c ImageDecoder: Use Core::AnonymousBuffer and Gfx::ShareableBitmap
...instead of sending shbufs back and forth. :^)
2021-01-16 23:58:57 +01:00
Andreas Kling
8a61aba1e5 LibGfx+LibGUI: Make Gfx::ShareableBitmap transmit indexed palettes 2021-01-16 23:58:47 +01:00
Andreas Kling
b5d98c0945 LibWeb+WebContent: Use anonymous files for OOPWV backing stores
To support this, the GUI process and the WebContent service will now
coordinate their backing store bitmaps. Each backing store can be
referred to by a serial ID, and we don't need to keep resending it
as a file descriptor.

We should probably do something similar in WindowServer. :^)
2021-01-16 23:21:52 +01:00
Andreas Kling
04b2aeef33 LibGfx: Make Gfx::Bitmap::create_shareable() use an anonymous file
Note that this is only used by OOPWV in LibWeb at the moment.
2021-01-16 23:21:52 +01:00
Andreas Kling
c16e36be48 LibVT: Convert dbgprintf() => dbgln() and remove some debug code 2021-01-16 23:21:52 +01:00
Andreas Kling
b818cf898e Kernel+Userland: Remove sys$shbuf_allow_all() and userland wrappers
Nobody is using globally shared shbufs anymore, so let's remove them.
2021-01-16 22:43:03 +01:00
Ben Wiederhake
ea5825f2c9 Kernel+LibC: Make sys$getcwd truncate the result silently
This gives us the superpower of knowing the ideal buffer length if it fails.
See also https://github.com/SerenityOS/serenity/discussions/4357
2021-01-16 22:40:53 +01:00
Ben Wiederhake
5dc29065e1 LibC: Avoid silent truncation after overlong realpath
The realpath syscall can attempt to return arbitrarily long paths, in particular
paths that are longer than PATH_MAX. The only way to detect this case is
checking whether 'rc', the true length of the returned path including NUL byte,
exceeds our buffer length. In such a case, the buffer contains invalid data.

All Serenity code calls LibC's realpath() with a nullptr buffer, meaning that
realpath is supposed to allocate memory on its own. All Serenity code can handle
arbitrarily long paths returned by LibC's realpath, so it is safe to "do the
dance" and repeat the syscall with a new buffer.

Ports are likely to be graceful in this regard, too. If a Port calls realpath()
with a pre-allocated buffer, however, there is nothing better we can do than
return a truncated buffer.
2021-01-16 22:40:53 +01:00
Ben Wiederhake
6f607742dd LibCore: Fix invalid errno
Noone seems to check 'errno' when using LibCore, but let's make sure it's correct anyway.
2021-01-16 22:40:53 +01:00
Ben Wiederhake
72ac97ef6a LibC: Fix memory leak in getcwd 2021-01-16 22:40:53 +01:00
Ben Wiederhake
ed857bc06e LibC: Fix memory leak in realpath 2021-01-16 22:40:53 +01:00
Brendan Coles
66b0012bfd LibELF: validate_program_headers: Validate PT_INTERP header p_filesz > 1 2021-01-16 22:39:26 +01:00
Tom
20f53c7462 LibGUI: Don't bubble window events up to parent windows
Always accept the events so that they don't bubble up to the
parent object.

Fixes #4967
2021-01-16 19:35:02 +01:00
Andreas Kling
04f95f9160 WindowServer+LibGUI: Pass the system theme using Core::AnonymousBuffer
This was the last remaining user of shbufs in WindowServer, and so
WindowServer no longer pledges "shared_buffer" :^)
2021-01-16 17:20:53 +01:00
Andreas Kling
9c6c18d9b6 LibCore+LibIPC: Add Core::AnonymousBuffer, an IPC-friendly buffer class
This will be used to migrate remaining clients off of shbufs.
2021-01-16 17:20:24 +01:00
Andreas Kling
01c2480eb3 Kernel+LibC+WindowServer: Remove unused thread/process boost mechanism
The priority boosting mechanism has been broken for a very long time.
Let's remove it from the codebase and we can bring it back the day
someone feels like implementing it in a working way. :^)
2021-01-16 14:52:04 +01:00
Andreas Kling
43109f9614 Kernel: Remove unused syscall sys$minherit()
This is no longer used. We can bring it back the day we need it.
2021-01-16 14:52:04 +01:00
asynts
adbb8d62d1 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-16 11:54:35 +01:00
asynts
6b7602d33b Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-16 11:54:35 +01:00
asynts
01879d27c2 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-16 11:54:35 +01:00
Andreas Kling
e8512b8cd7 LibC: Bump FD_SETSIZE to 1024
64 was cutting it pretty close, especially now as we start using file
descriptor passing more and more.

This (1024) matches many other systems, and if we need more there's
always sys$poll().
2021-01-16 11:26:53 +01:00
Andreas Kling
58b435f49e LibGfx: Short-circuit ShareableBitmap construction in IPC decoder
When decoding a ShareableBitmap that came over IPC, it's safe to assume
that it's backed by an anonymous file (since we just decoded it.)
2021-01-16 11:26:53 +01:00
Andreas Kling
f18d89b36d LibGfx: Make sure Bitmap::create_with_anon_fd() always closes if needed
If this is called with ShouldCloseAnonymousFile::Yes, it's entrusted
with closing the anon_fd and nobody else will take care of it.
2021-01-16 11:26:53 +01:00
Andreas Kling
1a157d3f50 LibGfx: Don't expose anon_fd inside Gfx::ShareableBitmap
Nobody outside needs to see this, so let's just hide it.
2021-01-16 11:26:53 +01:00
Andreas Kling
4277be356a WindowServer+LibGUI: Send menu item icons as Gfx::ShareableBitmap 2021-01-16 11:26:53 +01:00
Andreas Kling
7c1df68be3 LibGfx: Don't encode invalid Gfx::ShareableBitmap as IPC::File
IPC::File should only be used when there's an actual file to pass.
Invalid ShareableBitmaps don't have a backing file, so fix this by
first encoding a "valid" flag.
2021-01-16 11:26:53 +01:00
Andreas Kling
64610ca80e Everywhere: Remove a bunch of <AK/SharedBuffer.h> includes 2021-01-16 11:26:53 +01:00
Andreas Kling
ab0dad5ea2 WindowServer+LibGUI: Pass drag&drop bitmaps via Gfx::ShareableBitmap
This makes them backed by anonymous files instead of shbufs and also
simplifies the code significantly on both client and server side.
2021-01-16 11:26:53 +01:00
Nick Vella
fcf50af53d WindowServer, LibGUI: RefreshSystemTheme implementation
Adds a mechanism through which windowing clients can re-request an
UpdateSystemTheme message. This is currently used in SystemMenu's
ShutdownDialog to refresh it's theme when the dialog is instantiated.
2021-01-16 09:09:04 +01:00
Andreas Kling
6536a9c79a LibGfx: Fix fuzzer build (put anon_create() behind __serenity__) 2021-01-16 09:02:17 +01:00
Linus Groh
0187fd4fdd LibCoreDump: Expose arguments and environment
We can pull those from the coredump's ProcessInfo JSON, do some basic
sanity checks and expose them as ready-to-use Vector<String>s.
2021-01-15 23:26:47 +01:00
Linus Groh
7668e968af LibCoreDump+Crash{Daemon,Reporter}: Make backtraces thread-specific
We want to show an individual backtrace for each thread, not one
containing backtrace entries from all threads.

Fixes #4778.
2021-01-15 23:26:47 +01:00
Linus Groh
568cde5e23 Kernel+LibELF+LibCoreDump+CrashReporter: Use JSON for ProcessInfo
This is in preparation of adding (much) more process information to
coredumps. As we can only have one null-terminated char[] of arbitrary
length in each struct it's now a single JSON blob, which is a great fit:
easily extensible in the future and allows for key/value pairs and even
nested objects, which will be used e.g. for the process environment, for
example.
2021-01-15 23:26:47 +01:00
Andreas Kling
4839f36f5e LibGUI: Fix OpacitySlider hairline disappearing towards the left
Whoops, we were scaling the alpha channel of the hairline color along
with the RGB channels.
2021-01-15 23:24:07 +01:00
Andreas Kling
71f50b6e94 LibGUI: Window icons no longer need to be backed by shbufs
This allows us to remove Window::create_shared_bitmap() entirely.
2021-01-15 23:24:07 +01:00
Andreas Kling
333366a99d WindowServer+Taskbar: Send WM icon updates as Gfx::ShareableBitmap
Window icons in Taskbar were previously received in WM events with
shbuf ID's. Now that Gfx::ShareableBitmap is backed by anonymous files,
we can easily switch to using those.
2021-01-15 23:24:07 +01:00
Andreas Kling
633915e792 LibGfx: Make Gfx::ShareableBitmap use anonymous files instead of shbufs 2021-01-15 23:24:07 +01:00
Nico Weber
56cad36ef2 LibGfx: Make Painter::draw_rect() scale-aware
Needed for the window server minimize animation.

draw_rect() can't just call draw_line() because that isn't
draw_op()-aware. The draw_op()-awareness in Painter looks a bit ad-hoc,
but that's for another day.
2021-01-15 19:13:29 +01:00
Andreas Kling
0b0514d46b LibGUI+WindowServer: Use anonymous files for window backing stores :^)
This patch replaces the use of shbufs for GUI::Window backing stores
with the new anonymous files mechanism.

Backing bitmaps are now built on memory allocated with anon_create().
They are passed across the IPC socket as IPC::File. This means that
WindowServer now pledges "recvfd" and graphical clients need to pledge
"sendfd" to work.

To support the cached bitmap swapping optimization on the WindowServer
side, each backing store is assigned an incrementing serial number on
the client side. (This allows us to re-use an already mapped file.)
2021-01-15 13:57:00 +01:00
Andreas Kling
4d97b955e6 LibGfx: Allow creating a Gfx::Bitmap backed by an anonymous file
Gfx::Bitmap::create_with_anon_fd() creates such a Bitmap, and also
optionally takes ownership of the file, making sure to close() it
on destruction.
2021-01-15 13:56:54 +01:00
Andreas Kling
fb4993f067 Kernel: Add anonymous files, created with sys$anon_create()
This patch adds a new AnonymousFile class which is a File backed by
an AnonymousVMObject that can only be mmap'ed and nothing else, really.

I'm hoping that this can become a replacement for shbufs. :^)
2021-01-15 13:56:47 +01:00
Andreas Kling
96f8fcdcba LibGUI: Add a WindowBackingStore class
Instead of storing the back/front buffers of a GUI::Window as just
Gfx::Bitmap, wrap them in a WindowBackingStore class.

This will allow us to add more information alongside the bitmaps while
keeping the back/front swapping logic simple.
2021-01-15 10:54:19 +01:00
Andreas Kling
b8c3ea8b30 LibGUI: Hold on to notification icon until NotificationServer responds
This broke when switching IPC messages to support move-only types.
This pattern is not ideal, but the real fix for this will be using fd
passing instead of shbufs.

Fixes #4955.
2021-01-15 08:22:54 +01:00
Andreas Kling
f1f7bf567b LibIPC: Add an expressive way to close an IPC::File after sending it
If you don't need a file descriptor after sending it to someone over
IPC, construct it with IPC::File(fd, IPC::File::CloseAfterSending)
and LibIPC will take care of it for you. :^)
2021-01-14 09:50:14 +01:00
Andreas Kling
7f2d8e8884 LibIPC: Close received IPC::File fd's by default unless taken
When receiving a file descriptor over IPC, the receiver must now call
take_fd() on the IPC::File to take over the descriptor. Otherwise,
IPC::File will close the file on destruction.
2021-01-14 09:50:14 +01:00
Linus Groh
f253f68768 LibJS: Rename ErrorType::ProxyGetOwnDescriptor{Undef => Undefined}Return
This seems like an unnecessary and uncommon abbreviation.
2021-01-14 08:13:32 +01:00
Linus Groh
cab3049dcc LibJS: Rename ErrorType::ToObjectNullOr{Undef => Undefined}
This seems like an unnecessary and uncommon abbreviation.
2021-01-14 08:13:32 +01:00
Andrew Kaster
f67f8fdbf2 LibCore: Include fcntl.h in more places that we use fcntl for Lagom
Looks like it's more than just TcpServer where we do this :)
2021-01-13 15:02:11 +01:00
Andrew Kaster
a65ccfee3a LibCore: Include fcntl before using it for non-linux lagom builds
SOCK_NONBLOCK is a linux-ism that serenity and linux support. For lagom
builds, we use ioctl/fcntl to get a non-blocking socket the old
fashioned way. Some file re-org unhid the fcntl.h dependency of TcpServer,
so add the header explicitly.
2021-01-13 09:52:32 +01:00
AnotherTest
72be904259 LibLine: Use StringView::find() to find '::' in history entries
Fixes an issue mentioned in #4926.
2021-01-12 23:36:20 +01:00
Andreas Kling
1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Nico Weber
d551263b11 LibGfx: Make it possible to apply an (integer) scale to a Painter
This adds a scale factor to Painter, which will be used for HighDPI
support. It's also a step towards general affine transforms on Painters.

All of Painter's public API takes logical coordinates, while some
internals deal with physical coordinates now. If scale == 1, logical
and physical coordinates are the same. For scale == 2, a 200x100 bitmap
would be covered by a logical {0, 0, 100, 50} rect, while its physical
size would be {0, 0, 200, 100}.

Most of Painter's functions just assert that scale() == 1 is for now,
but most functions called by WindowServer are updated to handle
arbitrary (integer) scale.

Also add a new Demo "LibGfxScaleDemo" that covers the converted
functions and that can be used to iteratively add scaling support
to more functions.

To make Painter's interface deal with logical coordinates only,
make translation() and clip_rect() non-public.
2021-01-12 23:32:54 +01:00
Linus Groh
545b4879e4 LibGfx: Make Painter::draw_pixel() with thickness = 1 work with RGBA
The underlying fill_rect() works correctly, but the special case for
thickness = 1 was not blending the new color with the target pixel's
color, causing RGBA colors to be painted as their RGB counterpart.
2021-01-12 21:41:14 +01:00
AnotherTest
b2b3ccb12d LibCore: Don't create an RPC server when built for lagom
There's no reason to have this, and it will most likely fail anyway
(since there's likely no /tmp/rpc).
2021-01-12 16:21:34 +01:00
Andreas Kling
f2a6ee76c0 LibPthread: Add pthread_equal() 2021-01-12 13:42:45 +01:00
Andreas Kling
bee1145bdf LibPthread: Stub pthread_setcancelstate() and pthread_setcanceltype() 2021-01-12 13:40:48 +01:00
Andreas Kling
51a2d3c1fa Libraries: Remove LibUnwind
This was not used for anything.
2021-01-12 13:32:34 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00