Commit graph

570 commits

Author SHA1 Message Date
Andreas Kling
73110e25a9 WindowServer: Move classes into WindowServer namespace
Also remove the leading WS from names and filenames.
2020-02-06 20:03:37 +01:00
Andreas Kling
97edc82a26 LibAudio: Remove leading A from filenames 2020-02-06 15:18:03 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00
Andreas Kling
7415e6ef9f LibIPC: Remove leading I from filenames 2020-02-06 14:54:09 +01:00
Andreas Kling
5c06c32df4 LibGfx: Prefer using Gfx::Bitmap::load_from_file instead of load_png()
Code that just wants to open a Gfx::Bitmap from a file should not be
calling the PNG codec directly.
2020-02-06 13:39:17 +01:00
Andreas Kling
f8b00aa290 LibGfx: Unpublish Gfx::Size from the global namespace 2020-02-06 13:32:14 +01:00
Andreas Kling
9b87843af1 LibGfx: Unpublish Gfx::Point from global namespace 2020-02-06 13:08:32 +01:00
Andreas Kling
20cfd2a6bf LibGfx: Unpublish Gfx::Rect from global namespace 2020-02-06 13:02:38 +01:00
Andreas Kling
c39d44fc2e LibGfx: Rename GraphicsBitmap.{cpp,h} => Bitmap.{cpp,h} 2020-02-06 12:07:05 +01:00
Andreas Kling
9ac94d393e LibGfx: Rename from LibDraw :^) 2020-02-06 12:04:00 +01:00
Andreas Kling
11580babbf LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really
wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename
the library to LibGfx. :^)
2020-02-06 11:56:38 +01:00
Andreas Kling
92f77864de LibAudio: Put all classes in the Audio namespace and remove leading A 2020-02-06 10:40:02 +01:00
Andreas Kling
f2a087126c LibC: Add posix_openpt(), grantpt() and unlockpt()
This makes getting a pseudoterminal pair a little bit more portable.
Note that grantpt() and unlockpt() are currently no-ops, since we've
already granted the pseudoterminal slave to the calling user.

We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
2020-02-05 21:17:41 +01:00
Andreas Kling
d264e8fcc5 LibIPC: Put all classes in the IPC namespace and remove the leading I 2020-02-05 19:57:18 +01:00
joshua stein
c33cb8a289 TTYServer: Include AK/LogStream.h for dbg() 2020-02-05 18:39:45 +01:00
joshua stein
79be8be051 WindowServer: Remove unused s_checkbox_or_icon_padding 2020-02-05 18:39:45 +01:00
Liav A
44ddfd2bf5 WindowServer: Fix the drain mouse mechanism
Now we actually check if the Mouse packet relative flag is enabled or
not.
In addition to that, we have debug messages for mouse point changes.
2020-02-04 19:11:52 +01:00
Sergey Bugaev
e94484d208 WindowServer: Preliminary absolute mouse positioning support 2020-02-04 19:11:52 +01:00
Andreas Kling
2d39da5405 LibCore: Put all classes in the Core namespace and remove the leading C
I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
2020-02-02 15:15:30 +01:00
Hüseyin ASLITÜRK
c5edc09b78 WindowServer: Fix for Changing Screen Resolution Resets.
Fixes #816.
2020-02-02 15:08:37 +01:00
Oliver Kraitschy
5aa37f6f5c WindowServer: make menus wrap vertically
This commit adds vertical wrap to menus. The first item is focused if
Key_Down is pressed on the last item and the last item is focused if
Key_up is pressed on the first item.
2020-02-01 08:51:53 +01:00
Andreas Kling
d1721c761e LookupServer: Don't cache already-expired DNS answers 2020-01-26 16:25:12 +01:00
Andreas Kling
5e47508672 LookupServer: Cache DNS answers for TTL seconds
We now keep DNS answers around in a cache for TTL seconds after getting
them the first time. The cache is capped at 256 responses for now.

Suggested by @zecke in #10.
2020-01-26 15:44:51 +01:00
Andreas Kling
90a5907b44 LookupServer: Rename "custom_hosts" => "etc_hosts"
This makes it more obvious that these mappings come from /etc/hosts.
2020-01-26 15:44:51 +01:00
Andreas Kling
c26560ec26 LookupServer: Rename setting "DNS/IPAddress" => "DNS/Nameserver" 2020-01-26 15:44:51 +01:00
Andreas Kling
e335d730d6 LookupServer: Use CUdpSocket instead of the POSIX API
LibCore's UDP socket is a bit more comfortable to work with. :^)
2020-01-26 14:47:03 +01:00
Andreas Kling
537a1d31c5 LookupServer: Add missing copyright headers 2020-01-26 13:53:36 +01:00
Andreas Kling
a9ec2225a5 LookupServer: Retry with 0x20 randomization turned off on EREFUSED
Apparently some authoritative servers don't handle 0x20 randomization
well and may send EREFUSED. Retry with randomization turned off then.

Reference: https://github.com/dns-violations/dns-violations/blob/master/2017/DVE-2017-0006.md

More work towards #10.
2020-01-26 13:49:46 +01:00
Andreas Kling
00be9b33b1 LookupServer: Verify that DNS response questions match the request
To protect against DNS spoof attacks, we now check that the questions
in incoming responses match the questions in the request we sent out.

Suggested by @zecke in #10.
2020-01-26 13:07:43 +01:00
Andreas Kling
b4d55b16b6 LookupServer: Randomize the 0x20 bit in DNS request ASCII characters
This adds a bit of extra entropy to DNS requests, making it harder to
spoof a valid response.

Suggested by @zecke in #10.
2020-01-26 13:07:21 +01:00
Andreas Kling
02be23cf81 LookupServer: Randomize DNS request ID's
Suggested by @zecke in #10.
2020-01-26 12:38:49 +01:00
Andreas Kling
871b6b4e1a LookupServer: Minor overhaul
- Break out request building into a DNSRequest class.
- Break out response parsing into a DNSResponse class.

A DNSRequest contains one or more DNSQuestion objects.
A DNSResponse contains all the DNSQuestions asked, and a DNSAnswer
object for each answer.
2020-01-26 12:37:08 +01:00
Andreas Kling
b648997d1f WindowServer: Don't allow minimize/maximize of windows while modal up
While one window is blocked by another modal one, just ignore events on
the window frame, and also ignore set_minimized() and set_maximized().

The only thing you're allowed to do with a blocked window is moving it.

Fixes #1111.
2020-01-25 10:41:23 +01:00
Andreas Kling
6df81c8a88 WindowServer: Robustify WSWindow<->WSClientConnection link a bit
WSWindow now detaches from WSClientConnection when being destroyed.

Because of this, we can no longer rely on WSWindow::client() to tell
us whether a window is internal to WindowServer or not. So instead we
now have WSWindow::is_internal() which checks for client_id == -1.

Note that WSWindow now also gets a copy of its client_id when
constructed, since we can no longer rely on client() being valid after
destruction has started.

This allows various automatic mechanisms (e.g what happens in response
to window removal) to skip over windows that are being destroyed.

Fixes #387.
2020-01-25 10:34:32 +01:00
Andreas Kling
60d5b06e21 WindowServer: Tear down WSClientConnection asynchronously
If something goes wrong when trying to message a windowing client,
we now tear it down *on next event loop* instead of immediately.

This avoids having to deal with disconnected windows suddenly
disappearing from window lists while looping over them.
2020-01-25 10:34:32 +01:00
Sergey Bugaev
c0b32f7b76 Meta: Claim copyright for files created by me
This changes copyright holder to myself for the source code files that I've
created or have (almost) completely rewritten. Not included are the files
that were significantly changed by others even though it was me who originally
created them (think HtmlView), or the many other files I've contributed code to.
2020-01-24 15:15:16 +01:00
Brian Gianforcaro
521c6dbbee LookupServer: Lock unveil() after initialization.
Once LookupServer is initialized it should never need
access to any any paths for the lifetime of the process.

Lock the veil post initialization.
2020-01-22 11:25:09 +01:00
Andreas Kling
a2ed805d23 AudioServer: Drop "rpath" and "wpath" pledges
Once the event loop is constructed, we will have opened /dev/audio for
output and no more filesystem lookups need to happen.
2020-01-21 15:40:48 +01:00
Andreas Kling
05a2a0c492 WindowServer: unveil("/bin", "x") so we can start applications
Without this, we can't start programs via the system menu. This begs
the question: should WindowServer really be allowed to fork and exec
in the first place?
2020-01-21 10:48:14 +01:00
Andreas Kling
17e5fc301b WindowServer: Use unveil()
WindowServer needs persistent access to a few things:

- /res (for themes, fonts, cursors, apps, wallpapers, etc.)
- /etc/passwd (for username lookup, not sure this is actually needed..)
- /home/anon/WindowManager.ini (FIXME: this should not be hard-coded..)

These things are unveiled temporarily, and then dropped:

- /tmp (for setting up sockets)
- /dev (for opening input and framebuffer devices)

This leaves WindowServer running with a very limited view of the file
system, how neat is that!
2020-01-20 22:23:18 +01:00
Shannon Booth
68d5b39942 WindowServer: Simplify WSMenu MouseWheel event
A mouse move event needs to do a bit more work than what a mouse wheel event
does. Mouse wheel just needs to update the hovered item, and update for a new
hovered item. This also stops us from calling redraw() twice on a wheel event.
2020-01-20 10:35:12 +01:00
Shannon Booth
3e05c83591 WindowServer: Stop infinite menu movement cycle
While I really enjoyed having an infinite cycle when I implemented menu
keys (and seeing it wizz around and around :D), menu key movement should
be consistent between menus - and an inifinite cycle does not make much
sense for a scrollable menu.
2020-01-20 10:35:12 +01:00
Andreas Kling
fb7a885cae WindowServer: Allow scrolling of menus that don't fit on screen
Menus now have a scroll offset (index based, not pixel based) which is
controlled either with the mouse wheel or with the up/down arrow keys.

This finally allows us to browse all of the fonts that @xTibor has made
avilable through his serenity-fontdev project:

https://github.com/xTibor/serenity-fontdev

I'm not completely sure about the up/down arrows. They feel like maybe
they occupy a bit too much vertical space.

Also FIXME: this mechanism probably won't look completely right for
menus that have separators in them.

Fixes #1043.
2020-01-19 21:36:33 +01:00
Shannon Booth
ead1273632 WindowServer: More natural mouse menu navigation
Use an imaginary triangle between the top and bottom of the submenu of a
hovered item to determine whether the mouse is moving towards the
submenu. If it is, we do not update the hovered item. This allows the
submenu to stay open, making for much easier menu navigation.

Closes #1094
2020-01-19 08:45:23 +01:00
Sergey Bugaev
88f5991c29 WindowServer: Print the error when failing to open /dev/fb0 2020-01-18 23:51:22 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
shannonbooth
f60bd255f5 WindowServer: Stop tracking hovered menu independently from the index (#1093)
Tracking the hovered menu item independently from the index of the
currently hovered item is error prone and bad code. Simplify WSMenu by
only tracking the index of the currently hovered item.

Fixes #1092
2020-01-18 08:56:51 +01:00
Shannon Booth
6b52f6c61d WindowServer: Fix windowswitcher not closing, make system menu a toggle
We were swallowing the keyevent on a Logo key down even if we were not
opening the logo. This is incorrect, and was preventing the
windowswitcher from closing.

We also make the logo button toggle the system menu, as this behaviour
is closer to how you would normally expect this button to work.

Closes #1090
2020-01-18 00:27:39 +01:00
Shannon Booth
d86b20d8bd WindowServer: Add toggle_menu helper function 2020-01-18 00:27:39 +01:00
Andreas Kling
26a31c7efb Kernel: Add "accept" pledge promise for accepting incoming connections
This patch adds a new "accept" promise that allows you to call accept()
on an already listening socket. This lets programs set up a socket for
for listening and then dropping "inet" and/or "unix" so that only
incoming (and existing) connections are allowed from that point on.
No new outgoing connections or listening server sockets can be created.

In addition to accept() it also allows getsockopt() with SOL_SOCKET
and SO_PEERCRED, which is used to find the PID/UID/GID of the socket
peer. This is used by our IPC library when creating shared buffers that
should only be accessible to a specific peer process.

This allows us to drop "unix" in WindowServer and LookupServer. :^)

It also makes the debugging/introspection RPC sockets in CEventLoop
based programs work again.
2020-01-17 11:19:06 +01:00