Commit Graph

262 Commits

Author SHA1 Message Date
Andreas Kling
c029f39895 SystemServer: Don't spawn a TTYServer on on /dev/tty0
tty0 receives input while WindowServer is up, which meant that having
a shell on tty0 would cause commands typed into Terminal to run twice,
once in Terminal's shell, and once on the tty0 shell.

Long term we shouldn't send input to any VirtualConsole while the
WindowServer is up, so this just fixes the immediate weirdness. :^)
2019-08-17 14:19:18 +02:00
Sergey Bugaev
6778abb999 Kernel+SystemServer: Mount filesystems and start TTYServer in userspace 2019-08-17 12:07:55 +02:00
Andreas Kling
f7251c74a9 WindowServer: Let's run without buffer flipping by default
Instead of having a special mode that we only use in QEMU, let's bring
ourselves closer to real hardware by not relying on the QEMU VGA card.
2019-08-16 17:07:40 +02:00
Andreas Kling
14888bd992 WindowServer: Add a mode for running without buffer flipping
We can't rely on all hardware to give us a way to flip between the back
and front buffer.

This mode should actually perform slightly better but may show some tearing
as we don't have a way to know when we're in vertical retrace.
2019-08-15 15:11:31 +02:00
Andreas Kling
af6483cabb WindowServer: Fix incorrect "window left" event after button drag
This fixes an issue where we'd send a "cursor has left the window"
message incorrectly to the client after a button was clicked and the
user moved the cursor a little without releasing the button.

The issue was that we didn't update the 'hovered_window' out param
in mouse event processing in the case where we had an active input
window set.
2019-08-12 18:36:33 +02:00
Conrad Pankoff
67a4256a98 Server: Add TTYServer, a rudimentary text console manager
This should probably call out to a login program at some point. Right now
it just puts a root terminal on tty{1,2,3}.

Remember not to leave your Serenity workstation unattended!
2019-08-12 13:52:20 +02:00
Conrad Pankoff
53ddbce0b3 Kernel: Use established device name and number for framebuffer
This is to prepare for other framebuffer implementations, for which it
would be inappropriate to use the /dev/bxvga device name.
2019-08-12 12:56:55 +02:00
Andreas Kling
028e834bb4 WindowServer: Use range-for with InlineLinkedList 2019-08-08 13:40:47 +02:00
Andreas Kling
3100e8dee5 IPCCompiler+AudioServer: Accept "//"-style comments in IPC defintions 2019-08-03 21:29:09 +02:00
Andreas Kling
8e684f0959 AudioServer: Port to the new generated IPC mechanism
Fork the IPC Connection classes into Server:: and Client::ConnectionNG.
The new IPC messages are serialized very snugly instead of using the
same generic data structure for all messages.

Remove ASAPI.h since we now generate all of it from AudioServer.ipc :^)
2019-08-03 19:49:19 +02:00
Andreas Kling
3c1bad99a2 AudioServer: Link against LibIPC
We're not using any of the functionality yet, but soon...
2019-08-03 17:25:54 +02:00
Andreas Kling
4fc15c9e6e AudioServer: The EnqueueBuffer response needs a success boolean
This was already in the current version of the code, I'm just updating
the soon-to-be-current IPC protocol version of it. :^)
2019-08-03 16:41:58 +02:00
Andreas Kling
aa8a3d4a89 IPCCompiler: Start working on a simple IPC definition language
Instead of doing everything manually in C++, let's do some codegen.
This patch adds a crude but effective IPC definition parser, along
with two initial definition files for the AudioServer's client and
server endpoints.
2019-08-03 15:17:41 +02:00
Andreas Kling
1c50dce7d2 SystemServer: Remove always-true "if (pid == 0)" check
This code should probably be structured differently to handle things
like children dying, etc. But not right now.

Found by PVS-Studio.
2019-08-01 14:08:43 +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
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
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
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
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
7cabe6433e AudioServer: Add a buffer queue so we can buffer some sound.
The idea here is to keep a small number of sample buffers queued in the
AudioServer so we don't get caught without something to play.
2019-07-28 18:27:32 +02:00
Andreas Kling
d4892b3fdc WindowServer+LibGUI: Remove old "icon path" way of doing things.
Now that we can set icons directly "by bitmap", there's no need for passing
around the icon paths anymore, so get rid of all the IPC and API related
to that. :^)
2019-07-28 10:24:58 +02:00
Andreas Kling
841b2e5d13 WindowServer+LibGUI: Pass window icons as shared buffers rather than paths.
Now that we support more than 2 clients per shared buffer, we can use them
for window icons. I didn't do that previously since it would have made the
Taskbar process unable to access the icons.

This opens up some nice possibilities for programmatically generated icons.
2019-07-28 10:18:49 +02:00
Andreas Kling
6a0319697c AudioServer: Let ASMixer notify ASClientConnection about finished buffers.
Instead of posting a message directly from ASMixer, notify the client via
ASClientConnection::did_finish_playing_buffer().
2019-07-27 21:17:14 +02:00
Andreas Kling
e6eba24405 WindowServer+AudioServer: Add some missing C_OBJECT macros. 2019-07-27 18:43:59 +02:00
Andreas Kling
60a9a232be AudioServer: Remove some outdated comments. 2019-07-27 18:41:24 +02:00
Andreas Kling
5e01dde7b1 Audio: Make ABuffer sit on top of a SharedBuffer.
This allows us to carry the same buffer all the way from the WAV loader
to the AudioServer mixer.

This alleviates some of the stutter, but there's still a noticeable
skip when switching buffers. We're gonna need to do better. :^)
2019-07-27 18:17:17 +02:00
Andreas Kling
b805f112c2 AudioServer: Avoid two heap allocations per mixing iteration. 2019-07-27 17:43:00 +02:00
Andreas Kling
426248098c Audio: Make basic streaming WAV playback work.
I had to solve a bunch of things simultaneously to make this work.
Refactor AWavLoader to be a streaming loader rather than a one-shot one.
The constructor parses the header, and if everything looks good, you can
repeatedly ask the AWavLoader for sample buffers until it runs out.

Also send a message from AudioServer when a buffer has finished playing.
That allows us to implement a blocking variant of play().

Use all of this in aplay to play WAV files chunk-at-a-time.
This is definitely not perfect and it's a little glitchy and skippy,
but I think it's a step in the right direction.
2019-07-27 17:27:05 +02:00
Andreas Kling
fe45f5a6d2 LibCore: Port CoreIPCServer to using CLocalServer.
Use CLocalServer to listen for connections in WindowServer and AudioServer.
This allows us to accept incoming CLocalSocket objects from the CLocalServer
and construct client connections based on those.

Removed COpenedSocket since it's replaced by CLocalSocket.
2019-07-27 10:53:50 +02:00
Andreas Kling
8ed078e5b2 WindowServer: Add missing WSAPITypes.h include in WSClientConnection.h 2019-07-27 10:33:06 +02:00
Andreas Kling
a599317624 LibCore: Introduce a C_OBJECT macro.
This macro goes at the top of every CObject-derived class like so:

class SomeClass : public CObject {
    C_OBJECT(SomeClass)
public:
    ...

At the moment, all it does is create an override for the class_name() getter
but in the future this will be used to automatically insert member functions
into these classes.
2019-07-25 19:49:28 +02:00
Andreas Kling
1d0b464618 AK: Make HashMap::get(Key) return an Optional<Value>.
This allows HashMap::get() to be used for value types that cannot be default
constructed (e.g NonnullOwnPtr.)
2019-07-24 10:25:43 +02:00
Andreas Kling
90ea4918d6 WindowServer: Convert Vector<OwnPtr> to NonnullOwnPtrVector. 2019-07-24 09:04:57 +02:00
Andreas Kling
93489fbc4c Convert HashMap<Key, OwnPtr<T>> to HashMap<Key, NonnullOwnPtr<T>>.
In every case I found, we never wanted to support null entry values.
With NonnullOwnPtr, we can encode that at the type level. :^)
2019-07-24 08:42:55 +02:00
Robin Burchell
f2c0e55070 Userspace: Deal with select() returning EINTR on a signal interruption
Add a trivial CSafeSyscall template that calls a callback until it stops
returning EINTR, and use it everywhere we use select() now.

Thanks to Andreas for the suggestion of using a template parameter for
the syscall function to invoke.
2019-07-21 14:27:14 +02:00
Andreas Kling
6eb4ace6e8 WindowServer: Disable the global menubar while a modal window is active.
This makes it much harder to screw with an application while it's showing
a modal window, and matches what some other systems are doing. :^)
2019-07-21 10:23:21 +02:00
Andreas Kling
79a6312c8f WindowServer: Fix build after renaming WSMenuBarKeeper => WSMenuManager. 2019-07-18 10:46:41 +02:00
Andreas Kling
1c0669f010 LibDraw: Introduce (formerly known as SharedGraphics.)
Instead of LibGUI and WindowServer building their own copies of the drawing
and graphics code, let's it in a separate LibDraw library.

This avoids building the code twice, and will encourage better separation
of concerns. :^)
2019-07-18 10:18:16 +02:00
Andreas Kling
2167f60235 WindowServer: Rename (files) WSMenuBarKeeper => WSMenuManager. 2019-07-18 10:18:16 +02:00
Andreas Kling
66e9de8aaa WindowServer: Rename WSMenuBarKeeper => WSMenuManager. 2019-07-18 10:18:16 +02:00
Robin Burchell
b907608e46 SharedBuffer: Split the creation and share steps
This allows us to seal a buffer *before* anyone else has access to it
(well, ok, the creating process still does, but you can't win them all).

It also means that a SharedBuffer can be shared with multiple clients:
all you need is to have access to it to share it on again.
2019-07-18 10:06:20 +02:00
Robin Burchell
a9d1a86e6e CProcessStatisticsReader: Be consistent about terminology from the kernel down 2019-07-18 07:23:26 +02:00
Andreas Kling
4adbddeb36 AudioServer: Use Vector::append(Vector&&) for pending mix buffers.
Vector::append(Vector&&) is a simple pointer transfer when appending to an
empty Vector. :^)
2019-07-17 20:54:09 +02:00
Robin Burchell
9c8dd836fc Rename new IPC headers & classes
Sticking these in a namespace allows us to use a more generic
("Connection") term without clashing, which is way easier to understand
than to try to come up with unique names for both.
2019-07-17 20:16:44 +02:00
Robin Burchell
3837de0573 WSEventLoop: Remove inheritance from CEventLoop
The only reason for the inheritance was to add FDs to the select set.

Since CNotifier is available (and now also quite useful), we can make use of it
instead, and remove the inheritance.
2019-07-17 20:16:44 +02:00
Robin Burchell
6eaa6826fa Port WSClientConnection to CIPCServerSideClient 2019-07-17 20:16:44 +02:00
Robin Burchell
edcbba9e98 Introduce CIPCServerSideClient
As a new base class of IPC connections server-side.
Port ASClientConnection to CIPCServerSideClient.
2019-07-17 20:16:44 +02:00
Robin Burchell
fd6cafaa84 ABuffer: clamp -> clip
More natural term when talking about audio :)
2019-07-17 09:47:52 +02:00
Robin Burchell
ed25d524f2 ABuffer: move it and groove it 2019-07-17 09:47:52 +02:00