diff --git a/digesting_libdecor.c b/digesting_libdecor.c index 15fc5f6..0689d08 100755 --- a/digesting_libdecor.c +++ b/digesting_libdecor.c @@ -432,7 +432,6 @@ int main(){ LIBDECOR_WM_CAPABILITIES_FULLSCREEN | LIBDECOR_WM_CAPABILITIES_MINIMIZE); - wl_list_insert(&ctx.visible_frame_list, &ctx.frame->gtk_link); ctx.frame->visible = true; set_capabilities(ctx.frame, (LIBDECOR_ACTION_MOVE | @@ -441,17 +440,17 @@ int main(){ LIBDECOR_ACTION_FULLSCREEN | LIBDECOR_ACTION_CLOSE)); - ctx.frame->xdg_surface = xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, ctx.wl_surface); - xdg_surface_add_listener(ctx.frame->xdg_surface, &xdg_surface_listener, ctx.frame); + ctx.xdg_surface = xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, ctx.wl_surface); + xdg_surface_add_listener(ctx.xdg_surface, &xdg_surface_listener, ctx.frame); - ctx.frame->xdg_toplevel = xdg_surface_get_toplevel(ctx.frame->xdg_surface); - xdg_toplevel_add_listener(ctx.frame->xdg_toplevel, &xdg_toplevel_listener, ctx.frame); + ctx.xdg_toplevel = xdg_surface_get_toplevel(ctx.xdg_surface); + xdg_toplevel_add_listener(ctx.xdg_toplevel, &xdg_toplevel_listener, ctx.frame); ctx.frame->decoration_mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; - ctx.frame->toplevel_decoration = NULL; + ctx.toplevel_decoration = 0; if (ctx.decoration_manager != 0){ - ctx.frame->toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(ctx.decoration_manager, ctx.frame->xdg_toplevel); - zxdg_toplevel_decoration_v1_add_listener(ctx.frame->toplevel_decoration, &xdg_toplevel_decoration_listener, ctx.frame); + ctx.toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(ctx.decoration_manager, ctx.xdg_toplevel); + zxdg_toplevel_decoration_v1_add_listener(ctx.toplevel_decoration, &xdg_toplevel_decoration_listener, ctx.frame); } } @@ -692,25 +691,25 @@ frame_get_window_size_for(struct libdecor_frame *frame, static void frame_set_window_geometry(struct libdecor_frame *frame, - int32_t content_width, int32_t content_height) -{ + int32_t content_width, int32_t content_height){ int x, y, width, height; int left, right, top, bottom; if (frame_has_visible_client_side_decoration(frame) && - libdecor_plugin_gtk_frame_get_border_size(frame, NULL, &left, &right, &top, &bottom)) { + libdecor_plugin_gtk_frame_get_border_size(frame, NULL, &left, &right, &top, &bottom)){ x = -left; y = -top; width = content_width + left + right; height = content_height + top + bottom; - } else { + } + else{ x = 0; y = 0; width = content_width; height = content_height; } - xdg_surface_set_window_geometry(frame->xdg_surface, x, y, width, height); + xdg_surface_set_window_geometry(ctx.xdg_surface, x, y, width, height); } bool @@ -970,18 +969,16 @@ xdg_toplevel_decoration_listener = { void libdecor_frame_unref(struct libdecor_frame *frame){ - if (ctx.decoration_manager && frame->toplevel_decoration){ - zxdg_toplevel_decoration_v1_destroy(frame->toplevel_decoration); - frame->toplevel_decoration = NULL; + if (ctx.decoration_manager != 0 && ctx.toplevel_decoration != 0){ + zxdg_toplevel_decoration_v1_destroy(ctx.toplevel_decoration); + ctx.toplevel_decoration = 0; } - wl_list_remove(&frame->frame_link); - - if (frame->xdg_toplevel){ - xdg_toplevel_destroy(frame->xdg_toplevel); + if (ctx.xdg_toplevel != 0){ + xdg_toplevel_destroy(ctx.xdg_toplevel); } - if (frame->xdg_surface != 0){ - xdg_surface_destroy(frame->xdg_surface); + if (ctx.xdg_surface != 0){ + xdg_surface_destroy(ctx.xdg_surface); } libdecor_plugin_gtk_frame_free(frame); @@ -1002,33 +999,32 @@ libdecor_frame_set_visibility(struct libdecor_frame *frame, bool visible){ * * See also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/17 */ - if (ctx.decoration_manager && - frame->toplevel_decoration && - frame->has_decoration_mode && + if (ctx.decoration_manager != 0 && + ctx.toplevel_decoration != 0 && + frame->has_decoration_mode != 0 && frame->decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) { - zxdg_toplevel_decoration_v1_set_mode(frame->toplevel_decoration, + zxdg_toplevel_decoration_v1_set_mode(ctx.toplevel_decoration, frame->visible ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE); } - if (frame->frame_content_width <= 0 || - frame->frame_content_height <= 0) - return; - - /* enable/disable decorations that are managed by a plugin */ - if (frame_has_visible_client_side_decoration(frame)){ - /* show client-side decorations */ - libdecor_plugin_gtk_frame_commit(frame, NULL, NULL); + if (frame->frame_content_width > 0 && + frame->frame_content_height > 0){ + /* enable/disable decorations that are managed by a plugin */ + if (frame_has_visible_client_side_decoration(frame)){ + /* show client-side decorations */ + libdecor_plugin_gtk_frame_commit(frame, NULL, NULL); + } + else{ + /* destroy client-side decorations */ + libdecor_plugin_gtk_frame_free(frame); + } + + frame_set_window_geometry(frame, frame->frame_content_width, frame->frame_content_height); + + wl_surface_commit(ctx.wl_surface); } - else{ - /* destroy client-side decorations */ - libdecor_plugin_gtk_frame_free(frame); - } - - frame_set_window_geometry(frame, frame->frame_content_width, frame->frame_content_height); - - wl_surface_commit(ctx.wl_surface); } void @@ -1036,8 +1032,8 @@ libdecor_frame_set_title(struct libdecor_frame *frame, const char *title){ if (!STREQL(frame->title, title)){ free(frame->title); frame->title = strdup(title); - if (frame->xdg_toplevel != 0){ - xdg_toplevel_set_title(frame->xdg_toplevel, title); + if (ctx.xdg_toplevel != 0){ + xdg_toplevel_set_title(ctx.xdg_toplevel, title); if (GTK_IS_WIDGET(frame->header)){ draw_decoration(frame); wl_surface_commit(ctx.wl_surface); @@ -1051,8 +1047,8 @@ libdecor_frame_set_app_id(struct libdecor_frame *frame, const char *app_id){ free(frame->app_id); frame->app_id = strdup(app_id); - if (frame->xdg_toplevel != 0){ - xdg_toplevel_set_app_id(frame->xdg_toplevel, app_id); + if (ctx.xdg_toplevel != 0){ + xdg_toplevel_set_app_id(ctx.xdg_toplevel, app_id); } } @@ -1102,20 +1098,14 @@ libdecor_frame_popup_ungrab(struct libdecor_frame *frame, const char *seat_name) } void -libdecor_frame_show_window_menu(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial, - int x, int y){ - if (!frame->xdg_toplevel) { - fprintf(stderr, "Can't show window menu before being mapped\n"); - return; +libdecor_frame_show_window_menu(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial, int x, int y){ + if (ctx.xdg_toplevel != 0){ + xdg_toplevel_show_window_menu(ctx.xdg_toplevel, wl_seat, serial, x, y); } - xdg_toplevel_show_window_menu(frame->xdg_toplevel, wl_seat, serial, x, y); } void -libdecor_frame_translate_coordinate(struct libdecor_frame *frame, - int content_x, int content_y, - int *frame_x, int *frame_y) -{ +libdecor_frame_translate_coordinate(struct libdecor_frame *frame, int content_x, int content_y, int *frame_x, int *frame_y){ *frame_x = content_x; *frame_y = content_y; @@ -1159,25 +1149,22 @@ libdecor_frame_resize(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial, enum libdecor_resize_edge edge){ enum xdg_toplevel_resize_edge xdg_edge; xdg_edge = edge_to_xdg_edge(edge); - xdg_toplevel_resize(frame->xdg_toplevel, wl_seat, serial, xdg_edge); + xdg_toplevel_resize(ctx.xdg_toplevel, wl_seat, serial, xdg_edge); } void libdecor_frame_move(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial){ - xdg_toplevel_move(frame->xdg_toplevel, wl_seat, serial); + xdg_toplevel_move(ctx.xdg_toplevel, wl_seat, serial); } void -libdecor_frame_set_fullscreen(struct libdecor_frame *frame, - struct wl_output *output) -{ - xdg_toplevel_set_fullscreen(frame->xdg_toplevel, output); +libdecor_frame_set_fullscreen(struct libdecor_frame *frame, struct wl_output *output){ + xdg_toplevel_set_fullscreen(ctx.xdg_toplevel, output); } void -libdecor_frame_unset_fullscreen(struct libdecor_frame *frame) -{ - xdg_toplevel_unset_fullscreen(frame->xdg_toplevel); +libdecor_frame_unset_fullscreen(struct libdecor_frame *frame){ + xdg_toplevel_unset_fullscreen(ctx.xdg_toplevel); } bool @@ -1213,7 +1200,7 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s /* If the frame is configured as non-resizable before the first * configure event is received, we have to manually set the min/max * limits with the configured content size afterwards. */ - if (!(frame->frame_capabilities & LIBDECOR_ACTION_RESIZE)) { + if (!(frame->frame_capabilities & LIBDECOR_ACTION_RESIZE)){ frame->content_limits.min_width = frame->frame_content_width; frame->content_limits.max_width = frame->frame_content_width; @@ -1222,7 +1209,7 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s } if (frame->content_limits.min_width > 0 && - frame->content_limits.min_height > 0) { + frame->content_limits.min_height > 0){ struct libdecor_state state_min; int win_min_width, win_min_height; @@ -1232,14 +1219,14 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s frame_get_window_size_for(frame, &state_min, &win_min_width, &win_min_height); - xdg_toplevel_set_min_size(frame->xdg_toplevel, - win_min_width, win_min_height); - } else { - xdg_toplevel_set_min_size(frame->xdg_toplevel, 0, 0); + xdg_toplevel_set_min_size(ctx.xdg_toplevel, win_min_width, win_min_height); + } + else{ + xdg_toplevel_set_min_size(ctx.xdg_toplevel, 0, 0); } if (frame->content_limits.max_width > 0 && - frame->content_limits.max_height > 0) { + frame->content_limits.max_height > 0){ struct libdecor_state state_max; int win_max_width, win_max_height; @@ -1247,12 +1234,11 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s state_max.content_height = frame->content_limits.max_height; state_max.window_state = window_state; - frame_get_window_size_for(frame, &state_max, - &win_max_width, &win_max_height); - xdg_toplevel_set_max_size(frame->xdg_toplevel, - win_max_width, win_max_height); - } else { - xdg_toplevel_set_max_size(frame->xdg_toplevel, 0, 0); + frame_get_window_size_for(frame, &state_max, &win_max_width, &win_max_height); + xdg_toplevel_set_max_size(ctx.xdg_toplevel, win_max_width, win_max_height); + } + else{ + xdg_toplevel_set_max_size(ctx.xdg_toplevel, 0, 0); } } @@ -1291,7 +1277,7 @@ libdecor_frame_commit(struct libdecor_frame *frame, int w, int h, frame_set_window_geometry(frame, frame->frame_content_width, frame->frame_content_height); if (configuration != 0){ - xdg_surface_ack_configure(frame->xdg_surface, configuration->serial); + xdg_surface_ack_configure(ctx.xdg_surface, configuration->serial); } } @@ -1353,16 +1339,8 @@ cleanup(void){ } } - { - struct libdecor_frame *frame, *frame_tmp; - wl_list_for_each_safe(frame, frame_tmp, - &ctx.visible_frame_list, gtk_link) { - wl_list_remove(&frame->gtk_link); - } - - if (ctx.wl_shm){ - wl_shm_destroy(ctx.wl_shm); - } + if (ctx.wl_shm){ + wl_shm_destroy(ctx.wl_shm); } if (ctx.wl_subcompositor != 0){ @@ -1889,10 +1867,10 @@ libdecor_plugin_gtk_set_handle_application_cursor(bool handle_cursor){ static void toggle_maximized(void){ if (ctx.frame->frame_window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED){ - xdg_toplevel_unset_maximized(ctx.frame->xdg_toplevel); + xdg_toplevel_unset_maximized(ctx.xdg_toplevel); } else{ - xdg_toplevel_set_maximized(ctx.frame->xdg_toplevel); + xdg_toplevel_set_maximized(ctx.xdg_toplevel); } } @@ -2005,10 +1983,6 @@ libdecor_plugin_gtk_frame_free(struct libdecor_frame *frame){ g_clear_pointer(&frame->title, free); frame->decoration_type = DECORATION_TYPE_NONE; - - if (frame->gtk_link.next != 0){ - wl_list_remove(&frame->gtk_link); - } } static bool @@ -2155,26 +2129,20 @@ static void create_surface_subsurface_pair(struct libdecor_frame *frame, struct wl_surface **out_wl_surface, struct wl_subsurface **out_wl_subsurface){ - struct wl_compositor *wl_compositor = ctx.wl_compositor; struct wl_surface *wl_surface; - struct wl_surface *parent; struct wl_subsurface *wl_subsurface; - wl_surface = wl_compositor_create_surface(wl_compositor); - wl_proxy_set_tag((struct wl_proxy *) wl_surface, &libdecor_gtk_proxy_tag); - - parent = ctx.wl_surface; - wl_subsurface = wl_subcompositor_get_subsurface(ctx.wl_subcompositor, wl_surface, parent); + wl_surface = wl_compositor_create_surface(ctx.wl_compositor); + wl_proxy_set_tag((struct wl_proxy *)wl_surface, &libdecor_gtk_proxy_tag); + wl_subsurface = wl_subcompositor_get_subsurface(ctx.wl_subcompositor, wl_surface, ctx.wl_surface); *out_wl_surface = wl_surface; *out_wl_subsurface = wl_subsurface; } static void -ensure_component(struct libdecor_frame *frame, - struct border_component *cmpnt) -{ - if (!cmpnt->wl_surface) { +ensure_component(struct libdecor_frame *frame, struct border_component *cmpnt){ + if (!cmpnt->wl_surface){ wl_list_init(&cmpnt->output_list); cmpnt->scale = 1; create_surface_subsurface_pair(frame, &cmpnt->wl_surface, &cmpnt->wl_subsurface); @@ -2705,9 +2673,6 @@ static void draw_decoration(struct libdecor_frame *frame){ switch (frame->decoration_type) { case DECORATION_TYPE_NONE: { - if (frame->gtk_link.next != NULL){ - wl_list_remove(&frame->gtk_link); - } if (is_border_surfaces_showing(frame)){ hide_border_surfaces(frame); } @@ -2721,10 +2686,6 @@ draw_decoration(struct libdecor_frame *frame){ /* show title bar */ ensure_title_bar_surfaces(frame); draw_title_bar(frame); - /* link frame */ - if (frame->gtk_link.next == NULL){ - wl_list_insert(&ctx.visible_frame_list, &frame->gtk_link); - } }break; case DECORATION_TYPE_TITLE_ONLY: { @@ -2734,10 +2695,6 @@ draw_decoration(struct libdecor_frame *frame){ /* show title bar */ ensure_title_bar_surfaces(frame); draw_title_bar(frame); - /* link frame */ - if (frame->gtk_link.next == NULL){ - wl_list_insert(&ctx.visible_frame_list, &frame->gtk_link); - } }break; } } @@ -3381,7 +3338,7 @@ handle_button_on_header(struct libdecor_frame *frame, struct seat *seat, uint32_ switch (frame->hdr_focus.type) { case HEADER_MIN: { if (frame->frame_capabilities & LIBDECOR_ACTION_MINIMIZE){ - xdg_toplevel_set_minimized(frame->xdg_toplevel); + xdg_toplevel_set_minimized(ctx.xdg_toplevel); } }break; @@ -3393,7 +3350,7 @@ handle_button_on_header(struct libdecor_frame *frame, struct seat *seat, uint32_ case HEADER_CLOSE: { if (frame->frame_capabilities & LIBDECOR_ACTION_CLOSE){ - xdg_toplevel_close(frame, frame->xdg_toplevel); + xdg_toplevel_close(frame, ctx.xdg_toplevel); seat->pointer_focus = 0; } }break; @@ -3402,7 +3359,7 @@ handle_button_on_header(struct libdecor_frame *frame, struct seat *seat, uint32_ } frame->hdr_focus.state &= ~GTK_STATE_FLAG_ACTIVE; - if (GTK_IS_WIDGET(frame->header)) { + if (GTK_IS_WIDGET(frame->header)){ draw_title_bar(frame); wl_surface_commit(ctx.wl_surface); } @@ -3561,8 +3518,7 @@ touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial, } static void -touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial, - uint32_t time, int32_t id){ +touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial, uint32_t time, int32_t id){ struct seat *seat = data; if (seat->touch_focus && own_surface(seat->touch_focus)){ struct libdecor_frame *frame = wl_surface_get_user_data(seat->touch_focus); @@ -3571,7 +3527,7 @@ touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial, switch (frame->hdr_focus.type) { case HEADER_MIN: { if (frame->frame_capabilities & LIBDECOR_ACTION_MINIMIZE){ - xdg_toplevel_set_minimized(frame->xdg_toplevel); + xdg_toplevel_set_minimized(ctx.xdg_toplevel); } }break; @@ -3583,7 +3539,7 @@ touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial, case HEADER_CLOSE: { if (frame->frame_capabilities & LIBDECOR_ACTION_CLOSE){ - xdg_toplevel_close(frame, frame->xdg_toplevel); + xdg_toplevel_close(frame, ctx.xdg_toplevel); seat->touch_focus = 0; } }break; @@ -3629,10 +3585,7 @@ static void touch_frame(void *data, struct wl_touch *wl_touch){} static void -touch_cancel(void *data, - struct wl_touch *wl_touch) -{ -} +touch_cancel(void *data, struct wl_touch *wl_touch){} const struct wl_touch_listener touch_listener = { touch_down, @@ -3643,40 +3596,26 @@ const struct wl_touch_listener touch_listener = { }; static void -output_geometry(void *data, - struct wl_output *wl_output, - int32_t x, - int32_t y, - int32_t physical_width, - int32_t physical_height, - int32_t subpixel, - const char *make, - const char *model, - int32_t transform) -{ -} +output_geometry(void *data, struct wl_output *wl_output, + int32_t x, int32_t y, + int32_t physical_width, int32_t physical_height, + int32_t subpixel, const char *make, const char *model, + int32_t transform){} static void -output_mode(void *data, - struct wl_output *wl_output, - uint32_t flags, - int32_t width, - int32_t height, - int32_t refresh) -{ -} +output_mode(void *data, struct wl_output *wl_output, + uint32_t flags, int32_t width, int32_t height, + int32_t refresh){} static void -output_done(void *data, - struct wl_output *wl_output) -{ +output_done(void *data, struct wl_output *wl_output){ struct output *output = data; struct libdecor_frame *frame; struct seat *seat; - wl_list_for_each(frame, &ctx.visible_frame_list, gtk_link){ - bool updated = false; - updated |= redraw_scale(frame, &frame->shadow); + if (ctx.frame != 0 && + ctx.frame->decoration_type != DECORATION_TYPE_NONE){ + bool updated = redraw_scale(ctx.frame, &ctx.frame->shadow); if (updated){ wl_surface_commit(ctx.wl_surface); } @@ -3688,12 +3627,8 @@ output_done(void *data, } static void -output_scale(void *data, - struct wl_output *wl_output, - int32_t factor) -{ +output_scale(void *data, struct wl_output *wl_output, int32_t factor){ struct output *output = data; - output->scale = factor; } @@ -3705,8 +3640,7 @@ const struct wl_output_listener output_listener = { }; static void -remove_surface_outputs(struct border_component *cmpnt, const struct output *output) -{ +remove_surface_outputs(struct border_component *cmpnt, const struct output *output){ struct surface_output *surface_output; wl_list_for_each(surface_output, &cmpnt->output_list, link) { if (surface_output->output == output) { @@ -3718,13 +3652,13 @@ remove_surface_outputs(struct border_component *cmpnt, const struct output *outp } static void -output_removed(struct output *output) -{ +output_removed(struct output *output){ struct libdecor_frame *frame; struct seat *seat; - wl_list_for_each(frame, &ctx.visible_frame_list, gtk_link) { - remove_surface_outputs(&frame->shadow, output); + if (ctx.frame != 0 && + ctx.frame->decoration_type != DECORATION_TYPE_NONE){ + remove_surface_outputs(&ctx.frame->shadow, output); } wl_list_for_each(seat, &ctx.seat_list, link) { struct cursor_output *cursor_output; @@ -3744,8 +3678,7 @@ output_removed(struct output *output) //#include "desktop-settings.c" static bool -get_cursor_settings_from_env(char **theme, int *size) -{ +get_cursor_settings_from_env(char **theme, int *size){ char *env_xtheme; char *env_xsize; @@ -3764,9 +3697,7 @@ get_cursor_settings_from_env(char **theme, int *size) #include static DBusMessage * -get_setting_sync(DBusConnection *const connection, - const char *key, const char *value) -{ +get_setting_sync(DBusConnection *const connection, const char *key, const char *value){ DBusError error; dbus_bool_t success; DBusMessage *message; diff --git a/digesting_libdecor.h b/digesting_libdecor.h index a4dbcf5..e0711d3 100644 --- a/digesting_libdecor.h +++ b/digesting_libdecor.h @@ -163,18 +163,7 @@ struct border_component { }; struct libdecor_frame { - //struct libdecor_frame; - struct wl_list frame_link; - //struct libdecor_frame_private; - void *user_data; - - struct xdg_surface *xdg_surface; - struct xdg_toplevel *xdg_toplevel; - struct zxdg_toplevel_decoration_v1 *toplevel_decoration; - - bool pending_map; - char *app_id; char *title; struct libdecor_limits content_limits; @@ -187,16 +176,14 @@ struct libdecor_frame { enum libdecor_window_state frame_window_state; - bool has_decoration_mode; + bool has_decoration_mode; enum zxdg_toplevel_decoration_v1_mode decoration_mode; enum libdecor_capabilities frame_capabilities; - enum libdecor_wm_capabilities wm_capabilities; /* original limits for interactive resize */ struct libdecor_limits interactive_limits; - bool visible; //struct libdecor_frame_gtk; @@ -226,8 +213,6 @@ struct libdecor_frame { /* store pre-processed shadow tile */ cairo_surface_t *shadow_blur; - struct wl_list gtk_link; - struct { enum titlebar_gesture_state state; int button_pressed_count; @@ -474,6 +459,9 @@ typedef struct Ctx{ /* window */ struct wl_surface *wl_surface; struct libdecor_frame *frame; + struct xdg_surface *xdg_surface; + struct xdg_toplevel *xdg_toplevel; + struct zxdg_toplevel_decoration_v1 *toplevel_decoration; struct wl_egl_window *wl_egl_window; int configured; int w;