Cleanups as a result of just letting X11::Error exceptions mostly caused by closed windows now being handled at the top level

Some of these may possibly need to be reintroduced, but in most cases
bailing out from handling the current event is the right choice in any
case.
This commit is contained in:
Vidar Hokstad 2024-01-26 07:18:04 +00:00
parent 739da5fdf9
commit 3889d7a5f5
2 changed files with 12 additions and 22 deletions

View file

@ -17,7 +17,7 @@ class Window < X11::Window
@wm = wm
self.desktop = desktop
@hidden = false
@realgeom = get_geometry rescue nil
@realgeom = get_geometry
@floating = floating
# This is a "safety" workaround
@ -37,7 +37,7 @@ class Window < X11::Window
resize_to_geom(@realgeom)
end
(lower if desktop?) rescue nil
lower if desktop?
end
def mapped=(state)
@ -52,8 +52,8 @@ class Window < X11::Window
def hide
return if @hidden
@hidden=true
@realgeom = get_geometry rescue nil
resize_to_geom(@realgeom) if @realgeom
@realgeom = get_geometry
resize_to_geom(@realgeom)
end
def show
@ -129,8 +129,7 @@ class Window < X11::Window
return if special?
rootgeom = @wm.rootgeom
geom = get_geometry rescue nil
return if geom.nil?
geom = get_geometry
if (og = @old_geom) &&
geom.x == 0 && geom.y == 0 &&

23
wm.rb
View file

@ -234,19 +234,15 @@ class WindowManager
def on_button_press(ev)
return if !ev.child
w = window(ev.child)
@attr = w.get_geometry rescue nil
if @attr
set_focus(w.wid)
@start = ev
end
@attr = w.get_geometry
set_focus(w.wid)
@start = ev
end
def on_motion_notify(ev)
# @start.button == 1 -> move
# @start.button == 3 -> resize
if ev.child != @start.child
set_focus(ev.child) rescue nil # FIXME
end
set_focus(ev.child) if ev.child != @start.child
return if !@start&.child || !@attr
xdiff = ev.root_x - @start.root_x;
@ -255,10 +251,7 @@ class WindowManager
w = window(@start.child)
# FIXME: Any other types we don't want to allow moving or resizing
begin
return if w.special?
rescue # FIXME: Why is this here?
end
return if w.special?
if @start.detail == 1 # Move
if w.floating?
@ -397,10 +390,8 @@ class WindowManager
dir = dpy.get_atom_name(dir).downcase.to_sym
if @focus.floating?
# FIXME:
# Move stepwise instead.
g = @focus.get_geometry rescue nil
return if g.nil?
g = @focus.get_geometry
case dir
when :left then @focus.configure(x: g.x - 20)
when :right then @focus.configure(x: g.x + 20)