summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Window.h
AgeCommit message (Collapse)Author
2023-05-15LibGUI: Add Window::constrain_to_desktop() helperthankyouverycool
And a center_within(IntRect const&) overload
2023-04-30LibGUI: Use Variant's built-in equality operator in Window and WidgetAndreas Kling
Now that Variant has operator==(), we don't need to go through all this trouble to compare two Variant values.
2023-04-19LibGUI+Userland: Make Window::*add_menu take name using new stringKarol Kosek
2023-04-18LibGUI: Add Window::on_font_change() hookthankyouverycool
2023-04-15LibGUI: Allow Windows to auto shrinkthankyouverycool
Previously Windows automatically grew to accomodate layout changes when obeying minimum widget size but would not automatically shrink if so desired. Setting auto shrink true now automatically resizes windows to their effective_min_size() every time their minimum size updates. This will be useful for making fixed size windows responsive to layout and font changes in the future.
2023-03-25LibGUI: Make `propagate_shortcuts` handle different level of propagationLucas CHOLLET
First, this patch renames the function `propagate_shortcuts_up_to_application` to `propagate_shortcuts`. Handling those levels, will allow us to differentiate shortcuts at `Window` level and `Application` level. Which will be convenient to handle dialog-specific shortcuts.
2023-02-21LibGUI: Fix const-correctness issuesAndreas Kling
2023-01-17LibGUI+WindowServer: Improve window resizing performanceJelle Raaijmakers
The old `GUI::Window` resizing behavior created a new backing store for each resize event (i.e. every visible window size). This caused a lot of trashing and on my machine, caused up to 25% of CPU time spent in creating new backing stores. The new behavior is a bit more sensible: * If the window size is shrinking, the backing store is already large enough to contain the entire window - so we don't create a new one. * If the window size is growing, as soon as the backing store can no longer contain the window, it is inflated with a large margin (of an arbitrary chosen 64 pixels) in both directions to accommodate some leeway in resizing before an even larger backing store is required. * When the user stops resizing the window, the backing store is resized to the exact dimensions of the window. For me, this brings the CPU time for creating backing stores down to 0%.
2023-01-06LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)Sam Atkins
Rip that bandaid off! This does the following, in one big, awkward jump: - Replace all uses of `set_main_widget<Foo>()` with the `try` version. - Remove `set_main_widget<Foo>()`. - Rename the `try` version to just be `set_main_widget` because it's now the only one. The majority of places that call `set_main_widget<Foo>()` are inside constructors, so this unfortunately gives us a big batch of new `release_value_but_fixme_should_propagate_errors()` calls.
2022-12-07Meta+Userland: Pass Gfx::IntSize by valueMacDue
Just two ints like Gfx::IntPoint.
2022-12-07Meta+Userland: Pass Gfx::IntPoint by valueMacDue
This is just two ints or 8 bytes or the size of the reference on x86_64 or AArch64.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-19LibGUI+WindowServer+Applets+Taskbar: Remove active input conceptsthankyouverycool
and the CaptureInput mode. They are a source of unneeded complexity in WindowServer and have proven prone to regressions, so this patch replaces them with a simple input preemption scheme using Popups. Popup windows now have ergonomics similar to menus: When open, a popup preempts all mouse and key events for the entire window stack; however, they are fragile and will close after WindowServer swallows the first event outside them. This is similar to how combo box windows and popups work in the classic Windows DE and has the added benefit of letting the user click anywhere to dismiss a popup without having to worry about unwanted interactions with other widgets.
2022-11-19LibGUI+WindowServer: Remove InputPreemptor conceptthankyouverycool
This functionality will be superceded by WindowType:Popups
2022-11-19LibGUI+WindowServer: Replace WindowInput{Enter,Leave} Eventsthankyouverycool
with WindowInput{Preempted,Restored} Events and allow Widgets to save the state of their focus preemption. As of now, only Popups will preempt input and trigger these events.
2022-11-19LibGUI+WindowServer: Add WindowType:Autocomplete and helpersthankyouverycool
2022-11-19LibGUI: Allow adding previously constructed menus to Menubarthankyouverycool
2022-11-14LibGUI: Handle Action keyboard shortcuts in Widget keydownZaggy1024
Widgets can now prevent shortcut Actions from being called, which allows text input keydown handlers to override single key shortcuts.
2022-11-02LibGUI+WindowServer: Allow programatically minimizing windowsTimothy Flynn
The backend methods in WindowServer already exist. This just adds the IPC plumbing to connect those methods to GUI::Window.
2022-10-25LibGUI: Remove Window::set_blocks_command_palette()demostanis
Since the logic to open the command palette is now in the form of an action, its keybinding is only bound when the window active. Thus, when a combo box or the emoji input dialog is active, the window isn't, and the command palette doesn't show up, without requiring special checks.
2022-10-13LibGUI+WindowServer: Add Window::set_always_on_top()demostanis
2022-10-11WindowServer+LibGUI: Shrink window edge resize hot-spotsMart G
The hot-spots for resizing a window by dragging its corner are now limited to a small area around the actual corner instead of an area with 1/3rd the length or width of the window. The hot-spots to resize a window while holding a modifier key and the right mouse button are unchanged.
2022-09-09LibGUI: Allow blocking CommandPalette/EmojiInput on a per Window basisthankyouverycool
Instead of having to negate every focusable widget or textbox, let windows override all their widgets. These two Dialogs now block themselves and each other.
2022-09-09LibGUI: CommandPalette: Fix key event capture for actionsfaxe1008
This patch fixes an issue for applications that contain actions without a modifier (e.g. PixelPaint). Previously when pressing any key bound to an action while the CommandPalette was visible the action was forwarded to the parent instead of the CommandPalette.
2022-09-08LibGUI+WindowServer: Notify Windows on input preemptionthankyouverycool
Previously Menus set themselves as active input solely to make sure CaptureInput modals would close, but this is a functional half-truth. Menus don't actually use the active input role; they preempt normal Windows during event handling instead. Now the active input window is notified on preemption and Menus can remain outside the active input concept. This lets us make more granular choices about modal behavior. For now, the only thing clients care about is menu preemption on popup. Fixes windows which close on changes to active input closing on their own context menus.
2022-08-25LibGUI+WindowServer+Apps: Replace Accessory Windowsthankyouverycool
with the CaptureInput WindowMode. This mode will serve the same function as accessories: redirecting input while allowing parent windows to remain active.
2022-08-25LibGUI+WindowServer: Introduce WindowModesthankyouverycool
Previously, Windows only understood blocking modality: Windows were either modal, i.e., in a blocking state, or not. Windows could also be set as Accessories or ToolWindows, attributes which technically applied modes to their parents but were implemented ad hoc. This patch redefines these modal effects as WindowModes and sets up some helpers. This will let us simplify a lot of modal logic in the upcoming patches and make it easier to build new modal effects in the future. Windows can now set 1 of 5 modes before reification: -Modeless: No modal effect; begins a new modal chain -Passive: Window joins its modal chain but has no effect -RenderAbove: Window renders above its parent -CaptureInput: Window captures the active input role from its parent -Blocking: Window blocks all interaction with its modal chain States like fullscreen and tiling are dynamic and don't alter behavior in modal chains, so they aren't included.
2022-08-25LibGUI+WindowServer: Initialize minimum window size to zerothankyouverycool
And remove unnecessary workarounds to the old limit of {50, 50} and the cautious but arbitrary limit of {1, 1} for other WindowTypes. Null rects are already the default when calculating minimum window size and are the least restrictive but valid value. Also returns early during minimum size calculations for frameless windows, and verifies against negative minimum sizes and failure to disable widget min size before setting a minimum window size. Layout automatically overrides this setting each relayout otherwise.
2022-07-04LibGUI: Calculate Window min_size on showFrHun
2022-06-29LibGUI: Add ability to calculate min_size of Window from content widgetFrHun
2022-05-30LibGUI: Search for actions with a Shortcut instead of for KeyEventGeordie Hall
Instead of having widget/window/application create a shortcut from a KeyEvent within their find methods, we'll just pass them a Shortcut so that the "where to search" logic doesn't need to be duplicated for different Shortcut types. It also lets us handle invalid Shortcut rejection at a higher level, with most things letting the caller be responsible for not searching for actions with an invalid shortcut.
2022-04-05WindowServer+LibGUI: Notify windows when their maximized state changesAndreas Kling
Previously, GUI::Window::is_maximized() had to make a synchronous IPC request to WindowServer in order to find out if the window was indeed maximized. This patch removes the need for synchronous IPC by instead pushing the maximization state to clients when it changes. The motivation for this change was that GUI::Statusbar was checking if the containing window was maximized in its resize_event(), causing all windows with a statusbar to block on sync IPC *during* resize. Browser would typically block for ~15 milliseconds here every time on my machine, continuously during live resize.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-02-25Userland: Rename WindowServerConnection=>ConnectionToWindowServerItamar
This was done with CLion's automatic rename feature.
2022-01-31LibGUI: Remove `Window` background colorJelle Raaijmakers
The `m_background_color` field was not used anywhere. Both `Terminal` and the `ColorPicker` widget invoked `set_background_color()` to no avail.
2022-01-30LibGUI: Collect menu and submenu actions for CommandPalettenetworkException
We now not only collect actions that are children of windows but also all actions that are part of a window's menus and submenus :^)
2022-01-26LibGUI: Allow Windows to set a default return key widgetthankyouverycool
The default return key widget takes precendence when dispatching return key events with the exception of focused buttons.
2022-01-09LibGUI+WindowServer: Flash menubar menu when using a keyboard shortcutbugreport0
Briefly flash the menubar menu containing the keyboard shortcut action to give the user immediate visual feedback on their interaction with the system.
2021-11-24LibGUI: Add GUI::Window::try_set_main_widget<T>(...)Andreas Kling
This is a fallible variant of set_main_widget<T>() that returns ErrorOr.
2021-11-24LibGUI: Add GUI::Window::try_add_menu()Andreas Kling
This is a fallible variant of add_menu() that returns ErrorOr.
2021-10-31LibGUI: Support using a bitmap as override cursorMarco Cutecchia
2021-10-23LibGUI: Add Widget::repaint() to force an immediate repaintAndreas Kling
In most situations, Widget::update() is preferable, since that allows us to coalesce repaints and avoid redundant work, reducing system load. However, there are some cases where you really want a paint to happen right away, to make sure that the user has a chance to see a short-lived visual state.
2021-10-21LibGUI+WindowServer: Add option to hide a widow's close buttonTimothy Flynn
This allows windows to be closed only programatically, and not from e.g. the user clicking the X button on the window frame.
2021-10-17LibGUI: Remember the maximized value if a window hasn't been created yetKarol Kosek
d0fb511d75762e9d97fa80a01585381843b90a0a set the maximized window value in the File Manager before a window was created, which resulted in crash everytime you tried to open the program that was closed while it was maximized. ugh Here we do more-or-less what GUI::Window::set_rect() does, except we don't add it to the WindowServer::create_window() IPC call. That's because the Window Server knows nothing about menus at this point and just assumes they don't need to be visible. So if we try to maximize the window then, it could be slightly taller and a titlebar could be hidden. So even though it looks how it looks like, it does work and it doesn't show in the startup size, as described in the mentioned commit (the call is put a few lines before the initial update()). :^)
2021-09-08LibGUI+WindowServer: Remove now-obsolete cursor tracking featureBen Wiederhake
This feature was problematic for several reasons: - Tracking *all* the user activity seems like a privacy nightmare. - LibGUI actually only supports one globally tracking widget per window, even if no window is necessary, or if multiple callbacks are desired. - Widgets can easily get confused whether an event is actually directed at it, or is actually just the result of global tracking. The third item caused an issue where right-clicking CatDog opened two context menus instead of one.
2021-08-31WindowServer: Add message to notify clients of applet area resizeJoe Bentley
Applets and windows would like to be able to know when the applet area has been resized. For example, this happens asynchronously after an applet has been resized, so we cannot then rely on the applet area position synchronously after resizing. This adds a new message applet_area_rect_changed and associated Event AppletAreaRectChange, and the appropriate virtual functions.
2021-08-05LibGUI: Add on_active_window_change function object to the Window classKarol Kosek
2021-08-02LibGUI, WindowServer: Greatly simplify menubar logicsin-ack
Currently, any number of menubars can be plugged in and out of a window. This is unnecessary complexity, since we only need one menubar on a window. This commit removes most of the logic for dynamically attaching and detaching menubars and makes one menubar always available. The menubar is only considered existent if it has at least a single menu in it (in other words, an empty menubar will not be shown). This commit additionally fixes a bug wherein menus added after a menubar has been attached would not have their rects properly setup, and would therefore appear glitched out on the top left corner of the menubar.
2021-07-26LibGUI: Add virtual handlers for WindowEntered and WindowLeft eventssin-ack
These can be useful if an application wants to react to the cursor entering the window at any point, rather than just on a widget.
2021-07-21Userland: Add GUI::Window::add_menu() and use it everywhereAndreas Kling
Applications previously had to create a GUI::Menubar object, add menus to it, and then call GUI::Window::set_menubar(). This patch introduces GUI::Window::add_menu() which creates the menubar automatically and adds items to it. Application code becomes slightly simpler as a result. :^)