Skip to content

Commit 739da5f

Browse files
committed
Slight cleanup of error handling based on improvement to pure-x11.
1 parent 7dcd5da commit 739da5f

File tree

3 files changed

+50
-50
lines changed

3 files changed

+50
-50
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
source "https://rubygems.org"
44

5-
gem "pure-x11"
5+
gem "pure-x11", ">=0.0.9"
6+

rubywm.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@
5757
end
5858

5959
p ev
60-
d.(ev.class, ev)
60+
begin
61+
d.(ev.class, ev)
62+
rescue X11::Error => e
63+
pp e
64+
end
6165
end

wm.rb

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -115,56 +115,51 @@ def adopt(wid, desktop=nil)
115115
w = @windows[wid] # To avoid infinite recursion, this *must not* use #window
116116
return w if w
117117
w = Window.new(self, wid)
118-
begin
119-
# FIXME: At least some of these ought to "adopted" but set as
120-
# floating/non-layout so they stay on a single desktop.
121-
#
122-
if w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_POPUP) ||
123-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_NOTIFICATION) ||
124-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_POPUP_MENU) ||
125-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_MENU) ||
126-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_DOCK) ||
127-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_TOOLTIP) ||
128-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_DIALOG) ||
129-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_SPLASH) ||
130-
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_UTILITY)
131-
w.floating = true
132-
w.stack
133-
return w
134-
end
135-
if w.desktop?
136-
w.floating = true
137-
end
138-
attr = w.get_window_attributes
139-
return w if attr.wclass == 2 # InputOnly
140-
return w if attr.override_redirect
141-
w.mapped = attr.map_state != 0
142-
geom = w.get_geometry
143-
return w if geom.is_a?(X11::Form::Error) || geom.width < 2 || geom.height < 2
144-
@windows[wid] = w
145-
146-
wms = w.get_property(:_NET_WM_STATE, :atom)&.value
147-
if wms == dpy.atom(:_NET_WM_STATE_ABOVE)
148-
# This seems like it's probably not a good idea.
149-
return w
150-
end
151118

152-
w.set_border(@border_normal)
153-
154-
desktop = dpy.get_property(wid, :_NET_WM_DESKTOP, :cardinal)&.value
155-
desktop ||= current_desktop_id
156-
move_to_desktop(wid, desktop)
157-
w.select_input(
158-
X11::Form::FocusChangeMask |
159-
X11::Form::PropertyChangeMask |
160-
X11::Form::EnterWindowMask |
161-
X11::Form::LeaveWindowMask
162-
)
163-
rescue Exception => e
164-
p [:ZZZZZZZZZZZZZZZZZZZZZZZZZADOPT_FAILED, e]
165-
# Failure here most likely reflects a window that has "disappeared".
166-
# We should handle that better, but for now this is fine
119+
# FIXME: At least some of these ought to "adopted" but set as
120+
# floating/non-layout so they stay on a single desktop.
121+
#
122+
if w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_POPUP) ||
123+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_NOTIFICATION) ||
124+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_POPUP_MENU) ||
125+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_MENU) ||
126+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_DOCK) ||
127+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_TOOLTIP) ||
128+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_DIALOG) ||
129+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_SPLASH) ||
130+
w.type == dpy.atom(:_NET_WM_WINDOW_TYPE_UTILITY)
131+
w.floating = true
132+
w.stack
133+
return w
167134
end
135+
if w.desktop?
136+
w.floating = true
137+
end
138+
attr = w.get_window_attributes
139+
return w if attr.wclass == 2 # InputOnly
140+
return w if attr.override_redirect
141+
w.mapped = attr.map_state != 0
142+
geom = w.get_geometry
143+
return w if geom.width < 2 || geom.height < 2
144+
@windows[wid] = w
145+
146+
wms = w.get_property(:_NET_WM_STATE, :atom)&.value
147+
if wms == dpy.atom(:_NET_WM_STATE_ABOVE)
148+
# This seems like it's probably not a good idea.
149+
return w
150+
end
151+
152+
w.set_border(@border_normal)
153+
154+
desktop = dpy.get_property(wid, :_NET_WM_DESKTOP, :cardinal)&.value
155+
desktop ||= current_desktop_id
156+
move_to_desktop(wid, desktop)
157+
w.select_input(
158+
X11::Form::FocusChangeMask |
159+
X11::Form::PropertyChangeMask |
160+
X11::Form::EnterWindowMask |
161+
X11::Form::LeaveWindowMask
162+
)
168163
update_client_list
169164
return w
170165
end

0 commit comments

Comments
 (0)