Commit graph

32390 commits

Author SHA1 Message Date
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
Lucas CHOLLET ed0f4bdfaf Shell: Port to LibMain 2022-01-09 03:22:10 +03:30
Lucas CHOLLET 3fa5be655d LibCore: Add a wrapper for setsid() 2022-01-09 03:22:10 +03:30
Leonardo Nicolas 9aa0cf3265 FileManager: Do not allow rename files that cannot be modified
Pressing the F2 key on files that the user doesn't have permission was
opening the file name for editing.

This patch fixes the issue disabling the file name editing when the user
doesn't have permission to do it.

To reproduce the issue:

1) Open the File Manager
2) Click on the /etc directory
3) Select any file
4) Press the F2 key
5) Update the file name
2022-01-09 00:47:48 +01:00
Pankaj Raghav 0a1b34c753 Kernel: Use DMA helper everywhere
Port UCHI, AC97, SB16, BMIDEChannel and AHCIPort to use the helper to
allocate DMA buffers.
2022-01-09 00:45:38 +01:00
Pankaj Raghav 59da9bd0bd Kernel: Overload DMA helper without Physical Page output parameter
Not all drivers need the PhysicalPage output parameter while creating
a DMA buffer. This overload will avoid creating a temporary variable
for the caller
2022-01-09 00:45:38 +01:00
Pankaj Raghav e79f94f998 Kernel: Set Cacheable parameter to NO explicitly in DMA helpers
The cacheable parameter to allocate_kernel_region should be explicitly
set to No as this region is used to do physical memory transfers. Even
though most architectures ignore this even if it is set, it is better
to make this explicit.
2022-01-09 00:45:38 +01:00
Mustafa Quraish c5fb55725e PixelPaint: Only clear LayerListWidget if there are no editors left
Previously, we would clear it if there was still an editor open. This
was not obvious because it was only visible when an inactive tab was
closed, since closing an active tab would trigger an editor change
which would re-fill the layers widget.
2022-01-09 00:19:47 +01:00
Mustafa Quraish 6c60bf7537 PixelPaint: Move request_close_editor() logic inside ImageEditor
This allows us to request any specific editor to close itself. Earlier,
this could only be done for the currently active editor, so trying to
close inactive tabs would not work properly.
2022-01-09 00:19:47 +01:00
Mustafa Quraish c2b3bab984 PixelPaint: Move save and save_as logic inside ImageEditor
Previously the save logic was hardcoded to only work for the active
editor, so closing editors in the background would not properly
handle the unsaved changes. This patch brings us closer to be able
to fix that problem.
2022-01-09 00:19:47 +01:00
Maciej b3e47f0bd5 Documentation: Update glyph/x-fonteditor format description 2022-01-09 00:18:46 +01:00
Maciej 310fdd87d1 ClipboardHistory: Update to new glyph format 2022-01-09 00:18:46 +01:00
Maciej 1d98499234 FontEditor: Support selection ranges
This makes editing much easier, e.g. you don't need longer to copy
hundreds of glyphs one by one.

It has some flaws, e.g. it's not integrated with undo stack,
but we need to start with something!
2022-01-09 00:18:46 +01:00
Maciej ad2551e6b8 AK: Add ByteBuffer::append(char) 2022-01-09 00:18:46 +01:00
Maciej 22b3c25f10 FontEditor: Save scale to config file 2022-01-09 00:18:46 +01:00
Maciej 4d4764e0fb FontEditor: Display something for emoji glyphs
This commit makes FontEditor displaying emojis in GlyphMapWidget. They
are not editable, what is marked by red background of a glyph.

Additionally, a proper information is displayed in statusbar.

Fixes #10900.
2022-01-09 00:18:46 +01:00
electrikmilk 923bec28b7 Base: Add Serif font
Add default Serif font.
2022-01-09 00:14:05 +01:00
Liav A ac2c01320b Kernel/PCI: Split host bridge code from the Access singleton
Two classes are added - HostBridge and MemoryBackedHostBridge, which
both derive from HostController class. This allows the kernel to map
different busses from different PCI domains in the same time. Each
HostController implementation doesn't take the Address object to address
PCI devices but instead we take distinct numbers of the PCI bus, device
and function as it allows us to specify arbitrary PCI domains in the
Address structure and still to get the correct PCI devices. This also
matches the hardware behavior of PCI domains - the host bridge merely
takes memory operations or IO operations and translates them to
addressing of three components - PCI bus, device and function.

These changes also greatly simplify how enumeration of Host Bridges work
now - scanning of the hardware depends on what the Host bridges can do
for us, so in case we have multiple host bridges that expose a memory
mapped region or IO ports to access PCI configuration space, we simply
let the code of the host bridge to figure out how to fetch data for us.

Another semantical change is that a PCI domain structure is no longer
attached to a PhysicalAddress, so even in the case that the machine
doesn't implement PCI domains, we still treat that machine to contain 1
PCI domain to treat that one host bridge in the same way, like with a
machine with one or more PCI domains.
2022-01-08 23:49:26 +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
Rummskartoffel 1b8012e5c7 UserspaceEmulator: Fail with EINVAL for mmap with size 0
This is the behaviour specified by POSIX and also the behaviour of the
real kernel, so let's follow that while emulating.
2022-01-08 23:43:09 +01:00
Rummskartoffel 89502fc329 UserspaceEmulator: Interpret zero-alignment as page-sized alignment
This commit fixes an issue where zero-alignment would lead to the
requested range being allocated outside of the total available range,
hitting an assert in RangeAllocator::allocate_anywhere().
2022-01-08 23:43:09 +01:00
Linus Groh 963b0f76cf LibJS: Remove now unused VM::{set_,}last_value()
This was effectively replaced by correct use of completions, including
UpdateEmpty semantics.
2022-01-08 23:43:03 +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
creator1creeper1 f73afbb5ae AK: Reorder functions in FixedArray so that mutable comes before const 2022-01-08 22:54:05 +01:00
creator1creeper1 18a2685c6a AK: Reorder access in FixedArray so that m_size comes before m_elements 2022-01-08 22:54:05 +01:00
creator1creeper1 3c05261611 AK+Everywhere: Make FixedArray OOM-safe
FixedArray now doesn't expose any infallible constructors anymore.
Rather, it exposes fallible methods. Therefore, it can be used for
OOM-safe code.
This commit also converts the rest of the system to use the new API.
However, as an example, VMObject can't take advantage of this yet,
as we would have to endow VMObject with a fallible static
construction method, which would require a very fundamental change
to VMObject's whole inheritance hierarchy.
2022-01-08 22:54:05 +01:00
Andreas Kling a7b70c62d7 Kernel: Fix broken disk cache behavior with O_DIRECT
When writing into a block via an O_DIRECT open file description, we
would first flush every dirty block *except* the one we're about to
write into.

The purpose of flushing is to ensure coherency when mixing direct and
indirect accesses to the same file. This patch fixes the issue by only
flushing the affected block.

Our behavior was totally backwards and could end up doing a lot of
unnecessary work while avoiding the work that actually mattered.
2022-01-08 20:15:25 +01:00
Andreas Kling 95df924e0e Kernel: Remove EWHYTHO error code :^)
This error code was a hack for catching error handling mistakes in the
kernel. It's no longer used anywhere.
2022-01-08 20:10:58 +01:00
Andreas Kling 065f79990e Kernel: Rename DiskCache::get() to ensure()
Since this function always returns a CacheEntry& (after potentially
evicting someone else to make room), let's call it "ensure" instead of
"get" to match how we usually use these terms.
2022-01-08 19:57:33 +01:00
Andreas Kling 0e70759271 AK: Unbreak ref counting hooks in RefCounted
Same fix as 5871072ed3, but for userspace
this time. Regressed in c4a0f01b02.
2022-01-08 19:38:00 +01:00
Andreas Kling 01823746e3 Kernel: Remove redundant disk cache dirty flag in BlockBasedFileSystem
The disk cache is dirty if the dirty list has entries. No need to track
this in a separate flag.
2022-01-08 19:38:00 +01:00
Daniel Bertalan a99685ece7 LibC: Remove #ifdef AK_OS_MACOS checks from shadow.h
These checks were added because macOS doesn't have `shadow.h`, so we
would end up including our own LibC's `shadow.h` when we built Lagom.

All inclusions of this header in our code base are now guarded by
`#ifndef AK_OS_BSD_GENERIC`, so these checks are now pointless.
2022-01-08 19:22:00 +01:00
Daniel Bertalan b9c753f6f9 LibC+LibDl: Declare functions taking no arguments as taking void
In C++, a function declaration with an empty parameter list means that
the function takes no arguments. In C, however, it means that the
function takes an unspecified number of parameters.

What we did previously was therefore non-conforming. This caused a
config check to fail in the curl port, as it was able to redeclare
`rand` as taking an int parameter.
2022-01-08 19:22:00 +01:00
Daniel Bertalan a221596614 LibC: Fix typo: fgetround => fegetround 2022-01-08 19:22:00 +01:00
Simon Woertz 47f4e54cdc Lagom: Execute LibPDF unit tests on the host
Add lagom unit tests for `LibPDF`.
2022-01-08 18:57:55 +01:00
Simon Woertz c857b5d22f LibPDF: Convert PDF::Parser::m_document from RefPtr to WeakPtr
Otherwise both `PDF::Document` and `PDF::Parser` have a `RefPtr`
pointing to each other which leads to a memory leak due to a circular
dependency.
2022-01-08 18:57:55 +01:00
Simon Woertz d8013f9c3a Tests: Add test cases for #10702 and #10717
Add test cases for parsing an empty file and a truncated file.
2022-01-08 18:57:55 +01:00
Simon Woertz 07a557194c Tests: Add base structure for LibPDF unit tests
Add a unit test for each sample pdf file that currently exists in the
anon user's `~/Document/pdf` directory.
- linear.pdf
- non-linearized.pdf
- complex.pdf

Each test ensures that the pdf document is parsed and that the page
count is the expected one.
2022-01-08 18:57:55 +01:00
Andrew Kaster e687e5ba74 LibCrypt: Link the SHA2 hash implementation into LibCrypt privately
Previously, we linked LibCrypt against LibCrypto. This creates a
circular symbol dependency between LibCore, LibCrypto and LibCrypt.
LibCrypto uses Core::DateTime, LibCrypt uses Crypto::SHA2, and LibCore
uses crypt in Core::Account. The GNU toolchain massages the DT_NEEDED
lines of each library and applications that use each library such that
the Loader finds all the symbols as necessary. However, when using the
Clang toolchain, the circular library dependency is not as tolerated.
We get a symbol not found error in the Loader at runtime, and the app in
question crashes.

Now, we build the SHA2.cpp implementation file into LibCrypt using an
object library and `-fvisibility=hidden -fvisibility-hidden-inlines`.
This adds the implementation in a way that only creates STB_LOCAL
symbols and should avoid nasty ODR problems in the future.

An alternative approach to resolving this dependency would be to move
Core::DateTime to AK, or to make Crypto::ASN1::parse_utc_date return a
struct tm instead of a Core::DateTime. One of those approaches to
remove the LibCore dependency from LibCrypto should probabably be
investigated further in the future.

The net effect of removing this circular library dependency is that one
can now build and run the python3 port with the Clang toolchain :^)
2022-01-08 18:56:29 +01:00
Andrew Kaster 3ff7b76502 Ports: Don't try to enable PGO for python3 when cross-compiling
The --enable-optimizations flag attempts to enable PGO. Profile-guided
optimization is great in general, but will not work at all when doing a
cross-compile. If there's a more fine-grained flag for generic
optimization levels that doesn't try to do PGO, we should enable that
instead. The flag also enables `-fno-semantic-interposition`, but our
GCC patches enable that by default for -fPIC anyway, so that's not
necessary.
2022-01-08 18:56:29 +01:00
Andrew Kaster 498d3d8537 Ports: Add $READELF and $HOST_READELF variables to include scripts
Ports such as python require a distinction between host readelf and
target readelf. Set a toolchain-specific varaible for these, but be sure
save off the host readelf binary in case anyone needs it later.

This is part of allowing python to build with the Clang toolchain.
2022-01-08 18:56:29 +01:00
Andrew Kaster b85c785c12 Ports: Add /usr/local/lib to openssl's library search path
This allows building with the clang toolchain. We might consider a more
global patch in the future for this, it seems a lot of packages need
help to find /usr/local/lib.
2022-01-08 18:56:29 +01:00
Andrew Kaster 0a04f4ae86 Ports: Patch sqlite's configure script to let it build as a shared lib
By telling the libtool-related configure checks that the serenity
platform does in fact support shared libs, we can get a VERSYM-free
shared lib out of sqlite. This probably applies to other ports as well.

Suggested-by: Daniel Bertalan <dani@danielbertalan.dev>
2022-01-08 18:56:29 +01:00
Andreas Kling 5871072ed3 Kernel: Unbreak ref counting hooks in ListedRefCounted & RefCounted
We have to mind the constness of the pointer when using "requires" to
check if a member function can be invoked.

I regressed this in c4a0f01b02.
2022-01-08 17:25:37 +01:00
Andreas Kling e53571ef59 Kernel: Dump memory regions when crashing in ring 0 2022-01-08 16:31:14 +01:00
Andreas Kling b86443f0e1 Kernel: Lock weak pointer revocation during listed-ref-counted unref
When doing the last unref() on a listed-ref-counted object, we keep
the list locked while mutating the ref count. The destructor itself
is invoked after unlocking the list.

This was racy with weakable classes, since their weak pointer factory
still pointed to the object after we'd decided to destroy it. That
opened a small time window where someone could try to strong-ref a weak
pointer to an object after it was removed from the list, but just before
the destructor got invoked.

This patch closes the race window by explicitly revoking all weak
pointers while the list is locked.
2022-01-08 16:31:14 +01:00
Andreas Kling c4a0f01b02 AK+Kernel: Use requires expression when invoking ref counting hooks
Replace some old-school template trickery with C++20 requires. :^)
2022-01-08 16:31:14 +01:00
Andreas Kling ec74afdb8d Meta: Discourage excessive "feng shui programming" in CONTRIBUTING.md 2022-01-08 16:31:14 +01:00
Rummskartoffel ba0d46e31a gzip: Don't fail when trying to compress empty files
Given an empty file, gzip would try to create a zero-size memory mapping
of that file, which would fail with EINVAL.
2022-01-08 15:29:38 +01:00
Rummskartoffel 748218d5d0 gzip: Port to LibMain 2022-01-08 15:29:38 +01:00