Skip to content

Commit 0f68f9c

Browse files
committed
Layout fixes & log pipe syscall
1 parent 2fec9de commit 0f68f9c

File tree

15 files changed

+156
-45
lines changed

15 files changed

+156
-45
lines changed

applications/desktop/src/taskbar.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ void taskbar_t::paint()
187187
{
188188
if(entry->hovered)
189189
{
190-
cairo_set_source_rgb(cr, 37.0 / 255, 32.0 / 255, 39.0 / 255);
190+
cairo_set_source_rgb(cr, 30.0 / 255, 32.0 / 255, 39.0 / 255);
191191
}
192192
else
193193
{
194-
cairo_set_source_rgb(cr, 27.0 / 255, 28.0 / 255, 33.0 / 255);
194+
cairo_set_source_rgb(cr, 20.0 / 255, 28.0 / 255, 33.0 / 255);
195195
}
196196
}
197197
else
@@ -215,10 +215,9 @@ void taskbar_t::paint()
215215
TextLayouter::layout(cr, entry->title.c_str(), font, 14, textArea, TextAlignment::LEFT, textLayoutBuffer);
216216
for(PositionedGlyph& g: textLayoutBuffer->positions)
217217
{
218-
219218
cairo_save(cr);
220219
cairo_set_source_rgb(cr, 0.96, 0.98, 0.98);
221-
TextLayouter::paintChar(cr, g);
220+
TextLayouter::paintChar(cr, g, Point(entryLeft, 10));
222221
cairo_restore(cr);
223222
}
224223
}

applications/navigator/src/navigator.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <libfenster/layout/flex_layout.hpp>
3232
#include <libfenster/layout/grid_layout.hpp>
3333
#include <libfenster/layout/flow_layout.hpp>
34+
#include <libfenster/layout/stack_layout.hpp>
3435

3536
using namespace fenster;
3637

@@ -113,7 +114,7 @@ int main()
113114

114115
navText = TextBox::create();
115116
navBar->addChild(navText);
116-
navBarLayout->setComponentInfo(navText, 1, 1, 0);
117+
navBarLayout->setComponentInfo(navText, 1, 1, -1);
117118
navText->addKeyListener([](KeyEvent& e)
118119
{
119120
// TODO: g_keyboard needs a layout right now, maybe key events should already send ASCII codes:
@@ -144,8 +145,8 @@ int main()
144145

145146
Panel* centerPanel = Panel::create();
146147
centerPanel->setBackground(_RGB(255, 255, 255));
147-
GridLayout::create(centerPanel);
148148
{
149+
GridLayout::create(centerPanel);
149150
scroller = ScrollPane::create();
150151
content = Panel::create();
151152

@@ -158,7 +159,7 @@ int main()
158159
centerPanel->addChild(scroller);
159160
}
160161
window->addChild(centerPanel);
161-
windowLayout->setComponentInfo(centerPanel, 1, 1, 0);
162+
windowLayout->setComponentInfo(centerPanel, 1, 1, -1);
162163

163164
window->setVisible(true);
164165
window->onClose([]()

applications/testprogram/src/tester.cpp

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#include <cstdio>
2727
#include <libfenster/components/checkbox.hpp>
2828
#include <libfenster/components/label.hpp>
29-
#include <libfenster/layout/stack_layout.hpp>
29+
#include <libfenster/components/text_box.hpp>
30+
#include <libfenster/layout/grid_layout.hpp>
31+
#include <libfenster/layout/flex_layout.hpp>
3032

3133
int main(int argc, char** argv)
3234
{
@@ -41,45 +43,50 @@ int main(int argc, char** argv)
4143
{
4244
g_exit(0);
4345
});
44-
fenster::StackLayout::create(window);
46+
auto flex = fenster::FlexLayout::create(window);
4547

46-
auto panel = fenster::Panel::create();
47-
panel->setBackground(_RGB(200, 200, 255));
48+
auto textArea = fenster::TextBox::create();
49+
textArea->setMultiLine(true);
50+
textArea->setTitle("...");
51+
window->addChild(textArea);
52+
flex->setComponentInfo(textArea, 1, 1, -1);
4853

49-
auto stackLayout = fenster::StackLayout::create(panel);
50-
stackLayout->setPadding(fenster::Insets(10, 10, 10, 10));
51-
stackLayout->setSpace(20);
54+
auto lastRead = fenster::Label::create();
55+
lastRead->setTitle("Last read: -");
56+
window->addChild(lastRead);
57+
flex->setComponentInfo(lastRead, 0,0, 50);
5258

53-
auto testLabel = fenster::Label::create();
54-
testLabel->setTitle("Choose the checkbox to test listener behaviour:");
55-
panel->addChild(testLabel);
56-
57-
auto check = fenster::Checkbox::create();
58-
check->setTitle("Enable other field");
59-
panel->addChild(check);
59+
window->setTitle("Kernel log");
60+
window->setBounds(fenster::Rectangle(50, 50, 600, 600));
61+
window->setVisible(true);
6062

61-
auto conditionalLabel = fenster::Label::create();
62-
conditionalLabel->setTitle("Conditional label");
63-
conditionalLabel->setVisible(false);
64-
panel->addChild(conditionalLabel);
65-
check->addCheckedListener([conditionalLabel](bool checked)
63+
g_fd logPipe = g_open_log_pipe();
64+
if(logPipe == G_FD_NONE)
6665
{
67-
printf("Check state changed to %s\n", checked ? "checked" : "unchecked");
68-
conditionalLabel->setVisible(checked);
69-
});
66+
textArea->setTitle("Failed to open kernel log pipe");
67+
g_sleep(999999999);
68+
}
7069

71-
auto testLabel2 = fenster::Label::create();
72-
testLabel2->setTitle("Very cool.");
73-
panel->addChild(testLabel2);
70+
uint8_t buf[1] ={0};
71+
std::stringstream s;
72+
for(;;)
73+
{
74+
int r = g_read(logPipe, buf, 1);
75+
if(r == 0)
76+
{
77+
// Pipe is not blocking in both directions right now...
78+
g_sleep(100);
79+
continue;
80+
}
81+
s << (char) buf[0];
7482

75-
window->addChild(panel);
83+
textArea->setTitle(s.str());
7684

77-
window->setTitle("Test window");
78-
window->setBounds(fenster::Rectangle(70, 70, 400, 300));
79-
window->setVisible(true);
85+
if(s.str().size() > 1000)
86+
s.str("");
8087

81-
for(;;)
82-
{
83-
g_sleep(999999);
88+
std::stringstream out;
89+
out << s.str().size();
90+
lastRead->setTitle(out.str());
8491
}
8592
}

kernel/src/kernel/calls/syscall.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void syscallRegisterAll()
153153

154154
// System
155155
_syscallRegister(G_SYSCALL_LOG, (g_syscall_handler) syscallLog);
156+
_syscallRegister(G_SYSCALL_OPEN_LOG_PIPE, (g_syscall_handler) syscallOpenLogPipe);
156157
_syscallRegister(G_SYSCALL_SET_VIDEO_LOG, (g_syscall_handler) syscallSetVideoLog);
157158
_syscallRegister(G_SYSCALL_TEST, (g_syscall_handler) syscallTest);
158159
_syscallRegister(G_SYSCALL_CALL_VM86, (g_syscall_handler) syscallCallVm86);

kernel/src/kernel/calls/syscall_system.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ void syscallLog(g_task* task, g_syscall_log* data)
5959
}
6060
}
6161

62+
void syscallOpenLogPipe(g_task* task, g_syscall_open_log_pipe* data)
63+
{
64+
g_fs_node* node;
65+
if(filesystemCreatePipe(false, &node) != G_FS_PIPE_SUCCESSFUL)
66+
{
67+
logInfo("%! failed to open kernel log read pipe", "log");
68+
data->fd = G_FD_NONE;
69+
return;
70+
}
71+
72+
g_file_flag_mode readFlags = G_FILE_FLAG_MODE_READ;
73+
g_fs_open_status readOpen = filesystemOpenNodeFd(node, readFlags, task->process->id, &data->fd);
74+
if(readOpen != G_FS_OPEN_SUCCESSFUL)
75+
{
76+
logInfo("%! failed to open read end of kernel log pipe %i for task %i with status %i", "filesystem", node->id,
77+
task->id, readOpen);
78+
data->fd = G_FD_NONE;
79+
return;
80+
}
81+
82+
loggerEnablePipe(node);
83+
}
84+
6285
void syscallSetVideoLog(g_task* task, g_syscall_set_video_log* data)
6386
{
6487
loggerEnableVideo(data->enabled);

kernel/src/kernel/calls/syscall_system.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
void syscallLog(g_task* task, g_syscall_log* data);
2828

29+
void syscallOpenLogPipe(g_task* task, g_syscall_open_log_pipe* data);
30+
2931
void syscallSetVideoLog(g_task* task, g_syscall_set_video_log* data);
3032

3133
void syscallTest(g_task* task, g_syscall_test* data);

kernel/src/kernel/kernel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ void kernelInitializationThread()
226226

227227
G_PRETTY_BOOT_STATUS_P(80);
228228
kernelSpawnService("/applications/fenster.bin", "", G_SECURITY_LEVEL_APPLICATION);
229+
kernelSpawnService("/applications/tester.bin", "", G_SECURITY_LEVEL_APPLICATION);
229230
// G_PRETTY_BOOT_STATUS_P(80);
230231
// kernelSpawnService("/applications/terminal.bin", "--headless", G_SECURITY_LEVEL_DRIVER);
231232

kernel/src/kernel/logger/logger.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020

2121
#include "kernel/logger/logger.hpp"
22+
23+
#include <kernel/ipc/pipes.hpp>
24+
25+
#include "kernel/memory/memory.hpp"
2226
#include "kernel/system/spinlock.hpp"
2327
#include "kernel/system/interrupts/interrupts.hpp"
2428
#include "kernel/build_config.hpp"
@@ -32,6 +36,8 @@ static bool logSerial = false;
3236
static bool logVideo = G_VIDEO_LOG_BOOT;
3337
g_spinlock loggerLock = 0;
3438

39+
g_fs_node* pipeNode = nullptr;
40+
3541
void loggerPrintLocked(const char* message, ...)
3642
{
3743
INTERRUPTS_PAUSE;
@@ -245,11 +251,25 @@ void loggerPrintPlain(const char* message_const)
245251
void loggerPrintCharacter(char c)
246252
{
247253
if(logVideo)
248-
{
249254
consoleVideoPrint(c);
250-
}
251255
if(logSerial)
252-
{
253256
debugInterfaceWriteLogCharacter(c);
257+
258+
if(pipeNode != nullptr)
259+
{
260+
uint8_t buf[1];
261+
buf[0] = c;
262+
int64_t wrote;
263+
pipeWrite(pipeNode->physicalId, buf, 0, 1, &wrote);
264+
if(wrote == 0)
265+
{
266+
pipeTruncate(pipeNode->physicalId);
267+
pipeWrite(pipeNode->physicalId, buf, 0, 1, &wrote);
268+
}
254269
}
255270
}
271+
272+
void loggerEnablePipe(g_fs_node* node)
273+
{
274+
pipeNode = node;
275+
}

kernel/src/kernel/logger/logger.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include "kernel/logger/logger_macros.hpp"
2828

29+
struct g_fs_node;
30+
2931
void loggerPrintLocked(const char *message, ...);
3032

3133
void loggerPrintlnLocked(const char *message, ...);
@@ -38,6 +40,8 @@ void loggerEnableSerial(bool enable);
3840

3941
void loggerEnableVideo(bool video);
4042

43+
void loggerEnablePipe(g_fs_node* node);
44+
4145
void loggerPrintPlain(const char *message);
4246

4347
void loggerPrintCharacter(char c);

0 commit comments

Comments
 (0)