def test_sizehint_change_applied(hlwm, x11, floating): hlwm.attr.tags.focus.floating = floating # create a client with a geometry that does not match the sizehints # we will set later handle, winid = x11.create_client() old_geometry = Rectangle(x=30, y=40, width=111, height=121) hlwm.attr.clients[winid].floating_geometry = old_geometry if floating: assert hlwm.attr.clients[winid].content_geometry().size( ) == old_geometry.size() # update the size hints: hints = { 'flags': Xutil.PResizeInc, 'width_inc': 5, 'height_inc': 7, } handle.set_wm_normal_hints(hints) x11.sync_with_hlwm() new_geometry = hlwm.attr.clients[winid].floating_geometry() # the new size adheres to the size hints assert new_geometry.width % hints['width_inc'] == 0 assert new_geometry.height % hints['height_inc'] == 0 # the new size changes only as little as necessary assert abs(new_geometry.width - old_geometry.width) <= hints['width_inc'] assert abs(new_geometry.height - old_geometry.height) <= hints['height_inc'] if floating: assert hlwm.attr.clients[winid].content_geometry().size( ) == new_geometry.size()
def test_floating_geometry_and_placement(hlwm, x11, place_center): hlwm.attr.tags.focus.floating = True rule_geo = Rectangle(30, 40, 140, 170) rule = ['floating_geometry=' + rule_geo.to_user_str()] if place_center: rule += ['floatplacement=center'] else: # also add another rule whose floatplacement is then overwritten: hlwm.call('rule floatplacement=center') rule += ['floatplacement=none'] # 'floatplacement' is only applied by 'rule', so no test # for 'apply_tmp_rule' or 'apply_rules' hlwm.call(['rule'] + rule) _, winid = x11.create_client() client_geo = hlwm.attr.clients[winid].floating_geometry() monitor_geo = hlwm.attr.monitors.focus.geometry() assert client_geo.size() == rule_geo.size() if place_center: assert client_geo.center() == monitor_geo.center() else: assert client_geo.topleft() == rule_geo.topleft()