Commit graph

376 commits

Author SHA1 Message Date
Andreas Kling
f93c0dc489 LibIPC: Get client/server PIDs using getsockopt(SO_PEERCRED)
Instead of passing the PIDs back and forth in a handshake "Greet"
message, just use getsockopt(SO_PEERCRED) on both sides to get the same
information from the kernel.

This is a nice little simplification of the IPC protocol, although it
does not get rid of the handshake since we still have to pass the
"client ID" from the server to each client so they know how to refer
to themselves. This might not be necessary and we might be able to get
rid of this later on.
2019-12-06 18:39:59 +01:00
Andreas Kling
6e6e0b9de8 WindowServer: Compute some layout rects in WSMenuManager up front
Currently menu applets are laid out relative to the "audio rect" which
is the rect of the little audio muted state icon thingy.

There was an issue where applets would be placed at a negative X coord
if they were added to the WindowServer before the first time drawing
the menubar.
2019-12-05 19:59:54 +01:00
Andreas Kling
86d84f1654 WindowServer: Remove WSCPUMonitor
We'll still have a CPU graph, just not in the WindowServer process.
2019-12-05 19:43:56 +01:00
Andreas Kling
44d5388e78 WindowServer: Add basic menu applet concept
It's now possible to create a little applet window that sits inside the
system's menubar. This is done using the new CreateMenuApplet IPC call.

So far, it's possible to assign a backing store ID, and to invalidate
rects for repaint. There is no way to get the events from inside the
applet just yet.

This will allow us to move the CPU graph and audio thingy to separate
applet processes. :^)
2019-12-05 19:36:01 +01:00
Andreas Kling
e1862fe2f5 WindowServer: Move window minimize animation to a separate function
Move this from WSCompositor::compose() to a separate run_animations()
function to keep compose() readable. We might want to add some more
animations later.
2019-12-05 17:44:10 +01:00
Andreas Kling
d111b6ead4 WindowServer+Taskbar: Animate window frames on minimize/unminimize
We now show a quick window outline animation when going in/out of
minimized state. It's a simple 10 frame animation at 60fps, just to
give a visual cue of what's happening with the window.

The Taskbar sends over the corresponding button rect for each window
to the WindowServer using a new WM_SetWindowTaskbarRect message.

Note that when unminimizing, we still *show* the window right away,
and don't hold off until the animation has finished. This avoids
making the desktop feel slow/sluggish. :^)
2019-12-03 21:34:34 +01:00
Andreas Kling
0e34b7d65e WindowServer: Remove debug spam about menu creation 2019-12-02 17:16:59 +01:00
Andreas Kling
340c5506b4 WindowServer: Remove silly debug logging on startup :^) 2019-12-02 16:47:11 +01:00
Andreas Kling
e91b2b8f1b WindowServer: Mark clients as misbehaving when they send invalid data
If a client sends an invalid window ID or similar to the WindowServer,
we'll now immediately mark them as misbehaving and disconnect them.

This might be too aggressive in some cases (window management, ...)
but it's just a place to start.
2019-12-02 15:55:14 +01:00
Andreas Kling
4a37bec27c LibIPC: Rename base classes to IClientConnection and IServerConnection
This matches what we're already calling the server-side subclasses
better, though we'll probably want to find some better names for the
client-side classes eventually.
2019-12-02 11:11:05 +01:00
Andreas Kling
5d4ee0f58a LibIPC: Move IPC client/server connection templates to LibIPC
Move over the CoreIPC::Server and CoreIPC::Client namespace stuff
into LibIPC where it will soon becomes LibIPC-style things.
2019-12-02 11:11:05 +01:00
Andreas Kling
272d65e3e2 WindowServer: Port to the new IPC system
This patch introduces code generation for the WindowServer IPC with
its clients. The client/server endpoints are defined by the two .ipc
files in Servers/WindowServer/: WindowServer.ipc and WindowClient.ipc

It now becomes significantly easier to add features and capabilities
to WindowServer since you don't have to know nearly as much about all
the intricate paths that IPC messages take between LibGUI and WSWindow.

The new system also uses significantly less IPC bandwidth since we're
now doing packed serialization instead of passing fixed-sized structs
of ~600 bytes for each message.

Some repaint coalescing optimizations are lost in this conversion and
we'll need to look at how to implement those in the new world.

The old CoreIPC::Client::Connection and CoreIPC::Server::Connection
classes are removed by this patch and replaced by use of ConnectionNG,
which will be renamed eventually.

Goodbye, old WindowServer IPC. You served us well :^)
2019-12-02 11:11:05 +01:00
Andreas Kling
b6ad94407e WindowServer: Remove unused GetWindowBackingStore IPC request 2019-12-01 19:29:48 +01:00
Andreas Kling
4104f53a94 ProtocolServer: Don't crash on failed request
The CNetworkJob::on_finish hook will be invoked both for success and
failure, but there will only be a m_job->response() in the success case
so we have to null-check it before using it.

This should have been obvious from the "->"
2019-11-30 11:02:14 +01:00
Andreas Kling
712ae73581 Kernel: Expose per-thread information in /proc/all
Previously it was not possible to see what each thread in a process was
up to, or how much CPU it was consuming. This patch fixes that.

SystemMonitor and "top" now show threads instead of just processes.
"ps" is gonna need some more fixing, but it at least builds for now.

Fixes #66.
2019-11-26 21:37:30 +01:00
Sergey Bugaev
52b0bd06a8 SystemServer: Implement lazy spawning
For services explicitly configured as lazy, SystemServer will now listen
on the socket and only spawn the service once a client attempts to connect
to the socket.
2019-11-26 19:58:25 +01:00
Sergey Bugaev
ab98969403 LookupServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
821ed8367b LookupServer: Port to LibCore 2019-11-26 19:58:25 +01:00
Sergey Bugaev
9eaac26eda ProtocolServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
bd55938985 AudioServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
22a05621d5 WindowServer: Port to socket takeover 2019-11-26 19:58:25 +01:00
Sergey Bugaev
c9e21b2bcc SystemServer+LibCore: Implement socket takeover
SystemServer can now create sockets on behalf of services before spawning any
of them, and pass the open socket fd as fd 3. CLocalServer gains a method to
complete the takeover and listen on the passed fd.

This is not used by any services at the moment.
2019-11-26 19:58:25 +01:00
Sergey Bugaev
396ad4d6b2 SystemServer: Implement keepalive
When reaping a child, SystemServer will now match up child's pid with its own
record of the services, and respawn the service if keepalive is enabled for it.

For example, we want to restart the WindowServer if it crashes, but we wouldn't
want to restart the Terminal if it gets closed.
2019-11-26 19:58:25 +01:00
Sergey Bugaev
b93065359e SystemServer: Read service list from a config file
This replaces the hardcoded services list with a very simple config
file in /etc/SystemServer.ini :^)

Closes https://github.com/SerenityOS/serenity/issues/610
2019-11-26 19:58:25 +01:00
Andreas Kling
35c26a06fc LibCore: Move puff() from LibDraw to LibCore
Since it's used both by CGzip and PNGLoader, it seems most appropriate
to keep this in LibCore.
2019-11-23 23:43:37 +01:00
Andreas Kling
eb85103271 ProtocolServer: Send the download payload to clients as a shared buffer
The DownloadFinished message from the server now includes a buffer ID
that can be mapped into the client program.

To avoid prematurely destroying the buffer, the server will hang on to
it until the client lets it know that they're all good. That's what the
ProtocolServer::DisownSharedBuffer message is about.

In the future it would be nice if the kernel had a mechanism to allow
passing ownership of a shared buffer along with an IPC message somehow.
2019-11-23 22:11:44 +01:00
Andreas Kling
fd4349a9f2 ProtocolServer+LibProtocol: Introduce a server for handling downloads
This patch adds ProtocolServer, a server that handles network requests
on behalf of its clients. The first protocol implemented is HTTP.

The idea here is to use a plug-in architecture where any number of
protocols can be added and implemented without having to mess around
with each client program that wants to use the protocol.

A simple client API is provided through LibProtocol::Client. :^)
2019-11-23 21:50:32 +01:00
Andreas Kling
f61ed8eab5 WindowServer: Listen for muted state changes from AudioServer
Now the menu audio icon updates between muted/unmuted when anything in
the system changes the muted state. :^)
2019-11-23 17:21:28 +01:00
Andreas Kling
84cb91de38 AudioServer: Broadcast muted state changes to all clients 2019-11-23 17:21:12 +01:00
Andreas Kling
630d5b3ffd LibIPC+AudioServer: Allow unsolicited server-to-client IPC messages
Client-side connection objects must now provide both client and server
endpoint types. When a message is received from the server side, we try
to decode it using both endpoint types and then send it to the right
place for handling.

This now makes it possible for AudioServer to send unsolicited messages
to its clients. This opens up a ton of possibilities :^)
2019-11-23 16:50:21 +01:00
Andreas Kling
9009390f9c WindowServer: Add an audio icon to the menu bar
Clicking on this icon toggles the AudioServer muted state.

It currently does not react to muted state changes caused by other
programs, since it has no way of learning about those from AudioServer,
other than performing a synchronous IPC call (GetMuted), which we don't
want to be doing in the WindowServer :^)
2019-11-22 22:15:39 +01:00
Andreas Kling
107011f119 AudioServer: Allow muting the system audio
This patch adds muting to ASMixer, which works by substituting what we
would normally send to the sound card with zero-filled memory instead.
We do it this way to ensure that the queued sample buffers keep getting
played (silently.)

This is obviously not the perfect way of doing this, and in the future
we should improve on this, and also find a way to utilize any hardware
mixing functions in the sound card.
2019-11-22 21:44:02 +01:00
Sergey Bugaev
2b9ec22576 WindowServer: Optimize backing store placement for resizing windows
When a window is being resized, its size may differ from the size of its backing
store. In this case, peek at the direction the window is being resized in, and
render the backing store at the same place as it was previously.

https://github.com/SerenityOS/serenity/issues/52
2019-11-22 18:42:31 +01:00
Sergey Bugaev
555b4236f8 WindowServer: Ensure resized windows move in the expected direction
When a window is being interactively resized, there are several rules
beyond the actual mouse movement that can impact the new size of the
window, such as its size increments and minimum size limit.

Move the placement logic after applying all the sizing logic, so that
whatever final size the window ends up with, the sides of the window
that do move are the ones that the user is dragging.

https://github.com/SerenityOS/serenity/issues/52
2019-11-22 18:42:31 +01:00
Sergey Bugaev
3df521e2b7 AudioServer: Make all source files depend on generated sources
This fixes race conditions & failures during build.
2019-11-19 20:10:38 +01:00
Andreas Kling
69ca9cfd78 LibPthread: Start working on a POSIX threading library
This patch adds pthread_create() and pthread_exit(), which currently
simply wrap our existing create_thread() and exit_thread() syscalls.

LibThread is also ported to using LibPthread.
2019-11-13 21:49:24 +01:00
Sergey Bugaev
bf012ca10a WindowServer: Fix leaking framebuffer fd to clients
Now that the WindowServer's menu is the primary way to start apps,
it is especially noticable that it leaks the /dev/fb0 fd to the apps
that it spawns. Fix that by opening it with O_CLOEXEC.
2019-11-13 16:37:04 +01:00
Andreas Kling
dd2900eda0 Launcher: Remove the Launcher app, and all hacks in support of it
The Launcher's functionality has been replaced by the app shortcuts in
the system menu.

There were various window management hacks to ensure that the launcher
stayed below all other windows while also being movable, etc.
2019-11-11 13:13:08 +01:00
Andreas Kling
9f537d0b95 WindowServer: Sort the system menu app categories alphabetically 2019-11-11 13:13:08 +01:00
Andreas Kling
2fcf156540 WindowServer: Don't send menu item activations for separators
Separators can't have identifiers associated with them, so it's not
possible to react meaningfully to their activation. Don't send messages
about it to avoid confusing the clients.
2019-11-11 13:13:08 +01:00
Andreas Kling
5e61fd0e67 WindowManager: Simplify menu bar open/close logic
Let the global menu bar be either "open" or "closed". Clicking on one
of the menus in the menu bar toggles the state.

This ends up simpler and more intuitive than what we had before.
2019-11-11 13:13:08 +01:00
Andreas Kling
cbecad0a77 WindowManager: Move more of the menu management logic to WSMenuManager
This patch moves a whole lot of the menu logic from WSWindowManager to
its proper home in WSMenuManager.

We also get rid of the "close_current_menu()" concept which was easily
confused in the presence of submenus. All operations should now be
aware of the menu stack instead. (The concept of a single, current menu
made a lot more sense when there were no nested menus.)
2019-11-11 13:13:08 +01:00
Andreas Kling
74be54cce8 WindowServer: Organize system menu app shortcuts into categories
If the .af file for an app contains the App/Category key, we'll now put
it in a submenu of the system menu, together with all the other apps in
that same category. This is pretty neat! :^)
2019-11-11 13:13:08 +01:00
Andreas Kling
91407af8a4 SystemServer: Stop launching the Launcher app on startup
Launcher is being replaced by application shortcuts in the system menu.
2019-11-11 13:13:08 +01:00
Andreas Kling
b6a6f34caa WindowServer: Populate system menu with app launchers from /res/apps
The new system directory /res/apps now contains ".af" files describing
applications (name, category, executable path, and icon.)
These are used to populate the system menu with application shortcuts.

This will replace the Launcher app. :^)
2019-11-11 13:13:08 +01:00
masi456
7e7451c427 WindowServer: Don't de-maximize windows immediately (#756)
At least 5 pixels of dragging in some direction needed until a window
gets de-maximized.
2019-11-10 18:28:01 +01:00
Andreas Kling
0f76366b34 WindowServer: Some minor comments and cleanups in WSCompositor 2019-11-09 10:57:07 +01:00
Andreas Kling
9e570d0d6d Kernel+SystemServer: Get rid of two virtual consoles
Having four virtual (text) consoles by default seems really overkill
for a system that can't even switch to them anyway (yet!)
2019-11-06 11:41:50 +01:00
Till Mayer
2f13517a1a LibAudio: Added playback control features to audio server
LibAudio now supports pausing playback, clearing the buffer queue,
retrieving the played samples since the last clear and retrieving
the currently playing shared buffer id
2019-11-04 20:55:46 +01:00
George Pickering
704f48d7f3 POSIX compliance: (most) shell scripts converted to generic shell
Ports/.port_include.sh, Toolchain/BuildIt.sh, Toolchain/UseIt.sh
have been left largely untouched due to use of Bash-exclusive
functions and variables such as $BASH_SOURCE, pushd and popd.
2019-11-03 09:26:22 +01:00