feat(#2) Initialize input focus to last window
This commit is contained in:
parent
9416ea8189
commit
ca7d3b0fe3
5 changed files with 40 additions and 0 deletions
|
|
@ -26,6 +26,8 @@ void OnMapRequest(Aswm* aswm, const XMapRequestEvent* e) {
|
|||
if(!stacked)
|
||||
aswm_tile_window(e->display, aswm->current_desktop.tile_root, e->window);
|
||||
|
||||
XSetInputFocus(e->display, e->window, RevertToParent, CurrentTime);
|
||||
|
||||
aswm_info("Map tree:\n");
|
||||
aswm_log_tree(aswm_info, aswm, DefaultRootWindow(aswm->display), 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ add_executable(test_aswm
|
|||
aswm/create_windows/multiple_resizeable.c
|
||||
aswm/create_windows/single_fixed_size.c
|
||||
aswm/property/fix_size.c
|
||||
aswm/input_focus/init.c
|
||||
)
|
||||
target_include_directories(test_aswm PUBLIC ${unity_SOURCE_DIR}/src)
|
||||
target_link_libraries(test_aswm libaswm unity)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../test_set_up.h"
|
||||
#include "create_windows.h"
|
||||
#include "property.h"
|
||||
#include "input_focus.h"
|
||||
|
||||
void run_aswm(void) {
|
||||
int stat_loc;
|
||||
|
|
@ -22,6 +23,7 @@ int main(void) {
|
|||
RUN_TEST(create_multiple_resizeable_top_level_window);
|
||||
RUN_TEST(create_single_fixed_size_top_level_window);
|
||||
RUN_TEST(fix_size_of_an_existing_single_top_level_window);
|
||||
RUN_TEST(init_input_focus);
|
||||
}
|
||||
tear_down_test_logger();
|
||||
return UNITY_END();
|
||||
|
|
|
|||
6
test/aswm/input_focus.h
Normal file
6
test/aswm/input_focus.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef TEST_ASWM_INPUT_FOCUS
|
||||
#define TEST_ASWM_INPUT_FOCUS
|
||||
|
||||
void init_input_focus(void);
|
||||
|
||||
#endif
|
||||
29
test/aswm/input_focus/init.c
Normal file
29
test/aswm/input_focus/init.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "../../test_set_up.h"
|
||||
#include "../../utils.h"
|
||||
|
||||
void init_input_focus() {
|
||||
const int N = 3;
|
||||
Window windows[N];
|
||||
Window children[N];
|
||||
|
||||
for(auto i = 0; i < N; i++) {
|
||||
windows[i] = XCreateSimpleWindow(test_display, test_root,
|
||||
10 /*x*/, 10 /*y*/, 128 /*w*/, 128 /*h*/,
|
||||
0 /*TODO: border width*/, CopyFromParent /*depth*/, blue(((float) i+1)/N).pixel /* background */);
|
||||
// The top level windows might have children. Those must **not** be
|
||||
// altered by the Window Manager
|
||||
children[i] = XCreateSimpleWindow(test_display, windows[i],
|
||||
0, 0, 25, 30,
|
||||
0, CopyFromParent, red(1).pixel);
|
||||
XMapWindow(test_display, children[i]);
|
||||
XMapWindow(test_display, windows[i]);
|
||||
|
||||
Window input_focus;
|
||||
int revert_to;
|
||||
wait_visibility(test_display, windows[i]);
|
||||
|
||||
XGetInputFocus(test_display, &input_focus, &revert_to);
|
||||
|
||||
TEST_ASSERT_EQUAL(input_focus, windows[i]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue