Compare commits

...

3 Commits

Author SHA1 Message Date
Pascal Abresch 8f5f7d8ddf Shared: introduce font size for StatusView based on scrollbar size
Change-Id: Ie3b8678678c0d940981f1785418aa8ab354d01c5
2021-12-17 23:13:27 +01:00
Jérôme Duval 101dc0ba83 strace: fix revents output for poll syscall
each poll_fd struct should be checked, valid when not -1 and revents not zero.

Change-Id: Ia624ad1369ad1a6066c9970a47cfac63fa773702
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4821
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-12-17 20:40:55 +00:00
Jérôme Duval 3285dcae22 tcp: reset receive.low_water_mark when nothing to read anymore
the socket interface module checks the receive.low_water_mark to automatically
notify a read event. available_data will be zero, thus enabling the notification.

fixes the test poll_nm in NSPR.

Change-Id: I5354faec439df96671506550cdb144a45f6082b1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4820
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2021-12-17 20:40:55 +00:00
7 changed files with 48 additions and 9 deletions

View File

@ -0,0 +1,7 @@
#include "Font.h"
namespace BPrivate {
float GetFontSizeForPixel(float maxSize, BFont font);
} // namespace BPrivate

View File

@ -1011,6 +1011,9 @@ TCPEndpoint::ReadData(size_t numBytes, uint32 flags, net_buffer** _buffer)
TRACE(" ReadData(): %" B_PRIuSIZE " bytes kept.",
fReceiveQueue.Available());
if (fReceiveQueue.Available() == 0 && fState == FINISH_RECEIVED)
socket->receive.low_water_mark = 0;
// if we are opening the window, check if we should send an ACK
if (!clone)
SendAcknowledge(false);
@ -1438,7 +1441,7 @@ TCPEndpoint::_ShouldReceive() const
return false;
return fState == ESTABLISHED || fState == FINISH_SENT
|| fState == FINISH_ACKNOWLEDGED;
|| fState == FINISH_ACKNOWLEDGED || fState == FINISH_RECEIVED;
}

View File

@ -429,7 +429,7 @@ add_tcp_header(net_address_module_info* addressModule,
optionsLength);
}
TRACE(("add_tcp_header(): buffer %p, flags 0x%x, seq %lu, ack %lu, up %u, "
TRACE(("add_tcp_header(): buffer %p, flags 0x%x, seq %" B_PRIu32 ", ack %" B_PRIu32 ", up %u, "
"win %u\n", buffer, segment.flags, segment.sequence,
segment.acknowledge, segment.urgent_offset, segment.advertised_window));

View File

@ -9,6 +9,7 @@
#include "StatusView.h"
#include <private/shared/FontUtil.h>
#include <stdio.h>
#include <stdlib.h>
@ -63,7 +64,7 @@ void
StatusView::AttachedToWindow()
{
SetFont(be_plain_font);
SetFontSize(10. * be_plain_font->Size() / 12.f);
SetFontSize(BPrivate::GetFontSizeForPixel(be_control_look->GetScrollBarWidth(), be_plain_font));
BMessage message(UPDATE_STATUS);
message.AddInt32("line", 1);

View File

@ -134,11 +134,7 @@ format_signed_number(int32 value)
static string
read_pollfd(Context &context, void *data)
{
nfds_t numfds = 0;
if (context.GetContents(Context::INPUT_VALUES))
numfds = get_value<nfds_t>(context.GetValue(context.GetSibling(1)));
else if (context.GetContents(Context::OUTPUT_VALUES))
numfds = context.GetReturnValue();
nfds_t numfds = get_value<nfds_t>(context.GetValue(context.GetSibling(1)));
if ((int64)numfds <= 0)
return string();
@ -157,6 +153,10 @@ read_pollfd(Context &context, void *data)
r = "[";
for (nfds_t i = 0; i < numfds && added < 8; i++) {
if ((tmp[i].fd == -1 || tmp[i].revents == 0)
&& context.GetContents(Context::OUTPUT_VALUES)) {
continue;
}
if (added > 0)
r += ", ";
r += "{fd=" + format_signed_number(tmp[i].fd);
@ -176,7 +176,7 @@ read_pollfd(Context &context, void *data)
flags++;
}
}
if (tmp[i].fd != -1 && context.GetContents(Context::OUTPUT_VALUES)) {
if (context.GetContents(Context::OUTPUT_VALUES)) {
r += ", revents=";
int flags = 0;
if ((tmp[i].revents & POLLIN) != 0) {

View File

@ -0,0 +1,27 @@
/*
* Copyright 2021, Pascal R. G. Abresch, nep@packageloss.eu.
* Distributed under the terms of the MIT License.
*/
#include <ControlLook.h>
#include <View.h>
namespace BPrivate {
status_t GetFontSizeForPixel(float maxSize, BFont font) {
float currentSize;
font_height fontHeight;
for (float fontSize = 9.0F; fontSize < maxSize; fontSize++) {
font.SetSize(fontSize);
font.GetHeight(&fontHeight);
currentSize = fontHeight.ascent + fontHeight.descent;
if (currentSize > maxSize) {
return fontSize -1.0F;
}
}
return maxSize;
}
} // namespace BPrivate

View File

@ -38,6 +38,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
CommandPipe.cpp
DragTrackingFilter.cpp
DriverSettingsMessageAdapter.cpp
FontUtil.cpp
HashString.cpp
IconButton.cpp
IconView.cpp