To be clear, my problem is not about the technical implementation in terms of how the system communicates with the application, but is rather an user interface design issue (determining what, exactly, should constitute a valid clipboard access command).
What sort of security architecture(s) does your OS use overall, if any, and does any part of it allow configurable policy? In particular, have you considered a capability-based architecture (which would simply make clipboard access a capability which could be passed to a process and possibly rescinded by the system later - basically, a more general version of the token-passing option bzt mentioned)?
Each process has a set of handles which contain an object pointer and a 32 bit access mask, whose meaning depends on the type of object. I am also planning to implement indirect handles, such that when placed in the handle table, will be automatically followed when accessed, but not when duplicated, thereby providing a revocation mechanism. There is no concept of ACLs and no global namespace for applications to access. There will be some sort of mechanism for storing permanent policies, but the details are not decided. A policy for running a program will presumably include a set of paths (relative to a set of paths provided by the invoker) with access masks which can be used to access devices, directories or files, as well as various other privileges. Of course, one could use this to disable clipboard access entirely, but that should be a last resort.
How does your OS expose interrupts and/or system messages to the applications?
UI threads receive all their input from an input queue. Each window is associated with a particular input queue. The application receives a message if a message has been posted to the queue or a window needs to be updated. Messages can contain an object pointer, which when retrieved by an user mode thread is turned into a handle. Another function, which is in turn called to handle a message, constructs an object that wraps the passed handle and invokes the target window's message handler. Mouse input is only passed for the client area of a window. The title bar, borders and menu bar are considered part of the frame, and are handled by the system. Popup menus are system windows, associated with the same queue as the owning window. Messages directed at system windows are handled automatically if found when an user mode thread wants a message. At some point, this will probably be extended to allow for messages directed at other things besides windows.
Is your GUI in userspace, or part of the kernel, or some combination of those? Is there a separation of concerns (as outlined in Graphics stack) and how is it organized? Are their separate widget library, window manager, and desktop environment components
The window manager is part of the kernel. Controls are currently implemented by having the window's message handler subdivide the window into subviews and passing input to the appropriate target, without the system's involvement. An abstraction is provided called a "view", which can represent a window or a subview, and has an associated handler. Standard controls can be employed by user mode applications as well as the system, and the code then runs in user mode or kernel mode, respectively. In the future, I intend to implement child windows too. The desktop environment (what little there is of it) is currently part of the kernel.
Does the system have a single universal clipboard, or does it allow applications to spawn local clipboards separate from the system-wide one? If the latter, is their a way to pass clipped items from a local clipboard to the global one, and how would you specify that?
There is only a single global clipboard (per logon session). No standard mechanism is currently planned for having application clipboards. If only needed in order to avoid unnecessary copying of data, one could have the system automatically request the data from the application when the user tries to paste it into another application, thus providing a seamless experience for the user. If an application implements its own type of clipboard-like feature, it would need to implement a method for selecting the internal clipboard as a source or destination for operations. An alternative method of initiating clipboard transfers would be via a drag and drop interface. In this case, a system-defined area on the screen could serve as the drag and drop source or target corresponding to the clipboard, and one could even allow for additional clipboard slots in this way.
Have you considered a more general editing history facility (something like a kill ring or an edit stack) instead of a simple clipboard? If you have, how would you expose the items not at the top (presumably, the familiar CUA operations would be LIFO by default, but you could allow the 'stack' to be re-arranged or bypassed in some way separate from those)? This is common for image editors like Photoshop or GIMP, but few user environments support it system-wide.
I haven't spent much time thinking about the details, but if we have a set of stack locations represented by subsections of the system screen area, one could rearrange them by simply dragging them. It's definitely on the to-do list.
Anyway, after having thought about it for a bit, here is what I am currently leaning towards for the original problem:
- Reserve a key on the keyboard (for example, the Windows key or the Menu key) such that the application will not receive input events for this key or any key combination involving this key. Instead, such key combinations will solely be used to activate menu commands or other special functions, such as clipboard operations.
- Clipboard operations can be activated by standard shortcut key combinations, possibly involving additional shift keys, which will be passed to the application. They can also be activated by selecting special menu commands whose text will always begin with the word "Cut", "Copy" or "Paste".
- If a clipboard operation key shortcut is entered or a clipboard command is selected on the menu, a clipboard handle will be passed in the command message. If a Paste operation is initiated, any previous write access is revoked.
- When the clipboard is written, any previous read access is revoked.
- Clicking inside a window, dragging the cursor inside a window belonging to another application and releasing it will allow the first application to generate a block of data which will then be transferred to the second application, if support is indicated by the applications.