Commit Graph

382 Commits

Author SHA1 Message Date
Andreas Kling
953cb4e436 LibCore: Convert CLocalServer to ObjectPtr 2019-09-21 15:25:08 +02:00
Andreas Kling
c83da29a9d LibCore: Convert CLocalSocket to ObjectPtr 2019-09-21 15:25:08 +02:00
Andreas Kling
4298ba25c3 LibCore: Convert CTCPSocket to ObjectPtr, add construct() helper
The C_OBJECT macro now also inserts a static construct(...) helper into
the class. Now we can make the constructor(s) private and instead call:

    auto socket = CTCPSocket::construct(arguments);

construct() returns an ObjectPtr<T>, which we'll later switch to being
a NonnullRefPtr<T>, once everything else in in place for ref-counting.
2019-09-21 15:25:08 +02:00
Andreas Kling
fcc3745b02 LibCore+LibGUI+WindowServer: Make events bubble up through ancestors
With this patch, CEvents no longer stop at the target object, but will
bubble up the ancestor chain as long as CEvent::is_accepted() is false.

To the set accepted flag, call CEvent::accept().
To clear the accepted flag, call CEvent::ignore().

Events start out in the accepted state, so if you want them to bubble
up, you have to call ignore() on them.

Using this mechanism, we now ignore non-tabbing keydown events in
GWidget, causing them to bubble up through the widget's ancestors. :^)
2019-09-20 20:37:31 +02:00
Andreas Kling
74c4e62659 GCommonActions: Add "Open..." action
Make use of this in PaintBrush and TextEditor. :^)
2019-09-20 19:36:39 +02:00
Andreas Kling
d1bacb9885 LibCore: Convert CNotifier to ObjectPtr 2019-09-20 15:39:15 +02:00
Andreas Kling
50a6560413 LibCore: Convert CTimer to ObjectPtr 2019-09-20 15:20:10 +02:00
Andreas Kling
c34fd10b5b LibCore: Introduce ObjectPtr, a step towards reference-counted CObject
Long-term we should use reference counting for the CObject hierarchy.
Since we've already accumulated a fair amount of code, this is quite a
large task, so I'm breaking it into some steps.

So, ObjectPtr is a "smart" pointer for CObject-derived types.
It becomes null when moved from, and will destroy unparented CObjects
in its destructor.

The idea here is to convert the codebase over to ObjectPtr piece by
piece, and then when everything is moved and CObject itself refactored
for ref-counting, we can just replace ObjectPtr with RefPtr everywhere.
2019-09-20 15:19:11 +02:00
Andreas Kling
8cfb859368 IPv4: Support overriding the default TTL (64)
Made getsockopt() and setsockopt() virtual so we can handle them in the
various Socket subclasses. The subclasses map kinda nicely to "levels".

This will allow us to implement things like "traceroute", although..
I spent some time trying to do that, but then hit a wall when it turned
out that the user-mode networking in QEMU doesn't preserve TTL in the
ICMP packets passing through.
2019-09-19 21:42:59 +02:00
Andreas Kling
229dbd0ab2 GTableView: Only paint the currently visible table rows
This makes painting way faster for models with large amounts of data.
2019-09-18 14:10:09 +02:00
Andreas Kling
ce44d9a32f GWidget: Add a flag to ignore greediness in GWidget::hit_test()
Normally if a GWidget has the is_greedy_for_hits() flag set, all hit
tests will hit the widget itself instead of its descendants.

Sometimes it may be desirable to override this behavior, and so this
flag now allows you to do that.
2019-09-17 22:17:28 +02:00
Sergey Bugaev
053419dc3c Terminal: Ensure a \t always advances by at least one column 2019-09-17 21:56:42 +02:00
Sergey Bugaev
3824f572ef LibC: Ensure getopt error messages end with a newline
This is what POSIX seems to specify, and also what glibc getopt does.
2019-09-17 21:56:42 +02:00
Andreas Kling
68c06b8fac GComboBox: Use a down-arrow (instead of an up-arrow) for the button 2019-09-17 19:57:39 +02:00
Brandon Scott
a4d52b122d FileManager+LibGUI: Fix two folder-related crashes (#569)
Fix a crash when opening a folder, and another one when trying to open
a newly created folder.

It was not safe to modify a GModelSelection while it's being iterated over.

Fixes #536.
2019-09-17 09:26:10 +02:00
Andreas Kling
caf1b37e75 GTextEditor: Unbreak right-aligned single-line text boxes
This makes the Calculator app look right once again! :^)
2019-09-16 20:57:32 +02:00
Andreas Kling
fcf5b1ff5b Rect: Add set_right_without_resize() and set_bottom_without_resize()
Sometimes you want to move the Rect by its right or bottom edge without
resizing the rect in the process. There are probably better names for
this but nothing comes to mind at the moment.
2019-09-16 20:56:23 +02:00
Andreas Kling
f2b6e1b577 LibGUI: Add a fullscreen action to GCommonActions 2019-09-16 18:42:38 +02:00
Andreas Kling
d92e26d023 WindowServer+LibGUI: Allow switching windows in/out of fullscreen mode
You can now call GWindow::set_fullscreen(bool) and it will go in or out
of fullscreen mode.

WindowServer will also remember the previous window rect when switching
to fullscreen, and restore it when switching back. :^)
2019-09-16 18:38:42 +02:00
Conrad Pankoff
aa95bd7037 LibGUI: Fix move() of const StringView& 2019-09-16 07:49:43 +02:00
Conrad Pankoff
bfde6acd8c PNGLoader: Add load_png_from_memory method 2019-09-16 07:49:43 +02:00
Andreas Kling
77d6dbc236 GItemView: Elide item names that won't fit
This isn't perfect since now you will just see "Long name..." instead
of the whole name, but at least it doesn't look totally wrong either.
2019-09-15 15:47:26 +02:00
Andreas Kling
d754ac5bcb LibGUI+VisualBuilder: Add move-to-front/back to GCommonActions
Also give them nice little icons. :^)
2019-09-14 22:42:39 +02:00
Andreas Kling
b41b5433f4 LibGUI: Add Undo/Redo to GCommonActions 2019-09-14 22:23:49 +02:00
Andreas Kling
e83390387c LibGUI: Simplify GCommonActions a bit
Use the same callback signature as GAction so we can just forward it
to GAction instead of chaining callbacks.
2019-09-14 22:10:44 +02:00
Mauri de Souza Nunes
2d24b12a34 LibC: Implement mkdtemp library function 2019-09-14 12:05:50 +02:00
Andreas Kling
161cb89e87 LibC: Make gettid() cache the thread ID in thread-local-storage
This makes gettid() very cheap, compared to the cost of having to do
a syscall every time.
2019-09-14 11:37:58 +02:00
Andreas Kling
ec5091fa7d GraphicsBitmap: Allow constructing a wrapper bitmap around 8-bit pixels
This will be very useful for optimizing games like DOOM. :^)
2019-09-14 11:20:07 +02:00
Andreas Kling
c543ee5c5b WindowServer+LibGUI: Store a "data type" with the clipboard content
This will allow us to distinguish between different types of data
stored on the clipboard.
2019-09-14 09:19:05 +02:00
Andreas Kling
11f2e7cd5c GMenu: Update apps now that you can create a nameless GMenu
We had many context menus with names, simply because you were forced
to give them names.
2019-09-13 22:14:07 +02:00
Andreas Kling
f360858836 LibGUI: Tweak selection modification behavior on context menu event
Before bringing up the context menu, clicking...

- ...on an already selected item leaves selection alone
- ...on an unselected item makes it the only selected item
- ...outside any item clears the selection
2019-09-13 21:58:30 +02:00
Andreas Kling
f1c4b65089 GDirectoryModel: Add on_path_change hook 2019-09-13 21:43:23 +02:00
Andreas Kling
bf23f1e8bc GItemView: Add context menu support
Also, use the model_column() internally for selection as well as for
painting to keep things consistent.

Note that we always fire the on_context_menu_request hook, even if you
didn't click on an item. In those cases, you get a GModelIndex().
2019-09-13 21:42:26 +02:00
Andreas Kling
69365ccdd0 GMenu: Allow constructing without a name
We'll just default to "", which works fine for context menus.
2019-09-13 21:29:47 +02:00
Mauri de Souza Nunes
7d85fc00e4 Kernel: Implement fchdir syscall
The fchdir() function is equivalent to chdir() except that the
directory that is to be the new current working directory is
specified by a file descriptor.
2019-09-13 14:04:38 +02:00
Mauri de Souza Nunes
6d7c928359 LibC: Add MAXPATHLEN to limits.h
MAXPATHLEN defines the longest permissable path length after expanding
symbolic links. It is used to allocate a temporary buffer from the buffer
pool in which to do the name expansion, hence should be a power of two.

On UNIX MAXPATHLEN has the same size as PATH_MAX.
2019-09-13 09:21:41 +02:00
Andreas Kling
c74e4d0c80 LibC: Pass the environment as third argument to main()
After some very confused debugging, I discovered that GNU make has a
main() function with this signature:

    int main(int argc, char** argv, char** envp)

Apparently this is a non-standard but widely supported thing, so let's
do the same in Serenity so make works as expected.

This fixes an issue where you had to do "make PATH=..." instead of make
just picking up PATH from the environment. :^)
2019-09-12 21:43:32 +02:00
Andreas Kling
13ca1ee8dc GDirectoryModel: Allow retrieving an item's full path via Role::Custom 2019-09-12 18:58:52 +02:00
Andreas Kling
1cb661ae69 GModelSelection: Add size() and a const overload of for_each_index() 2019-09-12 18:42:15 +02:00
Andreas Kling
566eb58170 GDirectoryModel: Include directories in total byte count
I don't know what's really right or wrong here. It seems fine to also
include the directories in the total byte count, and it makes it a bit
easier to stay consistent when adding up size numbers elsewhere.
2019-09-12 18:41:28 +02:00
Andreas Kling
aeba1128e3 LibC: Add some missing errno codes 2019-09-12 18:26:19 +02:00
Andreas Kling
8b0d530584 LibC: fgets() shouldn't stop on '\0' 2019-09-11 23:01:55 +02:00
Andreas Kling
f89944e804 Inspector+LibCore+rpcdump: Rework the RPC stuff to be request/response
RPC clients now send JSON-encoded requests to the RPC server.
The connection also stays alive instead of disconnecting automatically
after the initial CObject graph dump.

JSON payloads are preceded by a single host-order encoded 32-bit int
containing the length of the payload.

So far, we have three RPC commands:

    - Identify
    - GetAllObjects
    - Disconnect

We'll be adding more of these as we go along. :^)
2019-09-11 21:19:23 +02:00
Andreas Kling
38b75d2a97 CIODevice: read(u8*, int) overload should return 0 on EOF 2019-09-11 21:13:14 +02:00
Andreas Kling
99970d7d4b CSocket: Share code between connect() overloads
Both overloads should know how to set up a notifier callback in case
we get EINPROGRESS from connect().

It might be even better to merge the connect() overloads into a single
function..
2019-09-11 19:44:15 +02:00
Andreas Kling
b305a51c90 CIODevice: read_all() should return a null ByteBuffer when nothing read
We were returning a zero-length ByteBuffer in some cases. We should be
consistent about this and always return a null ByteBuffer if nothing
was read at all.
2019-09-11 19:33:51 +02:00
Andreas Kling
ada1f504fd LibC: Make sure perror() is consistent about the errno it prints 2019-09-10 19:35:51 +02:00
Andreas Kling
31ba7ba2cc LibC: #define errno errno
This makes the binutils port build again, after the TLS changes.
2019-09-08 14:20:13 +02:00
Andreas Kling
64b1e9deec GTreeView: Make double-clicking toggle openable items 2019-09-07 21:45:06 +02:00
Andreas Kling
2f5b2685af GModel: Remove selected_index() and set_selected_index()
This breaks GSortingProxyModel selection preservation across resorts.
I'm not yet sure how we're going to solve that, but it's going to have
to work a bit differently than before, since the model itself no longer
knows what's selected.

Selection is now managed by GModelSelection which allows us to select
any arbitrary number of items, and to have different selections in
different views onto the same model. Pretty sweet. :^)
2019-09-07 21:39:44 +02:00