Skip to content

Commit

Permalink
wm: spawn more windows for testing
Browse files Browse the repository at this point in the history
- pipefs: correctly handle empty buffer
  • Loading branch information
ffwff committed Sep 8, 2019
1 parent 1914f5a commit d367adb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions pkgs/wm/canvwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ int main(int argc, char **argv) {
window_redraw(ctx, &sprite, 0);

// connect
int fd = open("/fb0", 0);

printf("initializing connection\n");
int fb_fd = open("/fb0", 0);

Expand Down Expand Up @@ -149,6 +147,11 @@ int main(int argc, char **argv) {
sprite.x += atom.mouse_event.delta_x;
if(!(atom.mouse_event.delta_y < 0 && sprite.y < -atom.mouse_event.delta_y))
sprite.y += atom.mouse_event.delta_y;
if((atom.mouse_event.x - sprite.x) < 10) {
// window_redraw(ctx, &sprite, 1);
char *spawn_argv[] = {"canvwin", NULL};
spawnv("canvwin", (char **)spawn_argv);
}
}
} else if (atom.mouse_event.type == WM_MOUSE_RELEASE && mouse_drag) {
mouse_drag = 0;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/wm/wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ int main(int argc, char **argv) {
wm.mouse_win->z_index = (size_t)-1;
}

wm_sort_windows_by_z(&wm);

// sample win
char *spawn_argv[] = {"canvwin", NULL};
spawnv("canvwin", (char **)spawn_argv);

wm_sort_windows_by_z(&wm);

// disable console
ioctl(STDOUT_FILENO, TIOCGSTATE, 0);

Expand Down
9 changes: 5 additions & 4 deletions src/fs/impl/pipefs.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private class PipeFSNode < VFSNode
property prev_node

def initialize(@name : GcString, @parent : PipeFSRoot, @fs : PipeFS)
# Serial.puts "mk ", @name, '\n'
end

@buffer = Pointer(UInt8).null
Expand All @@ -78,10 +79,10 @@ private class PipeFSNode < VFSNode

def read(slice : Slice, offset : UInt32,
process : Multiprocessing::Process? = nil) : Int32
# Serial.puts "read ", @name, " ", process.not_nil!.pid, '\n'
init_buffer
if @buffer_pos == 0
# TODO
VFS_ERR
0
else
# pop message from buffer
size = min(slice.size, @buffer_pos)
Expand All @@ -93,10 +94,10 @@ private class PipeFSNode < VFSNode

def write(slice : Slice, offset : UInt32,
process : Multiprocessing::Process? = nil) : Int32
# Serial.puts "write ", @name, " ", process.not_nil!.pid, '\n'
init_buffer
if @buffer_pos == BUFFER_CAPACITY
# TODO
VFS_ERR
0
else
# push the message on to the buffer stack
size = min(slice.size, BUFFER_CAPACITY - @buffer_pos)
Expand Down

0 comments on commit d367adb

Please sign in to comment.