[digesting_libdecor] eliminate the frame init logic, just require frames be made after the context is setup
parent
2bce6b183c
commit
4d9d8d1081
|
|
@ -181,14 +181,6 @@ init_wl_display_callback(void *user_data, struct wl_callback *callback, uint32_t
|
|||
|
||||
wl_callback_destroy(callback);
|
||||
ctx.wl_callback = 0;
|
||||
|
||||
if (ctx.plugin_ready){
|
||||
finish_init();
|
||||
}
|
||||
|
||||
if (ctx.has_argb){
|
||||
libdecor_notify_plugin_ready();
|
||||
}
|
||||
}
|
||||
|
||||
const struct wl_callback_listener init_wl_display_callback_listener = {
|
||||
|
|
@ -219,8 +211,7 @@ seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities){
|
|||
}
|
||||
|
||||
static void
|
||||
seat_name(void *data, struct wl_seat *wl_seat, const char *name)
|
||||
{
|
||||
seat_name(void *data, struct wl_seat *wl_seat, const char *name){
|
||||
/* avoid warning messages when opening/closing popup window */
|
||||
struct seat *seat = (struct seat*)data;
|
||||
seat->name = strdup(name);
|
||||
|
|
@ -264,9 +255,6 @@ int main(){
|
|||
{
|
||||
ctx.w = 640;
|
||||
ctx.h = 480;
|
||||
|
||||
wl_list_init(&ctx.frames);
|
||||
|
||||
wl_list_init(&ctx.visible_frame_list);
|
||||
wl_list_init(&ctx.seat_list);
|
||||
wl_list_init(&ctx.output_list);
|
||||
|
|
@ -434,7 +422,6 @@ int main(){
|
|||
LIBDECOR_WM_CAPABILITIES_FULLSCREEN |
|
||||
LIBDECOR_WM_CAPABILITIES_MINIMIZE);
|
||||
|
||||
wl_list_insert(&ctx.frames, &ctx.frame->frame_link);
|
||||
wl_list_insert(&ctx.visible_frame_list, &ctx.frame->gtk_link);
|
||||
ctx.frame->visible = true;
|
||||
|
||||
|
|
@ -445,21 +432,27 @@ int main(){
|
|||
LIBDECOR_ACTION_FULLSCREEN |
|
||||
LIBDECOR_ACTION_CLOSE);
|
||||
|
||||
if (ctx.init_done){
|
||||
init_shell_surface(ctx.frame);
|
||||
}
|
||||
ctx.frame->xdg_surface = xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, ctx.frame->wl_surface);
|
||||
xdg_surface_add_listener(ctx.frame->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.frame->decoration_mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||
ctx.frame->toplevel_decoration = NULL;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.frame != 0){
|
||||
/* (libdecor.h) " Set the title of the window. " */
|
||||
libdecor_frame_set_app_id(ctx.frame, "demo");
|
||||
libdecor_frame_set_title(ctx.frame, "Example Window");
|
||||
|
||||
ctx.frame->state.content_limits.min_width = 80;
|
||||
ctx.frame->state.content_limits.min_height = 60;
|
||||
|
||||
/* (libdecor.h) " Map the window. " */
|
||||
libdecor_frame_map(ctx.frame);
|
||||
ctx.frame->content_limits.min_width = 80;
|
||||
ctx.frame->content_limits.min_height = 60;
|
||||
wl_surface_commit(ctx.frame->wl_surface);
|
||||
|
||||
/* (nodocs-wl_egl) */
|
||||
ctx.wl_egl_window = wl_egl_window_create(ctx.wl_surface, ctx.w, ctx.h);
|
||||
|
|
@ -628,9 +621,6 @@ LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT |
|
|||
LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM;
|
||||
|
||||
|
||||
static void
|
||||
do_map(struct libdecor_frame *frame);
|
||||
|
||||
static bool
|
||||
state_is_floating(enum libdecor_window_state window_state)
|
||||
{
|
||||
|
|
@ -642,7 +632,7 @@ constrain_content_size(const struct libdecor_frame *frame,
|
|||
int *width,
|
||||
int *height)
|
||||
{
|
||||
const struct libdecor_limits lim = frame->state.content_limits;
|
||||
const struct libdecor_limits lim = frame->content_limits;
|
||||
|
||||
if (lim.min_width > 0)
|
||||
*width = MAX(lim.min_width, *width);
|
||||
|
|
@ -1021,50 +1011,6 @@ xdg_toplevel_decoration_listener = {
|
|||
toplevel_decoration_configure,
|
||||
};
|
||||
|
||||
static void
|
||||
init_shell_surface(struct libdecor_frame *frame)
|
||||
{
|
||||
if (frame->xdg_surface)
|
||||
return;
|
||||
|
||||
frame->xdg_surface =
|
||||
xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, frame->wl_surface);
|
||||
xdg_surface_add_listener(frame->xdg_surface,
|
||||
&xdg_surface_listener,
|
||||
frame);
|
||||
|
||||
frame->xdg_toplevel =
|
||||
xdg_surface_get_toplevel(frame->xdg_surface);
|
||||
xdg_toplevel_add_listener(frame->xdg_toplevel,
|
||||
&xdg_toplevel_listener,
|
||||
frame);
|
||||
|
||||
frame->decoration_mode =
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||
frame->toplevel_decoration = NULL;
|
||||
//libdecor_frame_create_xdg_decoration(frame_priv);
|
||||
if (ctx.decoration_manager){
|
||||
frame->toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(ctx.decoration_manager, frame->xdg_toplevel);
|
||||
zxdg_toplevel_decoration_v1_add_listener(frame->toplevel_decoration, &xdg_toplevel_decoration_listener, frame);
|
||||
}
|
||||
|
||||
if (frame->state.parent) {
|
||||
xdg_toplevel_set_parent(frame->xdg_toplevel,
|
||||
frame->state.parent);
|
||||
}
|
||||
if (frame->state.title) {
|
||||
xdg_toplevel_set_title(frame->xdg_toplevel,
|
||||
frame->state.title);
|
||||
}
|
||||
if (frame->state.app_id) {
|
||||
xdg_toplevel_set_app_id(frame->xdg_toplevel,
|
||||
frame->state.app_id);
|
||||
}
|
||||
|
||||
if (frame->pending_map)
|
||||
do_map(frame);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_ref(struct libdecor_frame *frame){
|
||||
frame->ref_count++;
|
||||
|
|
@ -1088,8 +1034,8 @@ libdecor_frame_unref(struct libdecor_frame *frame){
|
|||
|
||||
libdecor_plugin_gtk_frame_free(frame);
|
||||
|
||||
free(frame->state.title);
|
||||
free(frame->state.app_id);
|
||||
free(frame->title);
|
||||
free(frame->app_id);
|
||||
|
||||
free(frame);
|
||||
}
|
||||
|
|
@ -1097,8 +1043,7 @@ libdecor_frame_unref(struct libdecor_frame *frame){
|
|||
|
||||
void
|
||||
libdecor_frame_set_visibility(struct libdecor_frame *frame,
|
||||
bool visible)
|
||||
{
|
||||
bool visible){
|
||||
frame->visible = visible;
|
||||
|
||||
/* enable/disable decorations that are managed by the compositor.
|
||||
|
|
@ -1134,59 +1079,32 @@ libdecor_frame_set_visibility(struct libdecor_frame *frame,
|
|||
|
||||
frame_set_window_geometry(frame, frame->frame_content_width, frame->frame_content_height);
|
||||
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_set_parent(struct libdecor_frame *frame,
|
||||
struct libdecor_frame *parent)
|
||||
{
|
||||
if (!frame->xdg_toplevel)
|
||||
return;
|
||||
|
||||
frame->state.parent = ((parent != 0) ? parent->xdg_toplevel : 0);
|
||||
|
||||
xdg_toplevel_set_parent(frame->xdg_toplevel, frame->state.parent);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_set_title(struct libdecor_frame *frame, const char *title){
|
||||
if (!STREQL(frame->state.title, title)){
|
||||
free(frame->state.title);
|
||||
frame->state.title = strdup(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);
|
||||
|
||||
/*
|
||||
* when in SSD mode, the window title is not to be managed by GTK;
|
||||
* this is detected by frame_gtk->header not being a proper GTK widget
|
||||
*/
|
||||
if (GTK_IS_WIDGET(frame->header)){
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
libdecor_frame_get_title(struct libdecor_frame *frame){
|
||||
return frame->state.title;
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_set_app_id(struct libdecor_frame *frame, const char *app_id){
|
||||
free(frame->state.app_id);
|
||||
frame->state.app_id = strdup(app_id);
|
||||
|
||||
if (!frame->xdg_toplevel)
|
||||
return;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1199,34 +1117,29 @@ set_capabilities(struct libdecor_frame *frame, const enum libdecor_capabilities
|
|||
frame->frame_content_height != 0){
|
||||
|
||||
frame->gtk_capabilities = frame->frame_capabilities;
|
||||
|
||||
/*
|
||||
* when in SSD mode, the window title is not to be managed by GTK;
|
||||
* this is detected by frame_gtk->header not being a proper GTK widget
|
||||
*/
|
||||
if (GTK_IS_WIDGET(frame->header)){
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
if (!(frame->frame_capabilities & LIBDECOR_ACTION_RESIZE)){
|
||||
frame->interactive_limits = frame->state.content_limits;
|
||||
frame->interactive_limits = frame->content_limits;
|
||||
/* set fixed window size */
|
||||
ctx.frame->state.content_limits.min_width = frame->frame_content_width;
|
||||
ctx.frame->state.content_limits.min_height = frame->frame_content_height;
|
||||
ctx.frame->state.content_limits.max_width = frame->frame_content_width;
|
||||
ctx.frame->state.content_limits.max_height = frame->frame_content_height;
|
||||
ctx.frame->content_limits.min_width = frame->frame_content_width;
|
||||
ctx.frame->content_limits.min_height = frame->frame_content_height;
|
||||
ctx.frame->content_limits.max_width = frame->frame_content_width;
|
||||
ctx.frame->content_limits.max_height = frame->frame_content_height;
|
||||
}
|
||||
else{
|
||||
/* restore old limits */
|
||||
frame->state.content_limits = frame->interactive_limits;
|
||||
frame->content_limits = frame->interactive_limits;
|
||||
}
|
||||
|
||||
state = libdecor_state_new(frame->frame_content_width, frame->frame_content_height);
|
||||
libdecor_frame_commit(frame, state, NULL);
|
||||
libdecor_frame_commit(frame, state, 0);
|
||||
libdecor_state_free(state);
|
||||
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1353,16 +1266,16 @@ libdecor_frame_close(struct libdecor_frame *frame)
|
|||
bool
|
||||
valid_limits(struct libdecor_frame *frame)
|
||||
{
|
||||
if (frame->state.content_limits.min_width > 0 &&
|
||||
frame->state.content_limits.max_width > 0 &&
|
||||
frame->state.content_limits.min_width >
|
||||
frame->state.content_limits.max_width)
|
||||
if (frame->content_limits.min_width > 0 &&
|
||||
frame->content_limits.max_width > 0 &&
|
||||
frame->content_limits.min_width >
|
||||
frame->content_limits.max_width)
|
||||
return false;
|
||||
|
||||
if (frame->state.content_limits.min_height > 0 &&
|
||||
frame->state.content_limits.max_height > 0 &&
|
||||
frame->state.content_limits.min_height >
|
||||
frame->state.content_limits.max_height)
|
||||
if (frame->content_limits.min_height > 0 &&
|
||||
frame->content_limits.max_height > 0 &&
|
||||
frame->content_limits.min_height >
|
||||
frame->content_limits.max_height)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -1378,20 +1291,20 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s
|
|||
* 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)) {
|
||||
frame->state.content_limits.min_width = frame->frame_content_width;
|
||||
frame->state.content_limits.max_width = frame->frame_content_width;
|
||||
frame->content_limits.min_width = frame->frame_content_width;
|
||||
frame->content_limits.max_width = frame->frame_content_width;
|
||||
|
||||
frame->state.content_limits.min_height = frame->frame_content_height;
|
||||
frame->state.content_limits.max_height = frame->frame_content_height;
|
||||
frame->content_limits.min_height = frame->frame_content_height;
|
||||
frame->content_limits.max_height = frame->frame_content_height;
|
||||
}
|
||||
|
||||
if (frame->state.content_limits.min_width > 0 &&
|
||||
frame->state.content_limits.min_height > 0) {
|
||||
if (frame->content_limits.min_width > 0 &&
|
||||
frame->content_limits.min_height > 0) {
|
||||
struct libdecor_state state_min;
|
||||
int win_min_width, win_min_height;
|
||||
|
||||
state_min.content_width = frame->state.content_limits.min_width;
|
||||
state_min.content_height = frame->state.content_limits.min_height;
|
||||
state_min.content_width = frame->content_limits.min_width;
|
||||
state_min.content_height = frame->content_limits.min_height;
|
||||
state_min.window_state = window_state;
|
||||
|
||||
frame_get_window_size_for(frame, &state_min,
|
||||
|
|
@ -1402,13 +1315,13 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s
|
|||
xdg_toplevel_set_min_size(frame->xdg_toplevel, 0, 0);
|
||||
}
|
||||
|
||||
if (frame->state.content_limits.max_width > 0 &&
|
||||
frame->state.content_limits.max_height > 0) {
|
||||
if (frame->content_limits.max_width > 0 &&
|
||||
frame->content_limits.max_height > 0) {
|
||||
struct libdecor_state state_max;
|
||||
int win_max_width, win_max_height;
|
||||
|
||||
state_max.content_width = frame->state.content_limits.max_width;
|
||||
state_max.content_height = frame->state.content_limits.max_height;
|
||||
state_max.content_width = frame->content_limits.max_width;
|
||||
state_max.content_height = frame->content_limits.max_height;
|
||||
state_max.window_state = window_state;
|
||||
|
||||
frame_get_window_size_for(frame, &state_max,
|
||||
|
|
@ -1427,11 +1340,6 @@ libdecor_frame_apply_state(struct libdecor_frame *frame, struct libdecor_state *
|
|||
libdecor_frame_apply_limits(frame, state->window_state);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_toplevel_commit(struct libdecor_frame *frame){
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state,
|
||||
struct libdecor_configuration *configuration){
|
||||
|
|
@ -1461,29 +1369,6 @@ libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_map(struct libdecor_frame *frame)
|
||||
{
|
||||
frame->pending_map = false;
|
||||
wl_surface_commit(frame->wl_surface);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_map(struct libdecor_frame *frame)
|
||||
{
|
||||
if (!frame->xdg_surface) {
|
||||
frame->pending_map = true;
|
||||
return;
|
||||
}
|
||||
|
||||
do_map(frame);
|
||||
}
|
||||
|
||||
enum libdecor_wm_capabilities
|
||||
libdecor_frame_get_wm_capabilities(struct libdecor_frame *frame){
|
||||
return frame->wm_capabilities;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_wm_base_ping(void *user_data, struct xdg_wm_base *xdg_wm_base, uint32_t serial){
|
||||
xdg_wm_base_pong(xdg_wm_base, serial);
|
||||
|
|
@ -1493,31 +1378,67 @@ const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
|||
xdg_wm_base_ping,
|
||||
};
|
||||
|
||||
static void
|
||||
finish_init(void){
|
||||
struct libdecor_frame *frame;
|
||||
wl_list_for_each(frame, &ctx.frames, frame_link){
|
||||
init_shell_surface(frame);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
libdecor_dispatch(int timeout){
|
||||
return libdecor_plugin_gtk_dispatch(timeout);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_notify_plugin_ready(void){
|
||||
ctx.plugin_ready = true;
|
||||
|
||||
if (ctx.init_done){
|
||||
finish_init();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cleanup(void){
|
||||
libdecor_plugin_gtk_destroy();
|
||||
{
|
||||
struct seat *seat, *seat_tmp;
|
||||
wl_list_for_each_safe(seat, seat_tmp, &ctx.seat_list, link) {
|
||||
struct cursor_output *cursor_output, *tmp;
|
||||
|
||||
if (seat->wl_pointer){
|
||||
wl_pointer_destroy(seat->wl_pointer);
|
||||
}
|
||||
if (seat->wl_touch){
|
||||
wl_touch_destroy(seat->wl_touch);
|
||||
}
|
||||
if (seat->cursor_surface){
|
||||
wl_surface_destroy(seat->cursor_surface);
|
||||
}
|
||||
wl_seat_destroy(seat->wl_seat);
|
||||
if (seat->cursor_theme){
|
||||
wl_cursor_theme_destroy(seat->cursor_theme);
|
||||
}
|
||||
|
||||
wl_list_for_each_safe(cursor_output, tmp, &seat->cursor_outputs, link) {
|
||||
wl_list_remove(&cursor_output->link);
|
||||
free(cursor_output);
|
||||
}
|
||||
|
||||
free(seat->name);
|
||||
free(seat);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
struct output *output, *output_tmp;
|
||||
wl_list_for_each_safe(output, output_tmp,
|
||||
&ctx.output_list, link) {
|
||||
if (wl_output_get_version (output->wl_output) >=
|
||||
WL_OUTPUT_RELEASE_SINCE_VERSION)
|
||||
wl_output_release(output->wl_output);
|
||||
else
|
||||
wl_output_destroy(output->wl_output);
|
||||
free(output);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
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_subcompositor != 0){
|
||||
wl_subcompositor_destroy(ctx.wl_subcompositor);
|
||||
}
|
||||
|
|
@ -2016,55 +1937,6 @@ send_cursor(struct seat *seat);
|
|||
static bool
|
||||
update_local_cursor(struct seat *seat);
|
||||
|
||||
static void
|
||||
libdecor_plugin_gtk_destroy(void)
|
||||
{
|
||||
struct seat *seat, *seat_tmp;
|
||||
struct output *output, *output_tmp;
|
||||
struct libdecor_frame *frame, *frame_tmp;
|
||||
|
||||
wl_list_for_each_safe(seat, seat_tmp, &ctx.seat_list, link) {
|
||||
struct cursor_output *cursor_output, *tmp;
|
||||
|
||||
if (seat->wl_pointer)
|
||||
wl_pointer_destroy(seat->wl_pointer);
|
||||
if (seat->wl_touch)
|
||||
wl_touch_destroy(seat->wl_touch);
|
||||
if (seat->cursor_surface)
|
||||
wl_surface_destroy(seat->cursor_surface);
|
||||
wl_seat_destroy(seat->wl_seat);
|
||||
if (seat->cursor_theme)
|
||||
wl_cursor_theme_destroy(seat->cursor_theme);
|
||||
|
||||
wl_list_for_each_safe(cursor_output, tmp, &seat->cursor_outputs, link) {
|
||||
wl_list_remove(&cursor_output->link);
|
||||
free(cursor_output);
|
||||
}
|
||||
|
||||
free(seat->name);
|
||||
free(seat);
|
||||
}
|
||||
|
||||
wl_list_for_each_safe(output, output_tmp,
|
||||
&ctx.output_list, link) {
|
||||
if (wl_output_get_version (output->wl_output) >=
|
||||
WL_OUTPUT_RELEASE_SINCE_VERSION)
|
||||
wl_output_release(output->wl_output);
|
||||
else
|
||||
wl_output_destroy(output->wl_output);
|
||||
free(output);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
libdecor_plugin_gtk_get_fd(void){
|
||||
return wl_display_get_fd(ctx.wl_display);
|
||||
|
|
@ -2334,8 +2206,9 @@ surface_enter(void *data,
|
|||
if (!add_surface_output(wl_output, &cmpnt->output_list))
|
||||
return;
|
||||
|
||||
if (redraw_scale(frame, cmpnt))
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
if (redraw_scale(frame, cmpnt)){
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -2370,8 +2243,9 @@ surface_leave(void *data,
|
|||
if (!remove_surface_output(&cmpnt->output_list, wl_output))
|
||||
return;
|
||||
|
||||
if (redraw_scale(frame, cmpnt))
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
if (redraw_scale(frame, cmpnt)){
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static struct wl_surface_listener surface_listener = {
|
||||
|
|
@ -2456,8 +2330,7 @@ ensure_title_bar_surfaces(struct libdecor_frame *frame){
|
|||
&ctx.drag_threshold,
|
||||
NULL);
|
||||
/* set as "default" decoration */
|
||||
g_object_set(frame->header,
|
||||
"title", libdecor_frame_get_title(frame),
|
||||
g_object_set(frame->header, "title", frame->title,
|
||||
"has-subtitle", FALSE,
|
||||
"show-close-button", TRUE,
|
||||
NULL);
|
||||
|
|
@ -2910,20 +2783,18 @@ draw_title_bar(struct libdecor_frame *frame)
|
|||
/* set default width, using an empty title to estimate its smallest admissible value */
|
||||
gtk_header_bar_set_title(GTK_HEADER_BAR(frame->header), "");
|
||||
gtk_widget_get_preferred_width(frame->header, NULL, &pref_width);
|
||||
gtk_header_bar_set_title(GTK_HEADER_BAR(frame->header),
|
||||
libdecor_frame_get_title(frame));
|
||||
if (frame->state.content_limits.min_width < pref_width){
|
||||
frame->state.content_limits.min_width = pref_width;
|
||||
gtk_header_bar_set_title(GTK_HEADER_BAR(frame->header), frame->title);
|
||||
if (frame->content_limits.min_width < pref_width){
|
||||
frame->content_limits.min_width = pref_width;
|
||||
}
|
||||
if (frame->state.content_limits.max_width != 0 &&
|
||||
frame->state.content_limits.max_width <
|
||||
frame->state.content_limits.min_width) {
|
||||
frame->state.content_limits.max_width = frame->state.content_limits.min_width;
|
||||
if (frame->content_limits.max_width != 0 &&
|
||||
frame->content_limits.max_width < frame->content_limits.min_width){
|
||||
frame->content_limits.max_width = frame->content_limits.min_width;
|
||||
}
|
||||
W = frame->frame_content_width;
|
||||
H = frame->frame_content_height;
|
||||
if (W < frame->state.content_limits.min_width) {
|
||||
W = frame->state.content_limits.min_width;
|
||||
if (W < frame->content_limits.min_width) {
|
||||
W = frame->content_limits.min_width;
|
||||
struct libdecor_state *libdecor_state = libdecor_state_new(W, H);
|
||||
libdecor_frame_commit(frame, libdecor_state, NULL);
|
||||
libdecor_state_free(libdecor_state);
|
||||
|
|
@ -3034,10 +2905,10 @@ libdecor_plugin_gtk_frame_commit(struct libdecor_frame *frame,
|
|||
|
||||
/* set fixed window size */
|
||||
if (!(frame->frame_capabilities & LIBDECOR_ACTION_RESIZE)){
|
||||
ctx.frame->state.content_limits.min_width = frame->gtk_content_width;
|
||||
ctx.frame->state.content_limits.min_height = frame->gtk_content_height;
|
||||
ctx.frame->state.content_limits.max_width = frame->gtk_content_width;
|
||||
ctx.frame->state.content_limits.max_height = frame->gtk_content_height;
|
||||
ctx.frame->content_limits.min_width = frame->gtk_content_width;
|
||||
ctx.frame->content_limits.min_height = frame->gtk_content_height;
|
||||
ctx.frame->content_limits.max_width = frame->gtk_content_width;
|
||||
ctx.frame->content_limits.max_height = frame->gtk_content_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3086,7 +2957,7 @@ sync_active_component(struct libdecor_frame *frame, struct seat *seat){
|
|||
update_component_focus(frame, seat->pointer_focus, seat);
|
||||
if (old_active != frame->active) {
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
if (update_local_cursor(seat))
|
||||
|
|
@ -3113,7 +2984,7 @@ synthesize_pointer_enter(struct seat *seat)
|
|||
/* update decorations */
|
||||
if (frame->active) {
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
update_local_cursor(seat);
|
||||
|
|
@ -3138,7 +3009,7 @@ synthesize_pointer_leave(struct seat *seat){
|
|||
|
||||
frame->active = NULL;
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
update_local_cursor(seat);
|
||||
}
|
||||
|
||||
|
|
@ -3467,7 +3338,7 @@ pointer_enter(void *data,
|
|||
/* update decorations */
|
||||
if (frame->active) {
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
update_local_cursor(seat);
|
||||
|
|
@ -3501,7 +3372,7 @@ pointer_leave(void *data,
|
|||
frame->hdr_focus.widget = NULL;
|
||||
frame->hdr_focus.type = HEADER_NONE;
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
update_local_cursor(seat);
|
||||
}
|
||||
}
|
||||
|
|
@ -3511,8 +3382,7 @@ pointer_motion(void *data,
|
|||
struct wl_pointer *wl_pointer,
|
||||
uint32_t time,
|
||||
wl_fixed_t surface_x,
|
||||
wl_fixed_t surface_y)
|
||||
{
|
||||
wl_fixed_t surface_y){
|
||||
struct seat *seat = data;
|
||||
struct libdecor_frame *frame;
|
||||
struct header_element_data new_focus;
|
||||
|
|
@ -3541,7 +3411,7 @@ pointer_motion(void *data,
|
|||
frame->hdr_focus.state |= GTK_STATE_FLAG_PRELIGHT;
|
||||
/* redraw with updated button visuals */
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
|
||||
switch (frame->titlebar_gesture.state) {
|
||||
case TITLEBAR_GESTURE_STATE_BUTTON_PRESSED:
|
||||
|
|
@ -3637,7 +3507,7 @@ handle_button_on_header(struct libdecor_frame *frame, struct seat *seat, uint32_
|
|||
case HEADER_CLOSE: {
|
||||
frame->hdr_focus.state |= GTK_STATE_FLAG_ACTIVE;
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}break;
|
||||
|
||||
default: break;
|
||||
|
|
@ -3681,7 +3551,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)) {
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
libdecor_frame_unref(frame);
|
||||
}
|
||||
|
|
@ -3690,7 +3560,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)) {
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3777,7 +3647,7 @@ update_touch_focus(struct seat *seat, struct libdecor_frame *frame,
|
|||
frame->hdr_focus.state |= GTK_STATE_FLAG_PRELIGHT;
|
||||
/* redraw with updated button visuals */
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
else{
|
||||
frame->hdr_focus.type = HEADER_NONE;
|
||||
|
|
@ -3814,7 +3684,7 @@ touch_down(void *data,
|
|||
|
||||
/* update decorations */
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
|
||||
enum libdecor_resize_edge edge = LIBDECOR_RESIZE_EDGE_NONE;
|
||||
switch (frame->touch_active->type) {
|
||||
|
|
@ -3832,7 +3702,7 @@ touch_down(void *data,
|
|||
case HEADER_CLOSE: {
|
||||
frame->hdr_focus.state |= GTK_STATE_FLAG_ACTIVE;
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}break;
|
||||
default: {
|
||||
if (time - seat->touch_down_time_stamp < (uint32_t)ctx.double_click_time_ms) {
|
||||
|
|
@ -3897,7 +3767,7 @@ touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
|||
frame->hdr_focus.state &= ~GTK_STATE_FLAG_ACTIVE;
|
||||
if (GTK_IS_WIDGET(frame->header)) {
|
||||
draw_title_bar(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
libdecor_frame_unref(frame);
|
||||
break;
|
||||
|
|
@ -3910,7 +3780,7 @@ touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
|||
frame->hdr_focus.widget = NULL;
|
||||
frame->hdr_focus.type = HEADER_NONE;
|
||||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3981,8 +3851,9 @@ output_done(void *data,
|
|||
wl_list_for_each(frame, &ctx.visible_frame_list, gtk_link){
|
||||
bool updated = false;
|
||||
updated |= redraw_scale(frame, &frame->shadow);
|
||||
if (updated)
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
if (updated){
|
||||
wl_surface_commit(ctx.wl_surface);
|
||||
}
|
||||
}
|
||||
wl_list_for_each(seat, &ctx.seat_list, link) {
|
||||
if (update_local_cursor(seat))
|
||||
|
|
|
|||
|
|
@ -179,12 +179,10 @@ struct libdecor_frame {
|
|||
|
||||
bool pending_map;
|
||||
|
||||
struct {
|
||||
char *app_id;
|
||||
char *title;
|
||||
struct libdecor_limits content_limits;
|
||||
struct xdg_toplevel *parent;
|
||||
} state;
|
||||
|
||||
struct libdecor_configuration *pending_configuration;
|
||||
|
||||
|
|
@ -213,8 +211,6 @@ struct libdecor_frame {
|
|||
|
||||
enum decoration_type decoration_type;
|
||||
|
||||
char *title;
|
||||
|
||||
enum libdecor_capabilities gtk_capabilities;
|
||||
|
||||
struct border_component *active;
|
||||
|
|
@ -365,11 +361,8 @@ void libdecor_frame_unref(struct libdecor_frame *frame);
|
|||
void libdecor_frame_set_visibility(struct libdecor_frame *frame,
|
||||
bool visible);
|
||||
|
||||
void libdecor_frame_set_parent(struct libdecor_frame *frame,
|
||||
struct libdecor_frame *parent);
|
||||
void libdecor_frame_set_title(struct libdecor_frame *frame,
|
||||
const char *title);
|
||||
const char * libdecor_frame_get_title(struct libdecor_frame *frame);
|
||||
void libdecor_frame_set_app_id(struct libdecor_frame *frame,
|
||||
const char *app_id);
|
||||
void libdecor_frame_show_window_menu(struct libdecor_frame *frame,
|
||||
|
|
@ -405,7 +398,7 @@ void libdecor_frame_unset_fullscreen(struct libdecor_frame *frame);
|
|||
bool libdecor_frame_is_floating(struct libdecor_frame *frame);
|
||||
void libdecor_frame_close(struct libdecor_frame *frame);
|
||||
void libdecor_frame_map(struct libdecor_frame *frame);
|
||||
enum libdecor_wm_capabilities libdecor_frame_get_wm_capabilities(struct libdecor_frame *frame);
|
||||
|
||||
struct libdecor_state * libdecor_state_new(int width, int height);
|
||||
void libdecor_state_free(struct libdecor_state *state);
|
||||
bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration,
|
||||
|
|
@ -419,10 +412,6 @@ int libdecor_dispatch(int timeout);
|
|||
|
||||
// libdecor-plugin.h
|
||||
|
||||
void libdecor_frame_toplevel_commit(struct libdecor_frame *frame);
|
||||
|
||||
void libdecor_notify_plugin_ready(void);
|
||||
|
||||
int libdecor_state_get_content_width(struct libdecor_state *state);
|
||||
|
||||
int libdecor_state_get_content_height(struct libdecor_state *state);
|
||||
|
|
@ -446,11 +435,12 @@ int libdecor_os_create_anonymous_file(off_t size);
|
|||
|
||||
// #include "libdecor.c"
|
||||
|
||||
static void finish_init(void);
|
||||
static void init_shell_surface(struct libdecor_frame *frame);
|
||||
|
||||
static void set_capabilities(struct libdecor_frame *frame, const enum libdecor_capabilities new_capabilities);
|
||||
|
||||
static void do_map(struct libdecor_frame *frame);
|
||||
|
||||
//#include "plugins/gtk/libdecor-gtk.c"
|
||||
|
||||
|
||||
|
|
@ -460,7 +450,6 @@ static void output_removed(struct output *output);
|
|||
|
||||
static const char *libdecor_gtk_proxy_tag = "libdecor-gtk";
|
||||
|
||||
static void libdecor_plugin_gtk_destroy(void);
|
||||
static int libdecor_plugin_gtk_get_fd(void);
|
||||
static int libdecor_plugin_gtk_get_fd(void);
|
||||
static int libdecor_plugin_gtk_dispatch(int timeout);
|
||||
|
|
@ -491,12 +480,10 @@ typedef struct Ctx{
|
|||
struct zxdg_decoration_manager_v1 *decoration_manager;
|
||||
struct wl_callback *wl_callback;
|
||||
|
||||
struct wl_list frames;
|
||||
struct wl_list visible_frame_list;
|
||||
struct wl_list seat_list;
|
||||
struct wl_list output_list;
|
||||
|
||||
bool plugin_ready;
|
||||
bool init_done;
|
||||
bool has_error;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue