Skip to content

Commit e157cbb

Browse files
committed
Don't use the Unix adapter if the AT-SPI bus is not available
1 parent 503c42b commit e157cbb

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

bindings/c/examples/sdl/hello_world.c

+18-13
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ void accesskit_sdl_adapter_update(const struct accesskit_sdl_adapter *adapter,
118118
accesskit_macos_queued_events_raise(events);
119119
}
120120
#elif defined(UNIX)
121-
accesskit_unix_adapter_update(adapter->adapter, update);
121+
if (adapter->adapter != NULL)
122+
accesskit_unix_adapter_update(adapter->adapter, update);
122123
#elif defined(_WIN32)
123124
accesskit_windows_queued_events *events =
124125
accesskit_windows_subclassing_adapter_update(adapter->adapter, update);
@@ -140,8 +141,10 @@ void accesskit_sdl_adapter_update_if_active(
140141
accesskit_macos_queued_events_raise(events);
141142
}
142143
#elif defined(UNIX)
143-
accesskit_unix_adapter_update(adapter->adapter,
144-
update_factory(update_factory_userdata));
144+
if (adapter->adapter != NULL) {
145+
accesskit_unix_adapter_update(adapter->adapter,
146+
update_factory(update_factory_userdata));
147+
}
145148
#elif defined(_WIN32)
146149
accesskit_windows_queued_events *events =
147150
accesskit_windows_subclassing_adapter_update_if_active(
@@ -155,16 +158,18 @@ void accesskit_sdl_adapter_update_if_active(
155158
void accesskit_sdl_adapter_update_root_window_bounds(
156159
const struct accesskit_sdl_adapter *adapter, SDL_Window *window) {
157160
#if defined(UNIX)
158-
int x, y, width, height;
159-
SDL_GetWindowPosition(window, &x, &y);
160-
SDL_GetWindowSize(window, &width, &height);
161-
int top, left, bottom, right;
162-
SDL_GetWindowBordersSize(window, &top, &left, &bottom, &right);
163-
accesskit_rect outer_bounds = {x - left, y - top, x + width + right,
164-
y + height + bottom};
165-
accesskit_rect inner_bounds = {x, y, x + width, y + height};
166-
accesskit_unix_adapter_set_root_window_bounds(adapter->adapter, outer_bounds,
167-
inner_bounds);
161+
if (adapter->adapter != NULL) {
162+
int x, y, width, height;
163+
SDL_GetWindowPosition(window, &x, &y);
164+
SDL_GetWindowSize(window, &width, &height);
165+
int top, left, bottom, right;
166+
SDL_GetWindowBordersSize(window, &top, &left, &bottom, &right);
167+
accesskit_rect outer_bounds = {x - left, y - top, x + width + right,
168+
y + height + bottom};
169+
accesskit_rect inner_bounds = {x, y, x + width, y + height};
170+
accesskit_unix_adapter_set_root_window_bounds(adapter->adapter,
171+
outer_bounds, inner_bounds);
172+
}
168173
#endif
169174
}
170175

0 commit comments

Comments
 (0)