Commit Graph

85 Commits

Author SHA1 Message Date
Tom
87c1b1a25d WindowServer: Use active shadow for highlighted window
If we're switching through windows we should also use the active
shadow for the highlighted window.
2021-03-03 08:20:11 +01:00
Tom
c57d719d62 WindowServer: Prepare dirty rects if only the frame was invalidated 2021-03-03 08:20:11 +01:00
AnotherTest
857cdee0d0 AK: Make dbgln_if() avoid evaluating the arguments when disabled
Naturally, this makes the `enabled` flag on dbgln() obsolete.
2021-02-24 13:07:28 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Tom
b4c0314f1d WindowServer: Don't close context menus when hovering over menu bar 2021-02-22 09:09:26 +01:00
Tom
35363a972a WindowServer: Reset menu position when opened by the menu bar
Also, only mark the menu bar item as opened if a menu was actually
opened through the menu bar.

These changes allow a menu to be used both in the menu bar as well
as a context menu.

Fixes #5469
2021-02-22 09:09:26 +01:00
Tom
2d29bfc89e WindowServer: Re-evaluate the mouse cursor when alpha hit-testing
A window repaint may change the alpha value, resulting in a different
hit test outcome. In those cases, re-evaluate the cursor hit testing
after a window was painted, and update the cursor if needed.
2021-02-21 22:34:00 +01:00
Tom
1c31bcb24e WindowServer: Allow changing frameless state after a window is created 2021-02-21 10:33:28 +01:00
Tom
101c6b01ed WindowServer: Improve small tooltips/windows shadows a bit
This fixes some artifacts with very small tooltip windows.
2021-02-20 22:28:11 +01:00
Sahan Fernando
e920c74cae WindowServer: Restore cursor when marking window as responsive 2021-02-19 20:30:25 +01:00
Tom
06ee8c5aa8 WindowServer: Ignore other button presses while moving/resizing windows
Fixes #5334
2021-02-18 07:45:44 +01:00
Tom
6af4d35e8e WindowServer: Apply the backing bitmap's scale when alpha hit-testing
Fixes #5390
2021-02-18 07:45:22 +01:00
Andreas Kling
c4438d6fd4 WindowServer: Unbreak "pick new active window" algorithm
We lost the ability to pick a suitable new active window when I added
the support for tool windows.
2021-02-17 16:52:08 +01:00
Andreas Kling
11c8596ad3 WindowServer+LibGUI+LibGfx: Add WindowType::ToolWindow
Tool windows are secondary windows with a smaller title bar. The sit on
the layer above normal windows, and cannot be minimized.

These are intended for complex yet non-modal interactions with the
content of a primary window, such as find/replace windows, property
windows, etc.
2021-02-16 16:26:29 +01:00
Nick Vella
15c1f7a40d WindowServer, LibGUI: Variable minimum window sizes
Minimum window size can now be customised and set at runtime via the
SetWindowMinimumSize WindowServer message and the set_minimum_size
LibGUI::Window method. The default minimum size remains at 50x50.

Some behind-the-scenes mechanics had to be added to LibGUI::Window to
ensure that the minimum size is remembered if set before the window is
shown. WindowServer sends a resize event to the client if it requests a
size on create that's smaller than it's minimum size.
2021-02-16 15:46:03 +01:00
Tom
d590e0c946 WindowServer: Add support for alpha channel based hit testing
This enables implementing non-rectangular window shapes, including
non-rectangular window frames.
2021-02-15 23:07:49 +01:00
Jean-Baptiste Boric
e616cb35ba WindowManager: Fix default menu item on key down
This fixes the key down behavior on Terminal's Edit menu, which tried
to hover the disabled menu item Copy if there was nothing selected.
2021-02-15 19:37:14 +01:00
Jean-Baptiste Boric
f8cb068354 WindowManager: Select top-level menus with left/right keys 2021-02-15 19:37:14 +01:00
Jean-Baptiste Boric
7ee6c66ee9 WindowManager: Make the Logo key open the system menu 2021-02-15 19:37:14 +01:00
Tom
be48a89b35 WindowServer: Fix double click handling while using cursor tracking
We need to first deliver the mouse event and possibly the double click
event and record these facts. Then, we need to iterate all global
tracking listeners and deliver the mouse event (but not the double
click event) to any such listener, unless they already had these
events delivered.

Fixes #4703
2021-02-15 11:03:49 +01:00
Tom
0138f13bfe WindowServer: Improvements to support alpha channel in window frames
This fixes some issues handling the alpha channel that may be present
in rendered window frames.

Fixes #5303
2021-02-13 00:39:33 +01:00
Tom
7e06afb822 WindowServer: Recompute occlusions when changing window's alpha channel
Fixes #4845
2021-02-12 08:57:42 +01:00
Tom
cf1c159ed5 WindowServer: Allow different shadows for active/inactive windows
Also allow specifying different shadows for the task and menu bar.
2021-02-11 23:36:11 +01:00
Linus Groh
0304ab3e67 WindowServer: Fix compositing of fullscreen window
I honestly don't know the internals of all this and what exactly is
going on, but this fixes compositing of the fullscreen window. By trial
and error I found that specifically m_invalidated_all needs to be set to
false, so it's probably different behaviour in prepare_dirty_rects(),
which depends on that...
Either way, the code composing all windows in non-fullscreen mode calls
Window::clear_dirty_rects() for each, so not doing that for the fullscreen
window as well seems like an oversight.

Fixes #4810.
2021-02-11 13:12:17 +01:00
Tom
e1333724ea WindowServer: Blit backing bitmap with transparency for hung windows
We should respect the opacity of the window when painting the window
content of a hung application.
2021-02-11 13:11:57 +01:00
Tom
dd0833107f WindowServer: Fix clearing area not covered by backing bitmap
We only cleared the area not covered by the backing bitmap if a
rendering rectangle intersected with the backing bitmap. But because
we are potentially calling the render function many times we need
to always clear the area not covered by the backing bitmap, whether
it intersects or not.

Fixes #5291
2021-02-11 13:11:57 +01:00
Tom
f8d65e57ba WindowServer: Don't re-render the window frame when not needed
Merely moving a window shouldn't require re-rendering the window
frame anymore now that we cache the rendered frame in bitmaps. This
reduces CPU usage significantly when moving windows.
2021-02-10 23:03:22 +01:00
Tom
a807d92a32 WindowServer: Fix switching between shadows and no shadows with themes
We weren't properly handling switching between having a shadow and
not having a shadow when switching themes. This allows an empty string
in the theme configuration for a shadow path, meaning no shadow should
be rendered.
2021-02-10 09:12:49 +01:00
Tom
5d4c4bd372 WindowServer: Occlusion calculation fixes
We didn't properly determine whether a window was fully covered, which
caused some artifacts in certain cases.

Fixes #5283
2021-02-10 09:12:49 +01:00
Tom
964894dee6 WindowServer: Allow specifying different shadows for menus and tooltips
Also update the Redmond 2000 theme to drop shadows more Redmond-like.
2021-02-09 22:27:14 +01:00
Camisul
8c220dee03 WindowServer: Vertically maximize window
Button now can handle middle and right clicks.
Added 2 new handlers in button class: on_right_click for Right mouse
button and on_middle_click for middle mouse button.

Added functionality to vertically maximize window with middle mouse
click on the maximize window button.

Also added a way to vertically maximize window by resizing window
height-wise lower than the maximum window height.
2021-02-09 21:36:11 +01:00
Tom
e1ee59ac9d WindowServer: Recompute occlusions and re-render shadows on theme change
Since theme changes may change geometrics, which are also affected by
window shadows, we need to recompute occlusions as well as re-render
window frames.
2021-02-09 21:33:54 +01:00
Tom
db0149056f WindowServer: Don't render shadow for frameless windows
Fixes CatDog rendering odd square shadow.
2021-02-09 19:18:00 +01:00
Tom
3d374954eb WindowServer: Try harder to avoid re-rendering window shadow
We only really need to re-render the simple window shadow when
the size of the frame changes. So, for all other cases only re-render
the window frame without rendering the shadow.
2021-02-09 18:47:43 +01:00
Tom
0ce4b9d7db WindowServer: Implement simple window shadows
This implements simple window shadows around most windows, including
tooltips. Because this method uses a bitmap for the shadow bits,
it is limited to rectangular window frames. For non-rectangular
window frames we'll need to implement a more sophisticated algorithm.
2021-02-09 18:47:43 +01:00
Tom
15a1d9aa94 WindowServer: Cache rendered window frame in bitmap
This only renders the window frame once until the size of the window
changes, or some other event requires re-rendering. It is rendered
to a temporary bitmap, and then the top and bottom part is stored
in one bitmap as well as the left and right part. This also adds
an opacity setting, allowing it to be rendered with a different
opacity.

This makes it easier to enhance window themes and allows using
arbitrary bitmaps with e.g. alpha channels for e.g. shadows.
2021-02-08 19:02:04 +01:00
Tom
8ff34f96b6 WindowServer: Calculate transparent frame occlusions
If a window frame has transparency, include these areas in the
transparency rendering area so that we can render them flicker-free.
2021-02-08 19:02:04 +01:00
AnotherTest
09a43969ba Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
Ben Wiederhake
7961e09c29 Everywhere: Add semantically-missing includes
For example, FindInFilesWidget.h mentions GUI::TableView, but did not include
it. On the other hand, all source files that include FindInFilesWidget.h
also include TableView.h, so the issue is only cosmetical.
2021-02-08 18:03:57 +01:00
DragonAlex98
885974fc3c
WindowServer: Don't close menu when clicking on item with submenu (#5239)
When clicking on a menu item with a submenu, don't close the menu.
2021-02-07 12:28:42 +01:00
Andreas Kling
1ce03f4f34 LibIPC: Stop sending client ID to clients
The client ID is not useful to normal clients anymore, so stop telling
everyone what their ID is.
2021-02-01 11:32:00 +01:00
Andreas Kling
a5bbe3280d LibGUI+WindowServer: Don't use a WM IPC to initiate own window resize
The WM_* IPC messages are intended for "outsider" window management,
not for a client's own windows. Make a separate StartWindowResize
message for this.

This was the only reason that every IPC client had to know its server
side client ID.
2021-02-01 11:23:54 +01:00
etaIneLp
e625ae1130 WindowManager: Restore a window's geometry when untiling it
Specifically, when untiling it using the Super-{Left,Right} shortcuts

Fixes #5182
2021-01-30 22:59:16 +01:00
Ben Wiederhake
0558c74e30 WindowServer: Constrain geometry label on move/resize to desktop
Fixes #5063.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
cf586311a6 WindowServer: Split double-duty Window::normalize_rect()
This commit:
- merges the two(!) places that defined independently the minimum size of a window.
- splits Window::normalize_rect(), which was originally just a function to apply
  the minimum size requirement, and has taken on the additional job of nudging
  windows back onto the desktop.

This inadvertantly fixes a crash that happens when a malicious program creates a
window of size (0, 0). Now, a window at [0,0 50x50] is created instead.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
79f534ef12 WindowServer: Allow superdrags to hide the titlebar
Fixes #5105.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
e200824125 WindowServer: Count titlebar towards visible/grabbable area
This had lead to some surprising asymmetry at the bottom of the screen.
2021-01-29 22:49:12 +01:00
Ben Wiederhake
3fd5aec187 WindowServer: Properly determine where a window may be
This also fixes weird behavior of WindowManager::desktop_rect().
None of the callers seem to ever expect an empty Rect, so return a non-empty Rect.
2021-01-29 22:49:12 +01:00
Linus Groh
ed703b461b WindowServer: Fix client unresponsiveness detection
This broke in add01b3, where Core::Timer::create_single_shot() was
changed to create a stopped timer. Fix it by actually starting the timer
right away ourselves.

Fixes #5111.
2021-01-25 22:31:22 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00