[digesting_libdecor] clean up the property changing code, eliminate notify_on_property_change
parent
785b014580
commit
c1f41242ec
|
|
@ -406,28 +406,26 @@ int main(){
|
|||
}
|
||||
|
||||
if (ctx.wl_surface != 0){
|
||||
{
|
||||
ctx.frame = calloc(1, sizeof *ctx.frame);
|
||||
wl_list_insert(&ctx.visible_frame_list, &ctx.frame->gtk_link);
|
||||
|
||||
{
|
||||
static const int size = 128;
|
||||
static const int boundary = 32;
|
||||
cairo_t *cr;
|
||||
cairo_surface_t *shadow_blur;
|
||||
|
||||
ctx.frame->shadow_blur = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size, size);
|
||||
cr = cairo_create(ctx.frame->shadow_blur);
|
||||
shadow_blur = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size, size);
|
||||
cr = cairo_create(shadow_blur);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
cairo_set_source_rgba(cr, 0, 0, 0, 1);
|
||||
cairo_rectangle(cr, boundary, boundary, size - 2*boundary, size - 2*boundary);
|
||||
cairo_fill(cr);
|
||||
cairo_destroy(cr);
|
||||
|
||||
blur_surface(ctx.frame->shadow_blur, 64);
|
||||
}
|
||||
blur_surface(shadow_blur, 64);
|
||||
ctx.frame->shadow_blur = shadow_blur;
|
||||
}
|
||||
|
||||
{
|
||||
ctx.frame->ref_count = 1;
|
||||
|
||||
ctx.frame->wl_surface = ctx.wl_surface;
|
||||
|
|
@ -437,20 +435,20 @@ int main(){
|
|||
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;
|
||||
|
||||
libdecor_frame_set_capabilities(ctx.frame,
|
||||
set_capabilities(ctx.frame,
|
||||
LIBDECOR_ACTION_MOVE |
|
||||
LIBDECOR_ACTION_RESIZE |
|
||||
LIBDECOR_ACTION_MINIMIZE |
|
||||
LIBDECOR_ACTION_FULLSCREEN |
|
||||
LIBDECOR_ACTION_CLOSE);
|
||||
|
||||
ctx.frame->visible = true;
|
||||
|
||||
if (ctx.init_done){
|
||||
init_shell_surface(ctx.frame);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ctx.frame != 0){
|
||||
|
|
@ -1160,13 +1158,21 @@ libdecor_frame_set_title(struct libdecor_frame *frame, const char *title){
|
|||
free(frame->state.title);
|
||||
frame->state.title = strdup(title);
|
||||
|
||||
if (!frame->xdg_toplevel){
|
||||
return;
|
||||
}
|
||||
free(frame->title);
|
||||
frame->title = strdup(title);
|
||||
|
||||
if (frame->xdg_toplevel != 0){
|
||||
xdg_toplevel_set_title(frame->xdg_toplevel, title);
|
||||
|
||||
libdecor_plugin_gtk_frame_property_changed(frame);
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1187,58 +1193,43 @@ libdecor_frame_set_app_id(struct libdecor_frame *frame, const char *app_id){
|
|||
}
|
||||
|
||||
static void
|
||||
notify_on_capability_change(struct libdecor_frame *frame,
|
||||
const enum libdecor_capabilities old_capabilities)
|
||||
{
|
||||
set_capabilities(struct libdecor_frame *frame, const enum libdecor_capabilities new_capabilities){
|
||||
struct libdecor_state *state;
|
||||
|
||||
if (frame->frame_capabilities == old_capabilities)
|
||||
return;
|
||||
if (frame->frame_capabilities != new_capabilities){
|
||||
frame->frame_capabilities = new_capabilities;
|
||||
if (frame->frame_content_width != 0 &&
|
||||
frame->frame_content_height != 0){
|
||||
|
||||
if (frame->frame_content_width == 0 ||
|
||||
frame->frame_content_height == 0)
|
||||
return;
|
||||
frame->gtk_capabilities = frame->frame_capabilities;
|
||||
|
||||
libdecor_plugin_gtk_frame_property_changed(frame);
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
if (!libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) {
|
||||
if (!libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)){
|
||||
frame->interactive_limits = frame->state.content_limits;
|
||||
/* set fixed window size */
|
||||
libdecor_frame_set_min_content_size(frame,
|
||||
frame->frame_content_width,
|
||||
frame->frame_content_height);
|
||||
libdecor_frame_set_max_content_size(frame,
|
||||
frame->frame_content_width,
|
||||
frame->frame_content_height);
|
||||
} else {
|
||||
libdecor_frame_set_min_content_size(frame, frame->frame_content_width, frame->frame_content_height);
|
||||
libdecor_frame_set_max_content_size(frame, frame->frame_content_width, frame->frame_content_height);
|
||||
}
|
||||
else{
|
||||
/* restore old limits */
|
||||
frame->state.content_limits = frame->interactive_limits;
|
||||
}
|
||||
|
||||
state = libdecor_state_new(frame->frame_content_width,
|
||||
frame->frame_content_height);
|
||||
state = libdecor_state_new(frame->frame_content_width, frame->frame_content_height);
|
||||
libdecor_frame_commit(frame, state, NULL);
|
||||
libdecor_state_free(state);
|
||||
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_set_capabilities(struct libdecor_frame *frame,
|
||||
enum libdecor_capabilities capabilities)
|
||||
{
|
||||
const enum libdecor_capabilities old_capabilities = frame->frame_capabilities;
|
||||
frame->frame_capabilities |= capabilities;
|
||||
notify_on_capability_change(frame, old_capabilities);
|
||||
}
|
||||
|
||||
void
|
||||
libdecor_frame_unset_capabilities(struct libdecor_frame *frame,
|
||||
enum libdecor_capabilities capabilities)
|
||||
{
|
||||
const enum libdecor_capabilities old_capabilities = frame->frame_capabilities;
|
||||
frame->frame_capabilities &= ~capabilities;
|
||||
notify_on_capability_change(frame, old_capabilities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1615,8 +1606,7 @@ cleanup(void){
|
|||
|
||||
//#include "libdecor-cairo-blur.c"
|
||||
int
|
||||
blur_surface(cairo_surface_t *surface, int margin)
|
||||
{
|
||||
blur_surface(cairo_surface_t *surface, int margin){
|
||||
int32_t width, height, stride, x, y, z, w;
|
||||
uint8_t *src, *dst;
|
||||
uint32_t *s, *d, a, p;
|
||||
|
|
@ -1705,8 +1695,7 @@ blur_surface(cairo_surface_t *surface, int margin)
|
|||
|
||||
void
|
||||
render_shadow(cairo_t *cr, cairo_surface_t *surface,
|
||||
int x, int y, int width, int height, int margin, int top_margin)
|
||||
{
|
||||
int x, int y, int width, int height, int margin, int top_margin){
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_matrix_t matrix;
|
||||
int i, fx, fy, shadow_height, shadow_width;
|
||||
|
|
@ -2198,8 +2187,7 @@ libdecor_plugin_gtk_set_handle_application_cursor(bool handle_cursor){
|
|||
}
|
||||
|
||||
static void
|
||||
toggle_maximized(struct libdecor_frame *const frame)
|
||||
{
|
||||
toggle_maximized(struct libdecor_frame *const frame){
|
||||
if (!libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE))
|
||||
return;
|
||||
|
||||
|
|
@ -2211,9 +2199,7 @@ toggle_maximized(struct libdecor_frame *const frame)
|
|||
}
|
||||
|
||||
static void
|
||||
buffer_release(void *user_data,
|
||||
struct wl_buffer *wl_buffer)
|
||||
{
|
||||
buffer_release(void *user_data, struct wl_buffer *wl_buffer){
|
||||
struct buffer *buffer = user_data;
|
||||
|
||||
if (buffer->is_detached)
|
||||
|
|
@ -2227,11 +2213,7 @@ const struct wl_buffer_listener buffer_listener = {
|
|||
};
|
||||
|
||||
static struct buffer *
|
||||
create_shm_buffer(int width,
|
||||
int height,
|
||||
bool opaque,
|
||||
int scale)
|
||||
{
|
||||
create_shm_buffer(int width, int height, bool opaque, int scale){
|
||||
struct wl_shm_pool *pool;
|
||||
int fd, size, buffer_width, buffer_height, stride;
|
||||
void *data;
|
||||
|
|
@ -2280,8 +2262,7 @@ create_shm_buffer(int width,
|
|||
}
|
||||
|
||||
static void
|
||||
buffer_free(struct buffer *buffer)
|
||||
{
|
||||
buffer_free(struct buffer *buffer){
|
||||
if (buffer->wl_buffer) {
|
||||
wl_buffer_destroy(buffer->wl_buffer);
|
||||
munmap(buffer->data, buffer->data_size);
|
||||
|
|
@ -2292,8 +2273,7 @@ buffer_free(struct buffer *buffer)
|
|||
}
|
||||
|
||||
static void
|
||||
free_border_component(struct border_component *border_component)
|
||||
{
|
||||
free_border_component(struct border_component *border_component){
|
||||
if (border_component->wl_surface) {
|
||||
wl_subsurface_destroy(border_component->wl_subsurface);
|
||||
border_component->wl_subsurface = NULL;
|
||||
|
|
@ -3138,9 +3118,9 @@ libdecor_plugin_gtk_frame_commit(struct libdecor_frame *frame,
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
libdecor_plugin_gtk_frame_property_changed(struct libdecor_frame *frame)
|
||||
{
|
||||
libdecor_plugin_gtk_frame_property_changed(struct libdecor_frame *frame){
|
||||
bool redraw_needed = false;
|
||||
const char *new_title;
|
||||
|
||||
|
|
@ -3148,11 +3128,12 @@ libdecor_plugin_gtk_frame_property_changed(struct libdecor_frame *frame)
|
|||
* 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)) return;
|
||||
if (GTK_IS_WIDGET(frame->header)){
|
||||
|
||||
new_title = libdecor_frame_get_title(frame);
|
||||
if (!STREQL(frame->title, new_title))
|
||||
if (!STREQL(frame->title, new_title)){
|
||||
redraw_needed = true;
|
||||
}
|
||||
free(frame->title);
|
||||
frame->title = NULL;
|
||||
if (new_title){
|
||||
|
|
@ -3168,7 +3149,9 @@ libdecor_plugin_gtk_frame_property_changed(struct libdecor_frame *frame)
|
|||
draw_decoration(frame);
|
||||
libdecor_frame_toplevel_commit(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
update_component_focus(struct libdecor_frame *frame, struct wl_surface *surface, struct seat *seat){
|
||||
|
|
|
|||
|
|
@ -33,15 +33,6 @@
|
|||
|
||||
// config.h
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.2.2"
|
||||
|
||||
/* Plugin directiory path */
|
||||
#define LIBDECOR_PLUGIN_DIR "/usr/local/lib/x86_64-linux-gnu/libdecor/plugins-1"
|
||||
|
||||
/* Plugin API version */
|
||||
#define LIBDECOR_PLUGIN_API_VERSION 1
|
||||
|
||||
#define HAS_DBUS
|
||||
|
||||
/* #undef HAVE_MKOSTEMP */
|
||||
|
|
@ -381,10 +372,6 @@ void libdecor_frame_set_title(struct libdecor_frame *frame,
|
|||
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_set_capabilities(struct libdecor_frame *frame,
|
||||
enum libdecor_capabilities capabilities);
|
||||
void libdecor_frame_unset_capabilities(struct libdecor_frame *frame,
|
||||
enum libdecor_capabilities capabilities);
|
||||
bool libdecor_frame_has_capability(struct libdecor_frame *frame,
|
||||
enum libdecor_capabilities capability);
|
||||
void libdecor_frame_show_window_menu(struct libdecor_frame *frame,
|
||||
|
|
@ -481,7 +468,6 @@ void render_shadow(cairo_t *cr, cairo_surface_t *surface,
|
|||
bool libdecor_get_cursor_settings(char **theme, int *size);
|
||||
enum libdecor_color_scheme libdecor_get_color_scheme();
|
||||
|
||||
|
||||
// #include "os-compatibility.h"
|
||||
|
||||
int libdecor_os_create_anonymous_file(off_t size);
|
||||
|
|
@ -491,6 +477,8 @@ int libdecor_os_create_anonymous_file(off_t size);
|
|||
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);
|
||||
|
||||
//#include "plugins/gtk/libdecor-gtk.c"
|
||||
|
||||
|
||||
|
|
@ -507,11 +495,12 @@ static int libdecor_plugin_gtk_dispatch(int timeout);
|
|||
static void libdecor_plugin_gtk_set_handle_application_cursor(bool handle_cursor);
|
||||
static void libdecor_plugin_gtk_frame_free(struct libdecor_frame *frame);
|
||||
static void libdecor_plugin_gtk_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state, struct libdecor_configuration *configuration);
|
||||
static void libdecor_plugin_gtk_frame_property_changed(struct libdecor_frame *frame);
|
||||
static void libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, const char *seat_name);
|
||||
static void libdecor_plugin_gtk_frame_popup_ungrab(struct libdecor_frame *frame, const char *seat_name);
|
||||
static bool libdecor_plugin_gtk_frame_get_border_size(struct libdecor_frame *frame, struct libdecor_configuration *configuration, int *left, int *right, int *top, int *bottom);
|
||||
|
||||
static void draw_decoration(struct libdecor_frame *frame);
|
||||
|
||||
// digesting_libdecor
|
||||
|
||||
typedef struct Ctx{
|
||||
|
|
|
|||
Loading…
Reference in New Issue