Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing nw_move() and nw_resize() implementations #290

Open
ry755 opened this issue Dec 13, 2023 · 3 comments
Open

Missing nw_move() and nw_resize() implementations #290

ry755 opened this issue Dec 13, 2023 · 3 comments

Comments

@ry755
Copy link

ry755 commented Dec 13, 2023

Hi! I am currently attempting to improve the existing window manager and make it more like what one would expect of a typical window manager. However, I quickly realized that actually moving windows around is harder than it initially seemed. include/library/nwindow.h lists prototypes for nw_move() and nw_resize() but a quick search of the rest of the codebase shows that they aren't implemented. I dug through the related code but I'm having trouble understanding how all of the different layers of the graphics stack are connected.

Do you plan on implementing these missing functions? Or if not, could you provide some guidance so I could implement them myself? Thanks!

@dthain
Copy link
Owner

dthain commented Dec 13, 2023

Hello, thanks for your interest, happy to have some new contributions. To get this will require some changes that cut across various kernel objects. Let me see if I can clarify how a few things work:

  • A graphics object in the kernel describes an area on the screen in which drawing operations can be done safely with clipping. An initial root graphics object describes the whole screen, then child graphics objects are created from it using graphics_create to access a subset of that screen.
  • In the kernel, you can draw to a graphics object by calling graphics_line, graphics_rect, etc, or by calling graphics_write with a buffer full of drawing instructions described by gfxstream.h
  • An event_queue object is a buffer of events (mouse button, keypress, etc) to which one can post new events, or read events out.
  • A kernel window object joins together an event_queue and a graphics context into a single object to which one can read events or write graphics in the format expected by graphics_write.
  • syscall_open_window creates a kobject of type KOBJECT_WINDOW containing a window object. So that when you read or write this object, you get either an event stream or write graphics.
  • Finally, the nwindow interface in userspace is a small wrapper around the window object so that you can do the usual things by invoking system calls.

So, if you want to have windows that can move, a couple of things need to happen:

  • Modify the graphics module so that a graphics object can be resized and moved. Basically, this requires updating the object structure and copying a rectangular area on the screen.
  • Extend the window interface to have resize and move methods.
  • Extend the kobject interface to have resize and move methods.
  • Extend the system call interface to have generic object resize and move methods.
  • Finally, extend nwindow in userspace to call those system calls.

Now, note that the userspace manager program isn't really a window manager in the sense that we might understand that term in Linux. It is a very simple program that just invokes N other programs and gives each one a window. If you want to make that more interactive, you could modify it to capture certain keystrokes and translate those into selecting and resizing windows.

Hope that clarifies things.

@ry755
Copy link
Author

ry755 commented Dec 13, 2023

Thank you so much! This clarifies a lot. I'll keep this issue open for now in case I have any other related questions.

@dthain
Copy link
Owner

dthain commented Dec 18, 2023

FYI, I made some recent changes that fix a few compilation issues and kernel crashes that arose in relation to the window manager. You might want to pull the latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants