Commit Graph

12598 Commits

Author SHA1 Message Date
Tom
bcbe2fe525 Kernel: Protect looping over VMObject regions
We need to hold the memory manager lock so nobody else can modify
these lists while we're iterating them.
2020-08-26 01:25:06 +02:00
Ben Wiederhake
0e27a6e39e AK: Demonstrate and fix Checked
Specifically:
- post-increment actually implemented pre-increment
- helper-templates that provided operator{+,-,*,/}() couldn't possibly work,
  because the interface of add (etc) were incompatible (not taking a Checked<>,
  and returning void)
2020-08-26 00:55:13 +02:00
Ben Wiederhake
cd93fb9656 LibC: Deduplicate declaration of strcasecmp 2020-08-26 00:55:13 +02:00
Andreas Kling
9a25dd99c3 LibGUI: HeaderView should always notify parent when sections resize
The view needs to recompute the scrollable content size whenever this
happens, so let's always notify it. Previously we were only doing this
when resizing columns with interactively (not programmatically.)
2020-08-26 00:51:35 +02:00
Andreas Kling
cfc30b11ba LibGUI: Rename table view's "cell painting delegate" to "column *"
What you install with this API is a delegate that manages painting of
all the items in a specific column, so let's make the API reflect that.
2020-08-26 00:51:35 +02:00
Andreas Kling
44e371635e LibGUI: Move table view headers into their own widget
This patch introduces the HeaderView class, which is a widget that
implements the column headers of TableView and TreeView.

This greatly simplifies event management in the view implementations
and also makes it much easier to eventually implement row headers.
2020-08-26 00:51:35 +02:00
Andreas Kling
eca6ff353e LibGUI: Make Splitter inherit from Widget instead of Frame
It wasn't using any of the Frame features, so I'm not sure what the
idea here was.
2020-08-26 00:51:35 +02:00
Andreas Kling
ac78531756 LibGUI: Clip GUI::Frame children to the frame_inner_rect()
This way we don't draw the frame border underneath our children. :^)
2020-08-26 00:51:35 +02:00
Andreas Kling
a265d40d6e LibGUI: Allow widgets to clip their child widgets
This patch adds Widget::children_clip_rect() which can be overridden
to tighten clipping of a widget's children. The default implementation
simply returns Widget::rect().
2020-08-26 00:51:35 +02:00
Andreas Kling
965ccf5242 Spreadsheet: Focus the spreadsheet table on startup 2020-08-26 00:51:35 +02:00
Andreas Kling
af16552624 LibGUI: Add Widget focus proxies
A Widget can now have a focus proxy widget. Questions about focus are
redirected to the proxy if present. This is useful if a widget could
logically get focus, but wants one of its child widgets to actually
handle it.
2020-08-26 00:51:35 +02:00
Sergio Ahumada
9ba3862ee9 LibC: Prospective fix for openssl build
serenity/Build/Root/usr/include/sys/socket.h:93:26: error: 'sockaddr_un' undeclared here (not in a function)
   93 |         char data[sizeof(sockaddr_un)];
      |                          ^~~~~~~~~~~
make[2]: *** [<builtin>: bss_fd.o] Error 1
2020-08-26 00:46:04 +02:00
LepkoQQ
777b298880 LibGUI: Change window size and margin in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
9e75c124a8 LibGUI: Add spinbox for alpha channel in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
b10dde70b7 LibGUI: Show current and selected color comparison in ColorPicker 2020-08-26 00:38:23 +02:00
LepkoQQ
9f5310d607 LibGUI: Resize ColorPicker to include frame thickness
Also clamp mouse events to frame rect when dragging outside of the color
field area.
Store hue separately from color, to prevent pure white resetting the hue
back to 0.
2020-08-26 00:38:23 +02:00
LepkoQQ
189c493162 LibGUI: Split ColorPicker in to a field and slider 2020-08-26 00:38:23 +02:00
LepkoQQ
bb5014fad7 LibGfx: Use valid hsv values in painter debug 2020-08-26 00:38:23 +02:00
LepkoQQ
7a46e0fa35 LibGfx: Always use 0..360 0..1 0..1 in HSV colors 2020-08-26 00:38:23 +02:00
LepkoQQ
0604f82a96 LibGUI: Select current color when opening picker 2020-08-26 00:38:23 +02:00
Nico Weber
e4dac38127 JS Tests: Disable the one failing test when running test-js in Serenity 2020-08-25 21:23:10 +02:00
Nico Weber
31510de6a8 LibGUI: Make ScrollBar show hover state of scrubber after gutter drag
With this, if clicking the gutter until the scrubber's below the
mouse and then releasing the mouse, the scrubber is correctly
highlighted after releasing the mouse.
2020-08-25 20:20:45 +02:00
Nico Weber
a9136d0f47 LibGUI: Only paint ScrollBar hover states if a component is pressed
While left-mouse is pressed on any component (arrows, gutter, scrubber),
don't draw hover states for components other than the pressed component.

For example, while clicking the arrow-down button and then dragging
around, the arrow-up button and the scrubber now aren't highlighted.
This also means that during a gutter drag session, the scrubber
isn't highlighted while it's under the mouse cursor. That makes
sense, since we get the gutter drag behavior, not the scrubber
drag behavior, in this case.

The highlight is supposed to indicate "clickability", but if the
mouse is already down, they can't be clicked.

Now that I check for it, this seems to match the scrollbar behavior
on Windows.
2020-08-25 20:20:45 +02:00
Nico Weber
23e2944aa4 LibGUI: Make ScrollBar track the currently pressed component
And remove the now-redundant members m_scrubbing, m_scrubber_in_use,
and m_automatic_scrolling_kind.

This also made it clear that we weren't canceling the autoscroll
timer if the scrollbar got disabled while it was scrolling, so
this fixes that too.
2020-08-25 20:20:45 +02:00
Linus Groh
9ea6ef4ed1 LibJS: Make Interpreter::throw_exception() a void function
The motivation for this change is twofold:

- Returning a JS::Value is misleading as one would expect it to carry
  some meaningful information, like maybe the error object that's being
  created, but in fact it is always empty. Supposedly to serve as a
  shortcut for the common case of "throw and return empty value", but
  that's just leading us to my second point.
- Inconsistent usage / coding style: as of this commit there are 114
  uses of throw_exception() discarding its return value and 55 uses
  directly returning the call result (in LibJS, not counting LibWeb);
  with the first style often having a more explicit empty value (or
  nullptr in some cases) return anyway.
  One more line to always make the return value obvious is should be
  worth it.

So now it's basically always these steps, which is already being used in
the majority of cases (as outlined above):

- Throw an exception. This mutates interpreter state by updating
  m_exception and unwinding, but doesn't return anything.
- Let the caller explicitly return an empty value, nullptr or anything
  else itself.
2020-08-25 18:30:31 +02:00
Nico Weber
98dd034c29 LibGUI: Make scrollbars keep scrolling by page while clicking the gutter
Note that m_hovered_component is only updated on mouse move, not while
just keeping left down. It's arguably wrong to update it on mouse move
while the mouse is down, I'll probably change things so that it doesn't
update there either.

The behavior on click-in-gutter-keep-left-down-then-move-mouse varies
a surprising amount between platforms. This implements the macOS
behavior where the scrubber follows the mouse direction while scrolling
by pages. (To be precise, it's the macOS behavior of Finder and Preview,
Safari has Windows's scrollbar behavior).

On Windows, the first click locks in the scroll direction and then
dragging the mouse off the scrubber in that direction makes the
scroll continue, but dragging it off the other direction has no effect.
I see no reason for that behavior.
2020-08-25 18:09:56 +02:00
Nico Weber
0a462dac14 LibGUI: Keep scrollbar timer active while mouse is down
Rather than disable and re-enable the timer, always keep it active
and make it do collision checks to decide if it should have an effect.

This is because set_automatic_scrolling_active(true) calls the
timeout callback immediately before starting the timer, and
when clicking the gutter this callback could disable the timer
again (if the first page scroll put the scrubber under the cursor).

Intead of making set_automatic_scrolling_active() work when it's
called reentrantly (which is easy: just swap the order of
on_automatic_scrolling_timer_fired() and timer->start() so that
on_automatic_scrolling_timer_fired() can immediately stop the
timer again, but it's confusing), make the timer check if it
should do anything.

This is keyed off m_last_mouse_position instead of
m_hovered_component because m_hovered_component is a visual state
and we arguably shouldn't modify it while the left mouse button
is down (as it indicated what part is activated on click).
2020-08-25 18:09:56 +02:00
Nico Weber
b96759930d LibGUI: Extract ScrollBar::update_hovered_component() method 2020-08-25 18:09:56 +02:00
Nico Weber
bf0b5c3c5a LibGUI: Extract ScrollBar::component_at_position() method
...and use it in mousedown_event(), which allows putting in
stricter asserts.
2020-08-25 18:09:56 +02:00
asynts
10c6f062b3 AK: Add Endian.h header to replace NetworkOrdered.h. 2020-08-25 16:22:14 +02:00
Nico Weber
ecf6cbbd02 LibGUI: Make AutomaticScrollingKind a paramter on set_automatic_scrolling_active
Most callers of set_automatic_scrolling_active() also change
m_automatic_scrolling_kind, and it makes it possible to make timer
behavior dependent on the autoscroll kind later.
2020-08-25 16:21:26 +02:00
Nico Weber
129816e056 LibGUI: In ScrollBar, rename AutomaticScrollingDirection to AutomaticScrollingKind
Also rename Decrement to DecrementButton and Increment to
IncrementButton.
2020-08-25 16:21:26 +02:00
Nico Weber
c34956839e LibGUI: Make ScrollBar shift-click use same code path as scrubber click
It's slightly less code, and m_scrubber_in_use is now set correctly
when shift-clicking, keeping the mouse button down, and then
dragging the throbber.

The shift-click brings the scrubber under the cursor, and then
the scrubber_rect().contains() condition is true and both scrubber
drags and shift-click-drags are handled the same naturally.
2020-08-25 16:21:26 +02:00
Paul Scharnofske
88a2c245e5
AK: TestSuite: Define assert macros with do { } while(0). (#3292)
Consider the following scenario:

    if(condition)
        FOO();
    else
        bar();

Suppose FOO is defined as follows:

    #define FOO() { bar(); baz(); }

Then it expands to the following:

    if(condition)
        // Syntax error, we are not allowed to put a semicolon at the end.
        { bar(); baz(); };
    else
        bar();

If we define FOO as follows:

    #define FOO() do { bar(); baz(); } while(false)

Then it expands to the following:

    if(condition)
        do { bar(); baz(); } while(false);
    else
        bar();

Which is correct.
2020-08-25 16:20:52 +02:00
Tom
c2b9f8857c Kernel: Optimize SlabAllocator to be lock-free 2020-08-25 09:48:48 +02:00
Tom
81780e607d Kernel: Copy command line to a safe place
This avoids kmalloc overwriting it because it may be within the
kmalloc or eternal pool.
2020-08-25 09:48:48 +02:00
Tom
d89582880e Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because
MemoryManager::initialize is called before the global constructors
are run. That caused the Singleton to be re-initialized, causing
it to create another MemoryManager instance.

Fixes #3226
2020-08-25 09:48:48 +02:00
Tom
ba6e4fb77f Kernel: Fix kmalloc memory corruption
Rather than hardcoding where the kmalloc pool should be, place
it at the end of the kernel image instead. This avoids corrupting
global variables or other parts of the kernel as it grows.

Fixes #3257
2020-08-25 09:48:48 +02:00
Tom
08a569fbe0 Kernel: Make PhysicalPage not movable and use atomic ref counting
We should not be moving ref-counted objects.
2020-08-25 09:48:48 +02:00
AnotherTest
3320bb45d1 Spreadsheet: Add "Save As" 2020-08-25 09:46:28 +02:00
AnotherTest
5568da9a59 LibGUI: Add a save_as common action 2020-08-25 09:46:28 +02:00
AnotherTest
fdf0660064 Spreadsheet: Implement state-preserving saves and loads 2020-08-25 09:46:28 +02:00
Luke
916e5e8cb3 HackStudio: Add a registers view for the current function in debug mode 2020-08-25 09:46:06 +02:00
Luke
3ddc42fdf1 HackStudio: Add a disassembly view for the current function in debug mode 2020-08-25 09:46:06 +02:00
Luke
694b86a4bf LibDebug: Move everything into the "Debug" namespace 2020-08-25 09:46:06 +02:00
Luke
b58ca7cf3d Kernel: Scroll wheel amount on Intellimouse is 4 bits instead of 8
When trying to scroll up on virtualizers that don't use the VMware
backdoor and instead use PS2MouseDevice, it would actually scroll
down rapidly.

Looking into it, the mouse delta for scrolling down was 1 and 15
for scrolling up. 15 is suspiciously -1 for a nibble.

According to https://isdaman.com/alsos/hardware/mouse/ps2interface.htm
the Z is actually 4 bits for Intellimouse.

This fixes scrolling up on virtualizers such as VirtualBox.
2020-08-25 09:43:51 +02:00
Nico Weber
8b166e57df
Misc: Remove some unneeded includes of Timer.h and ElapsedTimer.h (#3286) 2020-08-25 09:41:56 +02:00
Sergio Ahumada
647f3b87bd Documentation: Update BuildInstructions.md
Add missing `cmake ..' line before compiling with make
2020-08-25 09:36:56 +02:00
Andreas Kling
f86c074be8 LibGUI: Pressing Return in an editable TableView should begin editing
This matches what happens when you double-click on a cell.
2020-08-24 21:20:54 +02:00
Andreas Kling
0f0b37d137 LibGUI: Return focus to view when stopping editing
If the editing widget (as provided by the editing delegate) was focused
when editing stops, have the view take back focus.
2020-08-24 21:10:00 +02:00