Commit graph

4550 commits

Author SHA1 Message Date
Jean-Baptiste Boric
e4394b1605 LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::Bitmap
Instead of using a low-level, proprietary API inside LibGfx, let's use
Core::AnonymousBuffer which already abstracts anon_fd and offers a
higher-level API too.
2021-05-24 13:31:01 +02:00
Andreas Kling
de395a3df2 AK+Everywhere: Consolidate String::index_of() and String::find()
We had two functions for doing mostly the same thing. Combine both
of them into String::find() and use that everywhere.

Also add some tests to cover basic behavior.
2021-05-24 11:59:18 +02:00
Daniel Bertalan
875a2cbb71 LibVT+Kernel: Add support for setting cursor styles
This commit introduces support for 3 new escape sequences:
1. Stop blinking cursor mode
2. `DECTCEM` mode (enable/disable cursor)
3. `DECSCUSR` (set cursor style)

`TerminalWidget` now supports the following cursor types: block,
underline and vertical bar. Each of these can blink or be steady.
`VirtualConsole` ignores these (just as we were doing before).
2021-05-24 11:27:58 +02:00
Thomas Keppler
7dfc804d7d FontSettingsWidget: Reduce duplication in Label setup code
Pull out the Label updating code into its own function.
Ideally, we should probably transform this code to use its own widget
rather than doing this all in-line.
I.e., having a `FontSettingWidget` that that ties the FontPicker, Label
and Button into its own little widget, so that we can stay extendible in
the main widget and reduce duplication some more!
2021-05-24 09:08:23 +01:00
Thomas Keppler
a1f8c10fe5 FontSettingsWidget: Promote Labels as instance members
In order to not resolve the widgets twice, we capture them in ivars.
2021-05-24 09:08:23 +01:00
Thomas Keppler
883d0d2466 FontSettingsWidget: Display the default (fixed-width) font's name
Previously, the font was applied to the Labels but the name wasn't
updated on initial startup.
This meant that the Label's content was only correct in the default
state but not if the user changed the defaults.
2021-05-24 09:08:23 +01:00
Andreas Kling
d3f298c592 LibIPC: Fix unaligned u32 access in drain_messages_from_peer()
Caught by userspace UBSAN. :^)
2021-05-24 09:04:22 +02:00
Andreas Kling
8f2425125e LibGfx+Base: Tweak bitmap fonts to ensure glyph data is 4-byte aligned
When building userland with UBSAN enabled (#7434), we were getting
spammed to death by unaligned access errors.

Fix these by adding 2 bytes of padding to the FontFileHeader struct,
and adjusting all our font files to match the new format. :^)
2021-05-24 08:18:34 +02:00
Jelle Raaijmakers
22d8778437 LibGfx/Matrix: Add inverse() and friends
Matrix inversion comes in quite handy in 3D projections, so let's add
`Matrix<N,T>.inverse()`. To support matrix inversion, the following
methods are added:

* `Matrix.first_minor()`
  See: https://en.wikipedia.org/wiki/Minor_(linear_algebra)
* `Matrix.adjugate()`
  See: https://en.wikipedia.org/wiki/Adjugate_matrix
* `Matrix.determinant()`
  See: https://en.wikipedia.org/wiki/Determinant
* `Matrix.inverse()`
  See: https://en.wikipedia.org/wiki/Invertible_matrix
* `Matrix.operator/()`
  To support easy matrix division :-)

Code loosely based on an implementation listed here:
https://www.geeksforgeeks.org/adjoint-inverse-matrix/
2021-05-24 00:33:18 +01:00
Lynn
d3aae59478 tar: Ignore "extended headers"
Looking around online, it seems like this is normally a bit of
metadata that the extract operation can safely ignore.
2021-05-24 00:01:01 +01:00
Marcus Nilsson
6b85c7647c
Browser: Add context menu with history for back/forward button
Right clicking on back or forward will now show a context menu with
URLs to navigate to. Also added an optional argument for the number of
steps in go_back() and go_forward().
2021-05-23 23:58:00 +01:00
Max Wipfli
6837634f31 Calculator: Remove unused headers 2021-05-23 23:18:54 +01:00
Max Wipfli
bb38328d39 Calculator: Fix behavior when entering number starting with decimal
This fixes a bug where entering a number like ".15" would result in "15"
instead of "0.15"
2021-05-23 23:18:54 +01:00
Max Wipfli
7b53ca5309 Calculator: Use Checked to ensure entered values do not overflow
This replaces the types of m_int_value and m_frac_value with
Checked<u64> which makes it possible to check if the value overflowed
when entering a digit. If that happens, the digit will just be ignored.

This fixes #1263.
2021-05-23 23:18:54 +01:00
Max Wipfli
7a5407982f Calculator: Show decimal point immediately when typed 2021-05-23 23:18:54 +01:00
Max Wipfli
2675d25453 Calculator: Handle keydown events correctly with all keyboard layouts
This changes the keydown_event handler to use codepoints instead of key
codes for comparison if possible. This is so the functionality still
works as intended with keyboard layouts where e.g. typing '+' actually
results in KeyCode::Key_ExclamationPoint rather than KeyCode::Key_Plus.

This also removes the unnecessary call to atoi().
2021-05-23 23:18:54 +01:00
Tobias Christiansen
b53dac6e88 LibWeb: Add support for more pseudoclasses
:disabled, :enabled and :checked are now parsed and matched. There
surely are more nuances to consider.
2021-05-24 02:14:11 +04:30
Andreas Kling
4f4cde2379 LibDebug: Pre-allocate capacity for the LineProgram::LineInfo vector
This shaves another ~15% off of "bt 12" on my machine :^)
2021-05-23 23:17:26 +02:00
Andreas Kling
0bf3df28b9 LibDebug: Memoize resolved paths in DebugInfo::prepare_lines()
When loading debug info, we encounter the same filename over and over
(since files usually have many lines!) and we were wasting a ton of
time re-checking if the filename was part of the Toolchain or libgcc,
along with some other checks.

This patch makes prepare_lines() significantly faster by memoizing
the result of these checks per filename.

This makes "bt 12" ~25% faster (from 850ms to 650ms on my machine.) :^)
2021-05-23 23:01:11 +02:00
Josh Perry
d27616cf36 Hearts: Allow player to set their name
Added a new settings dialog to Hearts with a textbox to allow the
player to set a name, which is persisted in the Hearts config file.
2021-05-23 20:43:53 +01:00
Brian Gianforcaro
e706de8f91 LibM: Fix linking with LibM when compiling Userland without -O2
While playing with conditionally disabling -O2 optimization when
building the Userland subdirectory, I discovered that we can no longer
link errors without -O2. This happens as LibM.so doesn't link to
anything else, resulting in no stack protector implementation. It
appears that optimization somehow avoids this problem?

To fix this inject LibC/ssp.cpp as we do with in dynamic loader.
2021-05-23 20:17:00 +01:00
Daniel Bertalan
d23425bfc0 LibC: Use \010 for erasing instead of \0177
We ignore \0177 in the terminal -- as the ANSI standard dictates.

Fixes #7415
2021-05-23 19:32:31 +02:00
Gunnar Beutner
39f0739381 LibC+UE: Keep more unused chunked blocks around
Previously each malloc size class would keep around a limited number of
unused blocks which were marked with MADV_SET_VOLATILE which could then
be reinitialized when additional blocks were needed.

This changes malloc() so that it also keeps around a number of blocks
without marking them with MADV_SET_VOLATILE. I termed these "hot"
blocks whereas blocks which were marked as MADV_SET_VOLATILE are called
"cold" blocks because they're more expensive to reinitialize.

In the worst case this could increase memory usage per process by
1MB when a program requests a bunch of memory and frees all of it.

Also, in order to make more efficient use of these unused blocks
they're now shared between size classes.
2021-05-23 19:31:39 +02:00
Tobias Christiansen
bd2b17a70e LibGfx: Replace ellipse drawing algorithm
The new one is way more naive and not as fancy as the old one, but it
doesn't crash when trying to draw circles.
This algorithm just sweeps the angles required by the call, makes sure
each segment is at most 1 (pixel) long and just uses the standard
parameterization to find the coordinates of each point on the ellipse.
2021-05-23 18:28:27 +02:00
Gunnar Beutner
6a194869cf Hearts: Add key combinations to letting the AI play for you
A single card can be played with F10 while Shift-F10 toggles the AI
for the current as well as all future tricks.
2021-05-23 18:15:36 +02:00
Gunnar Beutner
2dfced2501 Hearts: Let the AI prefer lead cards for which other cards are in play
When picking a lead card the AI should avoid playing cards where it
knows that no other player has a lower value card of the same type.
2021-05-23 18:15:36 +02:00
Gunnar Beutner
647d0f9f8a Hearts: Fix sorting function for lead cards
The pick_lead_card() function sometimes picks the incorrect card
because the sorted_hand vector wasn't being sorted properly.
2021-05-23 18:15:36 +02:00
Brendan Coles
efef77a154 HexEditor: Add 'Go to Offset...' dialog 2021-05-23 18:13:49 +02:00
Jean-Baptiste Boric
dd6921bfc6 LibProtocol: Fix non-constant usage of PAGE_SIZE 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
d92b6423bf Utilities: Fix test-unveil INT_MAX include 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
8e6241b78b LookupServer: Fix missing POSIX includes 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
5ced9a3dfb ImageDecoder: Fix narrowing cast of loop count 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
4d332f3930 Utilities: Fix fgrep assertion include 2021-05-23 18:10:29 +02:00
Andreas Kling
873eb47d2b ps: Sort output by PID :^) 2021-05-23 11:26:19 +02:00
Andreas Kling
a1e133cc6b LibCore: Make ProcessStatisticsReader return results in a Vector
The HashMap API was overkill and made using this less ergonomic than
it should be.
2021-05-23 11:10:15 +02:00
Andreas Kling
a345a1f4a1 Userland: Mark subclasses of IPC::{Client,Server}Connection final 2021-05-23 09:53:55 +02:00
Andreas Kling
c1c252ddb2 LibIPC: Remove unnecessary IPC::ServerConnection::handshake()
This is no longer used by any of our IPC pairs.
2021-05-23 09:53:55 +02:00
Andreas Kling
2eceabdcfd LibGUI: Handle fast_greet stuff in WindowServerConnection constructor
Move the from handshake() to the constructor (and move the constructor
out-of-line while we're at it.)

This prepares getting rid of the handshake() mechanism since this is
the only remaining user.
2021-05-23 09:53:55 +02:00
Andreas Kling
0af69e8917 HackStudio: Greet language servers asynchronously
There's no need to wait for a response after we've sent the project
path to a newly connected language server.
2021-05-23 09:53:55 +02:00
Andreas Kling
67b47d62f3 WebContent: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
6b2f24018d RequestServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
bf33b5df6e WebSocket: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
03df8882df InspectorServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
78b57fcea3 NotificationServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
5424372d50 AudioServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
e7fc46879e LaunchServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
de07dab184 ImageDecoder: Remove unnecessary greet() message
This didn't do anything except induce an IPC stall during startup.
2021-05-23 09:53:55 +02:00
Brian Gianforcaro
6ebec090c3 Userland: Allow nc to connect by hostname instead of just address
Allow the user to pass in a hostname to the connect functionality
instead of just an ip address. The call to gethostbyname(..) handles
both seamlessly for us.

Update the argument name / usage message accordingly.
2021-05-23 09:19:16 +02:00
Daniel Bertalan
8262d6fc68 Utilities: Implement stty
This commit adds support for most of the useful POSIX-defined features.
This will come in handy when dealing with serial terminals that are
implemented in #7260.

Unfortunately, it isn't possible to use `Core::ArgsParser` due to the
oddity of the input format. Most of this code is therefore just data
wrangling and parsing.
2021-05-23 09:04:24 +04:30
Brian Gianforcaro
529a8664f4 Userland: Tweak the visual display of the bt utility
This patch adds a few minor visual features to the `bt` utility:
- Number each frame of the back trace.
- Color the address based on if it's in kernel or user space.
- Add a "frames:" heading to visually seperate the thread id.
- Rename "tid: <tid>" -> "thread: <tid>" as it's more visually
  appealing since it aligns vertically with "frames:"
- Add a visual " | " seperate between the address and symbol name.
2021-05-23 09:00:13 +04:30