Commit graph

59 commits

Author SHA1 Message Date
Andreas Kling
39d1a9ae66 Meta: Tweak .clang-format to not wrap braces after enums. 2019-06-07 17:13:23 +02:00
Andreas Kling
0ed89440f1 ProcessManager+top: Rename "linear" size to "virtual" size.
I originally called it "linear" because that's how the Intel manual names
virtual addresses in many cases. I'm ready to accept that most people know
this as "virtual" so let's just call it that.
2019-06-07 12:44:29 +02:00
Andreas Kling
7770d6a09d LibCore: Run clang-format on everything. 2019-06-07 11:46:37 +02:00
Andreas Kling
98eeb8f22d AK: Rename printf.cpp to PrintfImplementation.h. 2019-06-07 11:41:11 +02:00
Andreas Kling
08cd75ac4b Kernel: Rename FileDescriptor to FileDescription.
After reading a bunch of POSIX specs, I've learned that a file descriptor
is the number that refers to a file description, not the description itself.
So this patch renames FileDescriptor to FileDescription, and Process now has
FileDescription* file_description(int fd).
2019-06-07 09:36:51 +02:00
Andreas Kling
29a9430246 AK: Make timeval_add() and timeval_sub() take references. 2019-06-06 18:02:28 +02:00
Andreas Kling
800242ed4e CEventLoop: Don't bother looking through fds when select() returns 0.
If it returns 0 that just means we hit the timeout. I suppose we could skip
the timer checks if there are a non-zero number of fds marked as well, but
I'm not sure that's a great idea since it will add some latency.
2019-06-05 01:57:28 -07:00
Andreas Kling
ae4ac524ad CIODevice: Update m_error if a write() fails. 2019-06-02 15:18:27 +02:00
Robin Burchell
7bce096afd Take StringView in more places
We should work towards a pattern where we take StringView as function
arguments, and store String as member, to push the String construction
to the last possible moment.
2019-06-02 12:55:51 +02:00
Robin Burchell
e74b5975e4 Userland: Use CFile inside sysctl
Also add a StringView overload to CIODevice::write
2019-06-02 12:55:51 +02:00
Andreas Kling
b8e705da0e LibCore: CObjects without is<T> specialization shouldn't LARP as others. 2019-06-01 14:11:31 +02:00
Andreas Kling
fdf3608c8a Update Badge<T> instantiations to simply be {}. 2019-05-31 15:44:04 +02:00
Robin Burchell
0dc9af5f7e Add clang-format file
Also run it across the whole tree to get everything using the One True Style.
We don't yet run this in an automated fashion as it's a little slow, but
there is a snippet to do so in makeall.sh.
2019-05-28 17:31:20 +02:00
Andreas Kling
cbd858544d LibC: Move struct timeval to sys/time.h. #POSIX 2019-05-28 13:48:06 +02:00
Christopher Dumas
c23882dde1 can now tile background and made sure the IRC choose server popup still works 2019-05-27 21:40:53 +02:00
Christopher Dumas
50154a23cb most apps now begin in the correct directory 2019-05-27 21:40:53 +02:00
Christopher Dumas
d4a16d6031 Network stack is now configurable, and resolution is also configurable, but loading cursors causes a page-fault? 2019-05-27 21:40:53 +02:00
Robin Burchell
9d2b08e06e LibCore: Add CDirIterator, and use it in everything rather than readdir 2019-05-27 15:27:23 +02:00
Andreas Kling
3873c51781 LibCore: Add CObject::for_each_child_of_type<T>()
Use this to iterate over all the GRadioButtons in a group.
2019-05-27 04:18:24 +02:00
Andreas Kling
0c85d3dba9 LibCore+LibGUI: Add is<T>(CObject&) and to<T>(CObject&) helpers. 2019-05-27 04:06:01 +02:00
Andreas Kling
906fde8f8c LibCore: Add CObject::for_each_child(callback). 2019-05-27 03:52:19 +02:00
Robin Burchell
8df3e2516f CEventLoop: Make it possible to determine running/quit state without using exec()
... by removing a redundant member that nothing uses (running), and
exposing whether or not quit has been requested.
2019-05-26 18:17:40 +02:00
Robin Burchell
d791bce6af CEventLoop: Allow manually driving the event loop
Move the bulk of exec() into a new pump(). Since SDL wants to drive the
event loop itself, this is a requirement. We also add a WaitMode flag to
allow for immediately pumping events -- again, this is required because
SDL wants to be in full control of the event loop, and not let us wait.
2019-05-20 03:03:48 +02:00
Robin Burchell
df74a9222f Kernel: Fix timeout support in select
The scheduler expects m_select_timeout to act as a deadline. That is, it
should contain the time that a task should wake at -- but we were
directly copying the time from userspace, which meant that it always
returned virtually immediately.

At the same time, fix CEventLoop to not rely on the broken select behavior
by subtracting the current time from the time of the nearest timer.
2019-05-18 02:57:38 +02:00
Robin Burchell
5babcac289 Build: Install most headers to Root (and libcore.a/libgui.a)
This makes out-of-tree linking possible. And at the same time, add a
CMakeToolchain.txt file that can be used to build arbitrary cmake-using
applications on Serenity by pointing to the CMAKE_TOOLCHAIN_FILE when
running cmake:

    -DCMAKE_TOOLCHAIN_FILE=~/code/serenity/Toolchain/CMakeToolchain.txt
2019-05-17 21:59:48 +02:00
Robin Burchell
77dfd419e9 LibCore: Move AK/ArgsParser to LibCore/CArgsParser
Also rename the classes to match LibCore naming style.
This means that it's no longer incorrectly linked into LibC and Kernel.
2019-05-17 15:49:37 +02:00
Robin Burchell
c8fda23a03 LibCore/Userland: Introduce a simple tail implementation
Also introduce more seek modes on CIODevice, and an out param to find
the current position inside the file -- this means less syscalls (and
less potential races) than requesting it through a separate pos()
accessor or something.
2019-05-17 14:28:13 +02:00
GuillaumeGas
0ba4ceb2cd Added CProcessStatisticsReader to avoid having to parse /proc/all (#35)
* Added CProcessStatisticsReader to avoid having to parse /proc/all

* Took @awesomekling's feedbacks into account

* Fixed indentation and replaced tabs by spaces
2019-05-16 18:47:47 +02:00
Andreas Kling
1e0f9d325c LibCore: Avoid a big malloc in CIODevice's internal buffering.
This heap allocation was totally avoidable and can be replaced by a stack
buffer instead. Dodges a bunch of mmap() traffic.
2019-05-14 16:36:29 +02:00
Andreas Kling
dbf7878998 LibCore: Using printf() inside CIODevices will now call CIODevice::printf().
Well this was confusing. Obviously this code should never be calling outside
to ::printf() anyway, so just use dbgprintf() instead.
2019-05-10 18:20:54 +02:00
Andreas Kling
7ce3b10568 CIODevice: Add some basic output facilities: write() and printf().
Being able to do file.printf() is extremely comfy, I have to say. :^)
2019-05-08 04:38:41 +02:00
Andreas Kling
dd299fe51a CObject: add_child() should set the child's parent. 2019-05-05 01:09:49 +02:00
Andreas Kling
202e922ce8 CLock: Remove a redundant call to gettid(). 2019-05-01 19:11:08 +02:00
Andreas Kling
65f2f19b41 CEventLoop: Protect the message queue with a Lock. 2019-04-29 15:57:49 +02:00
Andreas Kling
0a68e0046f LibCore: Make it possible to create a CFile for an existing file descriptor. 2019-04-26 02:22:21 +02:00
Andreas Kling
57da00b731 Include Makefile.common in all other Makefiles. 2019-04-21 04:09:39 +02:00
Andreas Kling
ab94a6be00 AK: Add String::copy(BufferType) helper.
This will create a String from any BufferType that has data() and size().
2019-04-20 14:13:40 +02:00
Andreas Kling
5eedb22834 Sprinkle use of AK::Vector in various places.
Some of these are less helpful than others. Avoiding a bunch of mallocs
in the event loop wakeup code is definitely nice.
2019-04-20 14:02:19 +02:00
Andreas Kling
301a269ca0 Get rid of SERENITY macro since the compiler already defines __serenity__
This makes it a bit easier to use AK templates out-of-tree.
2019-04-20 12:58:49 +02:00
Andreas Kling
405fe4f72c LibCore: Hide deferred_invoke() debug spam. 2019-04-20 12:48:49 +02:00
Andreas Kling
9e6b0ccc0e LibCore+LibGUI: Make CObject child events synchronous.
...and then make GWidget layout invalidation lazy. This way we coalesce
multiple invalidations into a single relayout and we don't have to worry
about child widgets not being fully constructed.
2019-04-18 22:57:24 +02:00
Andreas Kling
3b986da643 CEventLoop: Don't call gettimeofday() at all if there are no timers. 2019-04-18 13:23:59 +02:00
Andreas Kling
d73ed74d1c LibCore: Add CTimer::restart() and make set_interval() take effect soon. 2019-04-18 04:38:04 +02:00
Andreas Kling
7b3876383f LibCore: CIODevice::seek() should reset EOF state. 2019-04-18 02:09:15 +02:00
Andreas Kling
8e0611201e CEventLoop: Consolidate gettimeofday() syscalls. 2019-04-18 01:37:23 +02:00
Andreas Kling
04500c1ae2 GWidget: Add some new child z-ordering facilities.
- child_at(Point)
- move_to_front()
- move_to_back()
- is_frontmost()
- is_backmost()

This patch also makes it possible to receive the mouse event that triggers
a context menu before the context menu is shown. I'm not sure this is the
best design for context menus but it works for now.
2019-04-16 03:47:55 +02:00
Andreas Kling
b5759089d8 LibCore: Add CIODevice::seek(). 2019-04-16 00:51:05 +02:00
Andreas Kling
bc5148354f LibCore: Add a CConfigFile class, a simple INI file parser.
You open the configuration for an app like so:

    auto config = CConfigFile::get_for_app("MyApp");

This will then open ~/MyApp.ini and parse it for you.
Immediately start using it in Minesweeper to load the field size and mine
count from a config file.
2019-04-15 02:23:20 +02:00
Andreas Kling
a3e8fc3d9c LibCore: Add a convenience constructor for CTimer.
new CTimer(250, [] { thing_to_do_every_250_msec(); });
2019-04-14 05:44:15 +02:00
Andreas Kling
47a2982119 LibCore: Move LibGUI/GTimer to LibCore/CTimer. 2019-04-12 00:09:45 +02:00