Commit graph

12773 commits

Author SHA1 Message Date
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
Andreas Kling 032f567422 LibGUI: Always update() after changing AbstractView sort column/order
Otherwise we may end up with a stale appearance until something else
causes it to repaint.
2020-08-24 21:06:42 +02:00
Andreas Kling 2cbe290930 LibGUI: Allow moving the TableView selection horizontally with keyboard 2020-08-24 21:03:34 +02:00
Andreas Kling e5a6e297bf LibGUI: Add AbstractTableView::scroll_into_view(ModelIndex, bool, bool)
This API lets you specify whether to scroll horizontally, vertically,
or both.
2020-08-24 21:03:34 +02:00
AnotherTest 4c65bd3731 Spreadsheet: Add back the menubar 2020-08-24 19:15:07 +02:00
AnotherTest 1e14b93407 Spreadsheet: Fix crash when a row number is selected 2020-08-24 19:15:07 +02:00
AnotherTest e65d54a2fa Spreadsheet: Avoid crashing when a cell is created mid-update
To reproduce:
- make sure A0, A1, A2 do not exist (i.e. have not been selected or
  written to)
- select A0
- type in =A1+A2
- see crash
2020-08-24 19:15:07 +02:00
AnotherTest de13c6939d Spreadsheet: Add a syntax highlighter to the cell editor 2020-08-24 19:15:07 +02:00
Andreas Kling 8a5ce41065 LibC: Remove unused data member in the qsort() implementation 2020-08-24 18:22:09 +02:00
Andreas Kling 50bca8fcef SystemMonitor: Tweak processor feature display a little bit
Flatten the CPU features array instead of showing it as raw JSON data.
2020-08-24 18:22:09 +02:00
AnotherTest 682b2fdb75 LibWeb: Move OutOfProcessWebView into the Web namespace 2020-08-24 18:21:33 +02:00
AnotherTest 09ccb46980 LibGUI: Calculate the text rect correctly in AbstractTableView
This fixes the misalignments when a header is not left-aligned.
2020-08-24 18:21:33 +02:00
AnotherTest d0c96ba2d8 Spreadsheet: Reformat the runtime file to comply with js standards 2020-08-24 18:21:33 +02:00
AnotherTest 54036d660a Meta: Move prettier config files to the root of the repository 2020-08-24 18:21:33 +02:00
AnotherTest 3a07f6e345 Spreadsheet: Document runtime functions and add a help window
...that can automatically generate documentation pages from the objects.
2020-08-24 18:21:33 +02:00
AnotherTest 12cf3e13c0 Spreadsheet: Add a topbar with a text editor 2020-08-24 18:21:33 +02:00
AnotherTest a6ebd29aa5 Spreadsheet: Start making a spreadsheet application 2020-08-24 18:21:33 +02:00
AnotherTest 5b5ba91335 AK: Add URL::create_with_data() to create data URLs 2020-08-24 18:21:33 +02:00
AnotherTest e1a819827c LibGUI: Make AbstractTableView and TableView more customisable
This patchset adds a few getters/setters to AbstractTableView to make
its looks more customisable:
- Header width & text alignment
- Default column width
- Ability to disable selected row highlighting
2020-08-24 18:21:33 +02:00
Nico Weber 697faba147 LibJS: Make Date.getUTCSeconds() call through to LibC
The tzset documentation says that TZ allows a per-second local timezone,
so don't be needlessly clever here.

No observable behavior difference at this point, but if we ever
implement tzset, this will have a small effect.
2020-08-24 18:21:16 +02:00
Nico Weber 2191ec591f LibJS: Make Date's tuple constructor correctly handle out-of-range arguments
Milliseconds need extra handling, but everything else just works
now that mktime() handles this case.
2020-08-24 18:20:07 +02:00
Nico Weber 5b9d43767c LibCore: Make DateTime::create() and set_time() handle out-of-range values
Set member variables after calling mktime(), which canonicalizes
out-of-range values.

With this, DateTime::create(2020, 13, ...) will return a DateTime
on Jan 2021 (assuming the other parameters are in range).
2020-08-24 18:20:07 +02:00
Nico Weber 593b0b9fcc LibCore: Less code duplication in DateTime
DateTime::create() an just call DateTime::set_time().

No behavior change.
2020-08-24 18:20:07 +02:00
Nico Weber 1c9581f383 LibC: Make mktime() / gmtime() more POSIX-compliant
mktime() is supposed to fill in tm_wday and tm_yday, and it
it's supposed to canonicalize out-of-range values (that is,
"Jan 31" is turned into "Feb 1").

Instead of making the straightfoward tm_to_time() implementation
more complicated, just make it call time_to_tm() once the timestamp
is computed to break it back down ot (canonical) tm entries.
2020-08-24 18:20:07 +02:00
Nico Weber 84f729c2b4 LibJS+LibC: Add tests for Date tuple ctor overflow and make mktime()/timegm() handle month overflow 2020-08-24 09:30:11 +02:00
AnotherTest 465d46c665 Meta+Userland: Run the TLS test too
While this _does_ add a point of failure, it'll be a pretty bad day when
google goes down.
And this is unlikely to put a (positive) dent in their incoming
requests, so let's just roll with it until we have our own TLS server.
2020-08-24 09:29:39 +02:00