✅ Fixes fixed size window creation
This commit is contained in:
parent
a888c234a3
commit
a4b48b60bf
5 changed files with 27 additions and 16 deletions
|
@ -17,7 +17,7 @@ void OnCreateNotify(Aswm* aswm, const XCreateWindowEvent* e) {
|
|||
}
|
||||
|
||||
// The WM must subscribe to property changes, notably to implement the
|
||||
// Extended Window Manager Hints (EWMH) propocol
|
||||
// ICCM and Extended Window Manager Hints (EWMH) propocol
|
||||
XSelectInput(aswm->display, e->window, PropertyChangeMask);
|
||||
|
||||
{
|
||||
|
|
|
@ -144,6 +144,7 @@ void resize_stack(Display* display, Window stack) {
|
|||
for(auto i = 0; i < children_count; i++) {
|
||||
XWindowAttributes child_attributes;
|
||||
XGetWindowAttributes(display, children[i], &child_attributes);
|
||||
aswm_notice("Resize stack to %lu - %i %i", children[i], child_attributes.width, child_attributes.height);
|
||||
if(child_attributes.map_state != IsUnmapped) {
|
||||
if(child_attributes.width > width)
|
||||
width = child_attributes.width;
|
||||
|
@ -168,13 +169,19 @@ void aswm_stack_window(Display* display, Window stack, Window window_to_map, int
|
|||
XWindowAttributes stack_attributes;
|
||||
XGetWindowAttributes(display, stack, &stack_attributes);
|
||||
|
||||
XSetWindowAttributes stacked_attributes;
|
||||
stack_attributes.width = width;
|
||||
stack_attributes.height = height;
|
||||
stack_attributes.win_gravity = CenterGravity;
|
||||
aswm_notice("Stack window %lu with size %i %i", window_to_map, width, height);
|
||||
XSetWindowAttributes window_to_stack_attributes;
|
||||
window_to_stack_attributes.win_gravity = CenterGravity;
|
||||
XChangeWindowAttributes(display, window_to_map,
|
||||
CWWidth | CWHeight | CWWinGravity,
|
||||
&stacked_attributes);
|
||||
CWWinGravity,
|
||||
&window_to_stack_attributes);
|
||||
// Resize window to its fixed size before stacking it
|
||||
XResizeWindow(display, window_to_map, width, height);
|
||||
|
||||
|
||||
XWindowAttributes child_attributes;
|
||||
XGetWindowAttributes(display, window_to_map, &child_attributes);
|
||||
aswm_notice("Map window %lu with size %i %i", window_to_map, child_attributes.width, child_attributes.height);
|
||||
XReparentWindow(display, window_to_map, stack,
|
||||
(stack_attributes.width - width) / 2,
|
||||
(stack_attributes.height - height) / 2
|
||||
|
@ -251,9 +258,6 @@ void aswm_handle_normal_hints(Display* display, Window stack_root, Window window
|
|||
}
|
||||
} else {
|
||||
if(!aswm_is_resizeable(size)) {
|
||||
// Resize window to its fixed size before stacking it
|
||||
XResizeWindow(display, window, size->max_width, size->max_height);
|
||||
|
||||
// XMapWindow does not trigger a MapRequest for the current
|
||||
// client, so we need to call aswm_stack_window directly.
|
||||
// aswm_stack_window automatically triggers the appropriate
|
||||
|
|
|
@ -17,8 +17,8 @@ int main(void) {
|
|||
set_up_test_logger();
|
||||
if(check_xephyr_available()) {
|
||||
RUN_TEST(run_aswm);
|
||||
/*RUN_TEST(create_single_resizeable_top_level_window);*/
|
||||
/*RUN_TEST(create_multiple_resizeable_top_level_window);*/
|
||||
RUN_TEST(create_single_resizeable_top_level_window);
|
||||
RUN_TEST(create_multiple_resizeable_top_level_window);
|
||||
RUN_TEST(create_single_fixed_size_top_level_window);
|
||||
}
|
||||
tear_down_test_logger();
|
||||
|
|
|
@ -9,7 +9,6 @@ void create_single_fixed_size_top_level_window(void) {
|
|||
Window child = XCreateSimpleWindow(test_display, window,
|
||||
0, 0, 25, 30,
|
||||
0, CopyFromParent, red(1).pixel);
|
||||
XMapWindow(test_display, child);
|
||||
|
||||
const int fixed_width = 250;
|
||||
const int fixed_height = 75;
|
||||
|
@ -24,7 +23,16 @@ void create_single_fixed_size_top_level_window(void) {
|
|||
XSetWMNormalHints(test_display, window, normal_size);
|
||||
XFree(normal_size);
|
||||
}
|
||||
|
||||
XMapWindow(test_display, child);
|
||||
XMapWindow(test_display, window);
|
||||
// Even if we called XMapWindow before XSetWindowAttributes, there is NO
|
||||
// guarante that the property.h event handler for WM_NORMAL_HINTS will be
|
||||
// triggered AFTER the map. Indeed, the property event can be handled before
|
||||
// the WM has actually set event handlers on the mapped window. This is not
|
||||
// an issue as long as the map request handler handles the initial
|
||||
// WM_NORMAL_HINTS value. Calling XSetWMNormalHints before XMapWindow should
|
||||
// however ensure that the current test reproduce this situation.
|
||||
|
||||
int visibility = wait_visibility(test_display, window);
|
||||
|
||||
|
@ -52,5 +60,4 @@ void create_single_fixed_size_top_level_window(void) {
|
|||
TEST_ASSERT_EQUAL_INT(30, child_attributes.height);
|
||||
TEST_ASSERT_EQUAL_INT(0, child_attributes.border_width);
|
||||
TEST_ASSERT_EQUAL_INT(IsViewable, child_attributes.map_state);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ simple = "[%c %p] %d(%m-%d %T) %-5V %-8f:%-3L %m%n"
|
|||
|
||||
[rules]
|
||||
|
||||
aswm.NOTICE >stdout; simple
|
||||
aswm.DEBUG >stdout; simple
|
||||
|
|
Loading…
Add table
Reference in a new issue