Commit Graph

3546 Commits

Author SHA1 Message Date
Andreas Kling
cbfa211988 ProcFS: Align the buffer used for the CPUID brand string.
I'm not sure if this actually matters, but it won't hurt anyone to use
a 32-bit aligned buffer here.

Found by PVS-Studio.
2019-08-01 11:38:15 +02:00
Andreas Kling
a3ee35510f AK: Make Bitmap movable but not copyable.
We were falling back to an incorrect compiler-generated copy ctor for
this class, and let's not do that.

Found by PVS-Studio.
2019-08-01 11:34:36 +02:00
Andreas Kling
1a13145cb3 Kernel: Remove unnecessary null check in Process::fork()
Found by PVS-Studio.
2019-08-01 11:15:48 +02:00
Andreas Kling
e8b3a539b4 ProcessManager: Fix timer leak in ProcessStacksWidget
CObjects should really be reference-counted instead of this error-prone
(but convenient) model.

Found by PVS-Studio.
2019-08-01 11:12:35 +02:00
Andreas Kling
488d57750d pidof: Remove redundant bool check.
Found by PVS-Studio.
2019-08-01 11:07:44 +02:00
Andreas Kling
b2aea6b4ff Painter: Scaling RGBA32 bitmaps treated the source as alpha-less RGB32
Found by PVS-Studio.
2019-08-01 11:05:52 +02:00
Andreas Kling
be4d33fb2c Kernel+LibC: A lot of the signal handling code was off-by-one.
There is no signal 0. The valid ones are 1 (SIGHUP) through 31 (SIGSYS)
Found by PVS-Studio.
2019-08-01 11:03:48 +02:00
Andreas Kling
bd08664f05 LibC: In fgetc(), fread() will never return < 0.
Furthermore, fread() has already handled EOF, so there's no need to do
it again. If we read a character, return it, otherwise return EOF.
Note that EOF means "EOF or error" here.
2019-08-01 10:50:51 +02:00
Andreas Kling
caeb4b7a7e CEventLoop: Add a missing initializer to EventLoopTimer. 2019-08-01 10:49:31 +02:00
Andreas Kling
2923d39106 JsonParser: Merge the parsing of '\n' and '\r' in quoted strings 2019-08-01 10:45:37 +02:00
Andreas Kling
385e9268f4 CIODevice: printf() thought it was calling ::write() but it was write()
There's some confusion between the write syscall and CIODevice::write()
here. The internal write() returns a boolean, and has already whined
in case the syscall failed, so we don't need to do that again.
2019-08-01 10:41:04 +02:00
Andreas Kling
b9c8b3137d Lagom: Append to CMAKE_CXX_FLAGS instead of overwriting it. 2019-08-01 10:03:56 +02:00
Andreas Kling
db5a4c3409 GDirectoryModel: Tweak default width of permission bits column
Now that GTableView elides text content by default, this column was a
little too wide and ended up getting elided sometimes.
2019-07-31 21:21:20 +02:00
Andreas Kling
df51014834 GTableView: Elide cell content so it doesn't overflow the cell rect
I originally thought I'd have to implement text clipping in Painter for
this, but it seems like I can get away without doing that today. :^)

Fixes #390.
2019-07-31 21:18:01 +02:00
Andreas Kling
b46dbfe7e4 WindowServer: Fix bad assertion when setting wallpaper
The create_thread() syscall returns the thread ID now, not 0.
2019-07-31 18:04:06 +02:00
Andreas Kling
b36108dc3c WindowServer: Allow moving the Launcher window type. 2019-07-31 17:49:40 +02:00
Andreas Kling
ecb1b93d53 Ext2FS: Fix fetching of the major/minor device numbers for st_rdev.
This is how it seems to work:

- If ext2_inode.i_blocks[0] is non-zero, it contains the major/minor.
- Otherwise, it's in ext2_inode.i_blocks[1].
2019-07-31 17:24:54 +02:00
Conrad Pankoff
6b5fbad250 LibGUI: Simplify GTreeView ancestor traversal 2019-07-31 16:38:10 +02:00
Conrad Pankoff
fed0133109 FileManager: Show home directory by default, or command line argument
FileManager used to open up with the root directory loaded by default.
Now it will try to load either 1) the first argument specified on the
command line, 2) the user's home directory, or 3) the root directory.

Fixes #389
2019-07-31 16:33:21 +02:00
Conrad Pankoff
9b6e99f17e LibGUI: Reify intermediate nodes during index traversal
In the event where you want to find the index of a deeply-nested path
with a GFileSystemModel that hasn't yet traversed most of that path, it
is possible for a false negative failure to occur. This failure is
caused by the GFileSystemModel incorrectly bailing out of the search
when it hits the first unseen path segment that is not at the very end
of the path.

This patch fixes this problem by reifying the intermediate nodes during
that search and traversal process.
2019-07-31 16:33:21 +02:00
Robin Burchell
246c011497 Kernel: Port /proc/PID/fds to JSON 2019-07-31 10:48:53 +02:00
Andreas Kling
f10e850644 HashTable: Assert on iteration attempt over table during clear/rehash
It doesn't seem sane to try to iterate over a HashTable while it's in
the middle of being cleared. Since this might cause strange problems,
this patch adds an assertion if an iterator is constructed during
clear() or rehash() of a HashTable.
2019-07-31 10:23:24 +02:00
Andreas Kling
eccc3c3ef0 WindowServer: Control WSClientConnection's window list teardown better
A lot of things happen in response to window destruction, and some of
them may call into the window's WSClientConnection and ask it to look
through its window list.

If we're right in the middle of tearing down the window list, it's not
a great idea to start iterating over it.

Fixes #386.
2019-07-31 10:23:12 +02:00
Robin Burchell
a82c60b22a Add Result<>, to use with/complement Error
An operation often has two pieces of underlying information:

* the data returned as a result from that operation
* an error that occurred while retrieving that data

Merely returning the data is not good enough. Result<> allows exposing
both the data, and the underlying error, and forces (via clang's
consumable attribute) you to check for the error before you try to
access the data.
2019-07-31 09:06:39 +02:00
Robin Burchell
7dd25141cd Add Error<>
Put simply, Error<> is a way of forcing error handling onto an API user.

Given a function like:

    bool might_work();

The following code might have been written previously:

    might_work(); // but what if it didn't?

The easy way to work around this is of course to [[nodiscard]] might_work.
But this doesn't work for more complex cases like, for instance, a
hypothetical read() function which might return one of _many_ errors
(typically signalled with an int, let's say).

    int might_read();

In such a case, the result is often _read_, but not properly handled. Like:

    return buffer.substr(0, might_read()); // but what if might_read returned an error?

This is where Error<> comes in:

    typedef Error<int, 0> ReadError;
    ReadError might_read();

    auto res = might_read();
    if (might_read.failed()) {
        switch (res.value()) {
        case EBADF:
            ...
        }
    }

Error<> uses clang's consumable attributes to force failed() to be
checked on an Error instance. If it's not checked, then you get smacked.
2019-07-31 09:06:39 +02:00
Robin Burchell
28362fcc57 Optional: Add consumable checks
These will, when building with clang, prevent using Optional::value
without first checking Optional::has_value() - at compile time.
2019-07-31 09:06:39 +02:00
Andreas Kling
993ab84a0d GDirectoryModel: Add "modification time" column.
Fixes #373.
2019-07-31 07:09:35 +02:00
Andreas Kling
10b4c92e21 GVariant: Add Type::UnsignedInt. 2019-07-31 07:07:59 +02:00
Andreas Kling
34db7067fa GDirectoryModel: Shrink the Permissions and Inode columns a little bit. 2019-07-31 06:50:01 +02:00
Robin Burchell
ae231cfe3d Lagom: Set project() right away
Checking CMAKE_CXX_COMPILER_ID before project() does not work.
2019-07-30 15:28:37 +02:00
Andreas Kling
0f3d191a70 LibCore: Rename CFileStreamReader => CIODeviceStreamReader. 2019-07-30 15:16:39 +02:00
rhin123
c869d62e16 GFilePicker: Edit file name on opening window
Overlooked that you can't have two GWidgets
selected at the same time, whoops!
2019-07-30 09:19:14 +02:00
Conrad Pankoff
973c2d9bfd Kernel: fix typo regarding floppy drives in init_stage2 2019-07-30 09:16:47 +02:00
Andreas Kling
e6db1b81b8 AudioServer: Begin work on a new IPC API style.
The goal here is to generate most of this code from IPC protocol
descriptions, but for now I've spelled them all out to get started.

Each message gets a wrapper class in the ASAPI_Client or ASAPI_Server
namespace. They are convertible to and from the old message structs.

The real hotness happens when you want to make a synchronous request
to the other side:

    auto response = send_sync<ASAPI_Client::GetMainMixVolume>();

Each request class knows his corresponding response class, so in the
above example, "response" will be an ASAPI_Server::DidGetMainMixVolume
object, and we can get the volume like so:

    int volume = response.volume();

For posting messages that don't expect a response, you can still use
post_message() since the message classes are convertible:

    post_message(ASAPI_Server::DidGetMainMixVolume(volume));

It's not perfect yet, but I already really like it. :^)
2019-07-29 22:39:20 +02:00
rhin123
a175e76948 TextEditor: Include extension during SaveAs
When we save-as in the text editor we now auto-populate GFilePicker /w
the current name & extension.
2019-07-29 20:46:31 +02:00
Drew Stratford
80cb833594 Minesweeper: refactor on_square_clicked and flood_mark
Both on_square_clicked and flood_mark were very similar so I've
introduced the on_square_clicked_impl function which is now
called by on_square_clicked and flood_fill.
2019-07-29 19:34:31 +02:00
Drew Stratford
6b757a152a Minesweeper: updated flood_fill to use Queue 2019-07-29 19:34:31 +02:00
Drew Stratford
77cb83b629 Minesweeper: make Field::flood_fill iterative
This change uses an iterative traversal to avoid stack overflows
in, the previously recursive, flood_fill.
2019-07-29 19:34:31 +02:00
Andreas Kling
7cf4706a85 Meta: Advise people to wrap commit messages as 72 characters instead
GitHub wraps shortlog messages at 72 characters, and this seems to be
the norm anyway, so let's just adapt.
2019-07-29 19:15:08 +02:00
Andreas Kling
15afc88ffe AudioServer: Add a "main mix volume" and a simple program to get/set it
Give the mixer a main volume value (percent) that we scale all the
outgoing samples by (before clipping.)

Also add a simple "avol" program for querying and setting the volume:

- "avol" prints the current volume.
- "avol 200" sets the main mix volume to 200%
2019-07-29 19:06:58 +02:00
Andreas Kling
2feddc58bb Kernel: Oops, forgot to add Lock.cpp. 2019-07-29 12:00:14 +02:00
Andreas Kling
57c29491a3 Kernel+AK: Remove AK/StdLibExtras.cpp, moving kernel stuff to Kernel/.
We had some kernel-specific gizmos in AK that should really just be in the
Kernel subdirectory instead. The only thing remaining after moving those
was mmx_memcpy() which I moved to the ARCH(i386)-specific section of
LibC/string.cpp.
2019-07-29 11:58:44 +02:00
Andreas Kling
c59fdcc021 Kernel: Move Lock code out-of-line.
It's so big and chunky anyway, it's silly to expand it everywhere.
This makes it a lot easier to read function disassembly dumps.
2019-07-29 11:19:04 +02:00
Andreas Kling
5ded77df39 Kernel+ProcessManager: Let processes have an icon and show it in the table.
Processes can now have an icon assigned, which is essentially a 16x16 RGBA32
bitmap exposed as a shared buffer ID.

You set the icon ID by calling set_process_icon(int) and the icon ID will be
exposed through /proc/all.

To make this work, I added a mechanism for making shared buffers globally
accessible. For safety reasons, each app seals the icon buffer before making
it global.

Right now the first call to GWindow::set_icon() is what determines the
process icon. We'll probably change this in the future. :^)
2019-07-29 07:26:01 +02:00
Andreas Kling
7356fd389f aplay: s/Sample/Progress/ in the output. It's all in the details! 2019-07-28 21:56:19 +02:00
Andreas Kling
66f8ea92cb LibAudio: Silence some debug spam in the WAV loader. 2019-07-28 21:54:34 +02:00
Andreas Kling
ae4a9e017a LibAudio+aplay: Make the aplay output look a little funner.
Show some information about the file we're playing, and display how many
samples we've played out of how many total.

This might be a bit buggy as I haven't tested it with many different files,
but it's a start. :^)
2019-07-28 21:52:30 +02:00
Andreas Kling
b44d3faa1c LibAudio: WAV: Don't emit the very last sample in each decoded batch.
This is a total hack, because I haven't really looked into why these are
happening. Somehow we're producing one extra sample and it's glitching
up the sound stream ever so slightly.
2019-07-28 21:34:47 +02:00
Andreas Kling
be31e2232c AudioServer+LibAudio: Make mixing queue-based instead of buffer-based.
Each client connection now sets up an ASBufferQueue, which is basically a
queue of ABuffers. This allows us to immediately start streaming the next
pending buffer whenever our current buffer runs out of samples.

This makes the majority of the skippiness go away for me. :^)

Also get rid of the old PlayBuffer API, since we don't need it anymore.
2019-07-28 21:34:47 +02:00
Andreas Kling
66db6f4f92 AK: Add Queue::clear() to clear out a Queue. 2019-07-28 21:34:47 +02:00