Commit Graph

9428 Commits

Author SHA1 Message Date
Fredrik Holmqvist
da93a24811 efi_guid struct gets equals, simplify EFI acpi_init
Change-Id: Id4bc985dc1e6f44b594f6ca5dabd3fdac8e1cac2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3545
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
2020-12-22 22:12:13 +00:00
Adrien Destugues
8a72ba1b54 Tracker: improve algorithm to decide desktop text color
Fixes #16673
2020-12-19 10:17:55 +01:00
X512
553f3f2309 AutoDeleter: add delarations for common types and destructors
Change-Id: I74b75a54038d5af370696302f33b5c0abab4820c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3481
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-13 19:14:13 +00:00
X512
84b1893b73 AutoDeleter: introduce HandleDeleter
It allow to use arbitrary handle type, null value and destructor function.

Change-Id: I87c444cb7ef1b08d1dbed7fe4171700171d651d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2977
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-12-13 19:14:13 +00:00
Anarchos
74b6097078 sd/mmc: read, naive method
First implementation of reading sectors from an SD card.
This is not the best performance for many reasons:
- No DMA
- Reads only one sector at a time
- Cannot read more than 512 bytes per syscall

Also there are major limitations:
- Cannot read less than 512 bytes. The hardware of course works in full
  sectors. The mmc_disk driver should go through the io scheduler to
  make sure requests have a reasonable size and offset, and nothing
  tries to read just a few bytes in the middle of a sector.
- SD cards only (no SDHC, no MMC)

Architecture problems:
I think too much of the implementation is done in sdhci_pci and should
be moved to the upper layers. However it is difficult to say without
having implemented DMA (which indeed will be at the low level of the
sdhci controller). It doesn't help that the order of operations is a
bit different depending on wether there is DMA or not. In DMA mode you
first prepare the buffer, then run the command. In non-DMA mode you
first send the command, then read the data into the buffer. We need an
API at the mmc_bus level that doesn't care about that low-level detail.
There are other things that the MMC bus should be doing however, such
as switching to different clock speeds depending on which card is
activated and how fast it can go.

At least the following should be done:
- The read method for mmc_bus and sdhci_pci should use a scatter-gather
structure as a parameter instead of a single buffer
- See if can be integrated into ExecuteCommand at sdhci level (it's
essentially a command with an additional data phase)

Change-Id: I688b6c694561074535c9c0c2545f06dc04b06e7d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3466
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-12-13 18:56:19 +00:00
Adrien Destugues
e46898932c Initial work for the mmc_disk driver
No read and write support for now. But we implement getting SD card
capacity. SDHC is not supported yet (it uses a different layout for the
CSD register which will be rejected by this version of the code)

Change-Id: Ife844a62f3846c0a780259e9a3a08195e2fd965e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1068
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-12-13 18:56:19 +00:00
Andrew Lindesay
5b1ae51c6b HaikuDepot: Memory Leak Fix
Change-Id: Ibd311d10009484ba834843149740c5a11f283202
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3500
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2020-12-13 10:07:22 +00:00
Adrien Destugues
5b627acb33 Build fix.
Desynchronisation between fs_shell and normal autodeleter files
2020-12-10 18:01:22 +01:00
X512
76ab85671d AutoDeleter: fix AutoDeleter size
C++ don't allow zero size class fields. If field with empty class field
is used, it's size will be 1 byte.

Create DeleteFunc instance as local variable at each use instead.

Fixes #16638.

Change-Id: Ifb76c45ea02e9fed014751542ee5f16f41e11d15
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3458
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-10 11:39:49 +00:00
X512
aecba91311 AutoDeleter: move destructor function in MethodDeleter from constructor to template argument
The same as CObjectDeleter.

Change-Id: I85c4cb3635f01f13e529ca087324cc2fcb42cfc0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3456
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-10 11:39:49 +00:00
X512
7d775e7925 AutoDeleter: move destructor function in CObjectDeleter from constructor to template argument
It allows to make typedef of pointer types and declaring pointers in headers.

Store of destructor function pointer in CObjectDeleter is no longer needed.

Change-Id: Ic629fd10b28b09f4190edf8ba6b911ca3108ab0e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3455
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-10 11:39:49 +00:00
Alexander von Gluck IV
9adc70887e efi: Call console-control to enter text mode
Change-Id: Ife1df3415bc5a31801bcb3d925f1b7c3a105f51b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2250
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-07 11:32:28 +00:00
Adrien Destugues
a959262cd0 implement mlock(), munlock()
Change-Id: I2f04b8986d2ed32bb4d30d238d668e21a1505778
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1991
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-12-03 07:58:05 +00:00
Jérôme Duval
c5ff1f14c6 syslog.h: add LOG_PRIMASK and LOG_PRI macros
Change-Id: I9ae0c3165cea831e329e49211ff738cbb89a65de
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3408
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-11-22 09:28:57 +00:00
Jérôme Duval
2982d9819f fcntl.h: define O_DIRECT directly
coreutils wants to undefine O_NOCACHE, this shouldn't affect O_DIRECT though.

Change-Id: Id00316a78eb91b2c7f692bb46eca65b3a7983c6f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3398
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-20 18:23:35 +00:00
Murai Takashi
cb5156f081 LayoutBuilder.h: Fix use after free
Fix 'item' is used after delete.
Pointed out by Clang Static Analyzer.

Change-Id: I8eca3084c97b37015a2da1b96119a458d4eb9aa7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3392
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: John Scipione <jscipione@gmail.com>
2020-11-19 07:17:29 +00:00
Jérôme Duval
a1999d3b8a POSIX: add tcsetsid()
Change-Id: Ia8f41e417379dcaf4f976933cf91bb2de157bc72
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3376
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-17 07:53:28 +00:00
Jérôme Duval
e04970ad6f POSIX: add utmpx.h and function stubs
OpenJDK 14 assumes symbols and headers are available.

Change-Id: I21038e92afcfd2000ee95712bce874afd29611b6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3371
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-17 07:46:30 +00:00
Andrew Lindesay
027d608682 HaikuDepot: LRU Cache for Icons
Only keep a fixed number of icons in memory at once.

Completes To #15370

Change-Id: I23e3a4fa7559894034f45afb3b536910ea037078
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3367
Reviewed-by: Rene Gollent <rene@gollent.com>
2020-11-15 20:16:14 +00:00
Jérôme Duval
a9c09fcaae POSIX: lseek: support SEEK_DATA and SEEK_HOLE constants
this is queued for issue 8: https://www.austingroupbugs.net/view.php?id=415
this implementation calls the ioctl hook of the filesystem with BSD-like constants
FIOSEEKDATA and FIOSEEKHOLE. if the hook doesn't know the constants, we use the stat size
to return the last hole (as proposed in the draft spec).

Change-Id: I5d052eed87e29b70491a7ff534e244896469d03e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3385
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-11-12 10:42:11 +00:00
Jérôme Duval
fe357eb9c9 POSIX: add posix_fallocate and a preallocate syscall
the preallocate syscall will call the preallocate filesystem hook, if available.

fix #6285

Change-Id: Ifff4595548610c8e009d4e5ffb64c37e0884e62d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3382
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-11-12 10:41:21 +00:00
Jérôme Duval
b05d6f0af0 POSIX: asprintf and vasprintf are BSD/GNU extensions
fix #16259

Change-Id: Ia16bb6e1944b87b25d1a940bbdaaf6e236db1abf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3381
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-07 08:49:34 +00:00
Jérôme Duval
6878792ae4 C11: add aligned_alloc()
Change-Id: If648c0e27ed946874d393e8e33a4548b70c8ecdb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3377
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-04 21:01:42 +00:00
Jérôme Duval
b48159dce2 POSIX: add tcgetsid()
Change-Id: If58141b4e56b7fe444460b6808e33abc5ea71f37
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3374
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-11-04 06:18:17 +00:00
Jérôme Duval
7335fb0d5c in6.h: declare in6_addr with a union and extra fields
According to https://tools.ietf.org/html/rfc3493:
3.2 IPv6 Address Structure
"The structure in6_addr above is usually implemented with an embedded
union with extra fields that force the desired alignment level in a
manner similar to BSD implementations of "struct in_addr"."

Change-Id: Ibe0ee685366398c143cdf9573dcb77566a12888b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3348
Reviewed-by: Rene Gollent <rene@gollent.com>
2020-10-23 08:13:03 +00:00
Jérôme Duval
d504f219f4 POSIX: add _SC_TTY_NAME_MAX
Change-Id: Ifa24f68535d7a4a4c5fe3f01e63fe2c87adcc429
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3340
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-10-23 07:08:03 +00:00
François Revol
ad22267906 m68k: Add missing disklabel.h for NeXT support
Currently used by fixup_next_boot_floppy.

Change-Id: I47c10657b5280f00e470a3171ad11744859ce76c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3310
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-12 06:36:15 +00:00
Leorize
e67a4284c0 libbnetapi: Disallow instantiation of BUrlRequest subclasses directly
This API change forces all creation of BUrlRequest to be done via
BUrlProtocolRoster::MakeRequest(). This allows the structure of protocol
addons to be altered without breaking ABI for client applications.

Change-Id: I1785c9136c50d19eaa9e57cb9d259ed8d88a5b56
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3080
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-10-12 06:36:00 +00:00
Adrien Destugues
62eaf4c0e1 mmc_bus: add execute_command function
For now it just forwards the command to the SDHCI controller.
The bus will gain more features and functions as work advances (tracking
which card is active, arbitration of DMA transfers, etc).

Change-Id: I094eb84f27e7789387a3f8fb65fba1e5fcfa3e8a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3094
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-10-11 16:02:22 +00:00
Adrien Destugues
dedbe94e46 mmc: register devices for detected cards
Change-Id: I90891ead9a425e0e8bd25c2190fe3d430d49411b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1067
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-10-11 16:02:22 +00:00
John Scipione
7c095f4709 BeControlLook: Fix app integration drawing issues
Update BTab::DrawTab() to pass the current index, the index of the
selected tab, and the index of the first and last tabs into
BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab().
This allows you to draw tabs differently in your BTab or BControlLook
subclass in many different circumstances.

Modify BControlLook API to add indexes to DrawActiveTab() and
DrawInactiveTab() like so:

void DrawActiveTab(..., int32 index = 0, int32 selected = -1,
	int32 first = 0, int32 last = 0);
void DrawInactiveTab(..., int32 index = 0, int32 selected = -1,
	int32 first = 0, int32 last = 0);

These extra indexes are not used by HaikuControlLook which relies only
on if the tab is active or inactive to draw.

Add IndexOf(BTab* tab) method to BTabView and document it to get the
index of the current tab in BTab::DrawTab(). Also add a warning in the
BTabView::DrawTab() method not to use the position and full parameters
anymore, use BTabView::IndexOf(), BTabView::Selection(), and
BTabView::TabCount() to get the info you need.

Using a dynamic_cast to a BTabView in BeControlLook to determine if the
view is derived from a BTabView didn't work in the case of WebPositive.
Furthermore, WebPositive does custom tab drawing which needed to be
updated for alternative control look. These index parameters passed from
BTab to BeControlLook allow us to draw the tab like BeOS without relying
on a dynamic_cast to BTabView to get the info.

Reproduce the functionality described above for BTab in WebPositive's
custom tabs. Eliminate no longer needed code in favor of using indexes.
Update WebPositive custom tabs to use BControlLook::DrawTabFrame()
instead of BControlLook::DrawInactiveTab() matching the update made in
BTabView.

In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive
doesn't draw any tab background, so it expects this work to be done for
it.

Eliminate hasFrames variable from WebPositive.

Rename TabSelected(index) to UpdateSelection(index) in WebPositive to
better reflect its purpose.

Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more
selectively. Only draw border if left border is set for top and bottom tabs
or top border is set for left and right tabs. Undo no longer needed frame
manipulation border drawing workaround in HaikuControlLook::DrawTabFrame().

Draw scroll bar triangle without using DrawArrowShape().

Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in
BOutlineListView and menus distinctly from how it draws arrows in scroll
bars. Draw our distinct arrows in DrawSrollBarButtons() instead.

This fixes overflow of time edit up-down arrows in Clock prefs and the
collapse-expand arrow in Deskbar not being vertically centered.

In DrawBorders() only inset if we actually draw the border.

Fix alignment issues with DrawSliderThumb dots for example in
MediaPlayer volume knobs.

Draw using line arrays calling AddLine instead of StrokeLine in
several places.

DrawMenuBar() extends to draw final pixel which eliminates an extra
lines at the end of menu bars.

Truncate button labels better fixing a few issues for example keymap
keyboard layout button labels. Button insets has been updated a bit
to fix drawing issues with buttons missing a border.

Using a dynamic_cast to a BButton to determine if a view is a button
in BeControlLook didn't work in the case of the keymap label. Look for
B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel()
to draw the label inverted on click. Pass the B_FLAT flag from Keymap
keys when drawing using BControlLook so that the label is inverted.

Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-11 15:50:18 +00:00
Augustin Cavalier
64b46b706b headers: Adjust GCC2 stdbool to be usable by modern GCC.
musl's allocator needs to be built with GCC 8, but we need to link
it into GCC 2 libroot, which uses GCC 2 headers.
2020-10-10 16:36:59 -04:00
Jérôme Duval
06ed32b8c4 BCursor: add a constructor with bitmap and point
* enhancement #15169
* get_mouse_bitmap(): also reads the colorspace from app_server.
* docs and tests

Change-Id: Iba63f8a2789530ae596c30b92f14828f31761d98
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3292
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-08 08:23:31 +00:00
Jérôme Duval
db9d2a6f14 POSIX: add dprintf
Change-Id: I577d5283a9be04924a8dd05c3be3969b41da60db
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3282
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-04 19:34:40 +00:00
Jérôme Duval
513955e6c0 GraphicsCard.h: remove declarations for dprintf and set_dprintf_enabled
Change-Id: Ie8bbfcf2f23cf0ee36dc74e76062f21c99effc96
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3281
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-03 11:52:37 +00:00
Jérôme Duval
64331e96ca kernel/x86: extend CR4 flags
Change-Id: I4861f6cd61d0daeeb2403d07e703b83cd6a00666
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3280
Reviewed-by: Rene Gollent <rene@gollent.com>
2020-10-02 17:12:06 +00:00
Alexander G. M. Smith
a22fa0c977 package kit: Add pre-uninstall scripts feature.
Just like post-install scripts which run shortly after a package is
installed, pre-uninstall scripts are run just before a package is
removed.  Implements enhancement #13427

* Fix script exit code handling vs script launch errors.
* Bump package and repo file version numbers due to new attribute,
  unfortunately makes new .hpkg files not backwards compatible.
* Add pre-uninstall functionality, mostly cloning the post-install
  except in a few places.
* Discover that _RunQueuedScripts() is never called, a future TODO:?
* Update package documentation for pre-uninstall scripts, and use of
  the boot/post-install directory.

Change-Id: I45596255ce74bc102f6e5b606cbf83e4e4347a17
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1504
Reviewed-by: Alexander G. M. Smith <agmsmith@ncf.ca>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-21 10:47:57 +00:00
CodeforEvolution
5c32512076 GNU Compatibility: Implement qsort_r
This is a version of the qsort function allowing you to pass a "cookie" to the function.

Change-Id: I60c645213b9c9590e38b112634fcac1d7969b6d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2449
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-18 06:25:20 +00:00
Jérôme Duval
e632208b79 kernel/scheduler: enable cpu load tracking after boot
when the cpufreq module is loaded, we let the scheduler update its policy.
Improve assert report
CoreEntry::GetLoad() could return more than kMaxLoad.

Change-Id: I127f9b3e8062b5996872aae30b4021b9904fa179
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3216
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-09-17 15:45:25 +00:00
Alexander von Gluck IV
0558674126 efi: fix pointer width on non-64-bit platforms
Change-Id: I041238af87df3e1e3a967216685413801fd49877
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2450
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
2020-09-17 13:58:55 +00:00
Jérôme Duval
357b9d3cbb x86: identify Hygon vendor
it's a Zen-based CPU: rely on AMD support code.

Change-Id: Ia980a42457575bf8d1130d813310a285bf137691
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3217
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-15 20:43:45 +00:00
Jérôme Duval
7c1bcc9cae kernel/x86: add MSR for HWP and extended CR0 flags
Change-Id: I9e5d5421dabbdf7d4ecf6334509178f8f892591f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3215
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-09-15 20:43:17 +00:00
Jérôme Duval
22fdfc4428 kernel/cpu: add cpu_frequency()
implement on x86 with APERFMPERF.

Change-Id: Ia484854c76dee76c5447983de15800a25d791d39
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3213
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-09-15 20:42:14 +00:00
Jérôme Duval
026c8b9c04 kernel/smp: add call_single_cpu()
to call a function on the target cpu. Early mechanism not available.

Change-Id: I9d049e618c319c59729d1ab53fb313b748f82315
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3212
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-09-15 20:42:14 +00:00
Jérôme Duval
eb7ac342a0 kernel/x86: detect power subfeatures
Change-Id: Id159f0d7fc7816b6a40b9cf28f53dfdbebd04a73
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3211
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2020-09-14 19:24:25 +00:00
Adrien Destugues
a52008cb44 tty: implement TCFLSH to flush buffers
This is probably incomplete. Is locking needed? Should we notify the
next writer (if any) that the port is writable when flushing the output?

Change-Id: I2566e2d036a61af4819894a44f57603179aa27df
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2516
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-14 13:35:23 +00:00
John Scipione
fe88ae51ec AppKit: BMessage Add/Find/Get/Has/ReplaceNodeRef
This allows you to pass node_ref's around like you can entry_ref's.

Added node_ref_flatten(), node_ref_unflatten() and node_ref_swap() to
MessageUtils. These are close cousins to entry_ref_flatten(),
entry_ref_unflatten(), and entry_ref_swap() but for node_ref's.

Added B_NODE_REF_TYPE to TypeConstants.h in the Support Kit.

Added B_NODE_REF_TYPE to Debugger and ByteOrder in Support Kit,
B_NODE_REF_TYPE is treated the same as a B_REF_TYPE (entry_ref).

Add documentation for new NodeRef methods and B_NODE_REF_TYPE.

Change-Id: I32c6ed276bf1a7894a835b9fc9de5a882c35883c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3182
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-10 17:18:09 +00:00
Preetpal Kaur
02ad22d6c8 Input: declare BString to get the Mouse Name
Change-Id: I3476f58839202a6fd8c93e325a15045963a9b7b2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3125
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-10 17:15:09 +00:00
Preetpal Kaur
37d793236c Added get_set_mulitple_mouse_type() functions
Change-Id: I95f85a15a77c3a548bb672cb966ae7b13fcefcc8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3127
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-10 17:15:09 +00:00
John Scipione
d9385a9d38 IK: align BTextView text rect/fix alignment
Recalculate line breaks in FrameResized() if word-wrap is on, otherwise
only move the text rect into position. StyledEdit was recalculating line
breaks before on resize (we have to in this mode) and the frame offset
updates for non-wrapping text views are inexpensive. This makes resizing
text view's work like StyledEdit everywhere.

Scroll to cursor when word-wrap setting changes if text view is editable.
If you are viewing a long document changing word-wrap can move the cursor
quite far, so scroll back to it.

Fix _ActualTabWidth() pen location for right and center-aligned text views
so that tabs widths are calculated correctly.

Reset fTextRect horizontal limits to bounds minus insets in
_RecalculateLineBreaks(), then grow fTextRect based on alignment when
wrap is off.

Fixing insets also fixes right and center-aligned BTextViews.
Left-aligned text view's grow right, right-aligned ones grow left,
and center-aligned ones grow out.

Make extra scrolling space for all aligned text views go the other way
from how it did in hrev24130 (and on left-aligned text view's too) so
that half the text is visible when you edit past the end or before the
beginnning of a text view instead of none of it.

Fixes #1651 #12608 #13796 #15189

Do not _RecalculateLineBreaks() if text view bounds are invalid.
In SetText() detect invalid text view bounds and resize the view to the
width and height of the first line. Then recalculate line breaks.
This fixes BAlert text view size issues.

Fixes #16481 (regression from hrev54496.)

Remove useless and heavy computation. There is no point in computing line
breaks for a 10px wide text view and it takes a long time because it needs
a lot of linebreaks. The view eventually gets laid out properly.

Fixes #5582 (which was not locale-related, after all.)

Only apply default insets if text rect is set to bounds. This ensures
that apps that manipulate the text rect can continue to do so without
the default insets interfering while apps that don't can benefit
from the defaults. If you want to set the text rect to bounds and
not use the default insets you must override the default by calling
SetInsets(). This prevent the default insets from being applied once
apps have changed the text rect fixing a bug in Icon-O-Matic where the
text rect insets were being applied incorrectly.

Fixes #16488 (regression from hrev54496.)

Reduce left and right insets inside text views from full label spacing
to half label spacing. Unify padding between BTextControl and BTextView.

Move fLayoutData->UpdateInsets() to private BTextView::_UpdateInsets()
because we need access to BTextView member variables when deciding
whether or not to add the default padding or not.

_UpdateInsets() changes:
* Don't update insets if BTextView::SetInsets() was called.
* Don't add default insets unless fTextRect is set to view Bounds().
* Do not set the right and bottom insets to left and top if negative,
  set them to 0 like we do to left and top -- DeskCalc bug otherwise.

Fixes #15688

Other BTextView fixes:
* Replace max_c and min_c with std::max and std::min respectively.
* Remove scrolling from one instance of BTextView::SetText() as it
  produced undesired results while editing a scrolled text view.
* Add default insets in _UpdateInsets()
* Fix scrolling when entering and deleting text so that some part of
  the text is always visible. Make visible scroll width depend on font
  size.
* Allow scrolling to a negative offset in x but not y. This allows you
  to scroll the entire contents of right and centered-aligned text views
  whose content does not fit in the box.
* Change _Refresh() to take an offset instead of a bool so that you can
  scroll to any offset.
* Replace TextLength() with fText->Length() in a couple of places.

TextControl changes:
* Set text rect in BTextControl::DoLayout().
* Remove AlignTextRect() from TextInput.

Fix the following problems in apps:

ScreenSaver: Set text rect in PreviewView::AddPreview().
Tracker: Set "Edit name" text view insets to 2. Tweek text rect position
  to be on top of label in icon, mini-icon, and list mode. Add a TODO that
  the text rect is a pixel off from the name on some files.
Mail: Remove _AlignTextRect() and FrameResized() from AddressTextControl.
  Use default insets on the text view, defaults are fine here.
DeskCalc: Set insets based on font size in ExpressionTextView
  SetTextRect() instead of manipulating the text rect.
  Remove _CheckTextRect() and related methods from InputTextView.
Icon-O-Matic: Remove _CheckTextRect() and related methods from InputTextView.
WebPositive: Remove _AlignTextRect() and FrameResized() from URLTextView
  and call SetInsets().
StyledEdit: Word-wrap and FrameResized() changes ported to BTextView.

Fixes #16476 #16480 #16488 (regressions from hrev54496.)

Change-Id: Ifeca6077f8815ccd86d5a3880f99556298aaf0fe
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3152
Reviewed-by: John Scipione <jscipione@gmail.com>
2020-09-07 22:10:36 +00:00