FLTK logo

[master] 5afd0bb - libdecor: pull upstream changes (a382710b on 28 apr 2022).

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 5afd0bb - libdecor: pull upstream changes (a382710b on 28 apr 2022). "ManoloFLTK" May 27, 2022  
 
commit 5afd0bb44aa3fff79fd7825e9ac97f991d3d1f39
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Fri May 27 10:58:23 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Fri May 27 10:58:23 2022 +0200

    libdecor: pull upstream changes (a382710b on 28 apr 2022).

 libdecor/demo/demo.c           | 25 ++++++++++++++++++++++++-
 libdecor/src/libdecor-plugin.h | 20 ++------------------
 libdecor/src/libdecor.c        | 34 +++++++++++++++++-----------------
 libdecor/src/libdecor.h        | 28 ++++++++++++++++++++++------
 4 files changed, 65 insertions(+), 42 deletions(-)

diff --git libdecor/demo/demo.c libdecor/demo/demo.c
index 85efcd7..ff285cc 100644
--- libdecor/demo/demo.c
+++ libdecor/demo/demo.c
@@ -166,6 +166,27 @@ static void
 redraw(struct window *window);
 
 static void
+constrain_content_size(const struct libdecor_frame *frame,
+		       int *width,
+		       int *height)
+{
+	int min_width, min_height, max_width, max_height;
+
+	libdecor_frame_get_min_content_size(frame, &min_width, &min_height);
+	libdecor_frame_get_max_content_size(frame, &max_width, &max_height);
+
+	if (min_width > 0)
+		*width = MAX(min_width, *width);
+	if (max_width > 0)
+		*width = MIN(*width, max_width);
+
+	if (min_height > 0)
+		*height = MAX(min_height, *height);
+	if (max_height > 0)
+		*height = MIN(*height, max_height);
+}
+
+static void
 resize(struct window *window, int width, int height)
 {
 	struct libdecor_state *state;
@@ -175,8 +196,10 @@ resize(struct window *window, int width, int height)
 		return;
 	}
 
+	constrain_content_size(window->frame, &width, &height);
+
 	/* commit changes to decorations */
-	state = libdecor_state_new( width, height);
+	state = libdecor_state_new(width, height);
 	libdecor_frame_commit(window->frame, state, NULL);
 	libdecor_state_free(state);
 	/* force redraw of content and commit */
diff --git libdecor/src/libdecor-plugin.h libdecor/src/libdecor-plugin.h
index eba41d4..e91ee2b 100644
--- libdecor/src/libdecor-plugin.h
+++ libdecor/src/libdecor-plugin.h
@@ -160,10 +160,10 @@ libdecor_notify_plugin_error(struct libdecor *context,
 			     ...);
 
 int
-libdecor_state_get_content_width (struct libdecor_state *state);
+libdecor_state_get_content_width(struct libdecor_state *state);
 
 int
-libdecor_state_get_content_height (struct libdecor_state *state);
+libdecor_state_get_content_height(struct libdecor_state *state);
 
 enum libdecor_window_state
 libdecor_state_get_window_state(struct libdecor_state *state);
@@ -176,20 +176,4 @@ libdecor_plugin_init(struct libdecor_plugin *plugin,
 void
 libdecor_plugin_release(struct libdecor_plugin *plugin);
 
-/*
- * Get the min content size as set before with libdecor_frame_set_min_content_size().
- */
-void
-libdecor_frame_get_min_content_size(struct libdecor_frame *frame,
-				    int *pcontent_width,
-				    int *pcontent_height);
-
-/*
- * Get the max content size as set before with libdecor_frame_set_max_content_size().
- */
-void
-libdecor_frame_get_max_content_size(struct libdecor_frame *frame,
-				    int *pcontent_width,
-				    int *pcontent_height);
-
 #endif /* LIBDECOR_PLUGIN_H */
diff --git libdecor/src/libdecor.c libdecor/src/libdecor.c
index 9fedf1a..c4b5b1e 100644
--- libdecor/src/libdecor.c
+++ libdecor/src/libdecor.c
@@ -839,47 +839,47 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame,
 }
 
 LIBDECOR_EXPORT void
-libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
+libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
 				    int content_width,
 				    int content_height)
 {
 	struct libdecor_frame_private *frame_priv = frame->priv;
 
-	frame_priv->state.content_limits.max_width = content_width;
-	frame_priv->state.content_limits.max_height = content_height;
+	frame_priv->state.content_limits.min_width = content_width;
+	frame_priv->state.content_limits.min_height = content_height;
 }
 
 LIBDECOR_EXPORT void
-libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
+libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
 				    int content_width,
 				    int content_height)
 {
 	struct libdecor_frame_private *frame_priv = frame->priv;
 
-	frame_priv->state.content_limits.min_width = content_width;
-	frame_priv->state.content_limits.min_height = content_height;
+	frame_priv->state.content_limits.max_width = content_width;
+	frame_priv->state.content_limits.max_height = content_height;
 }
 
 LIBDECOR_EXPORT void
-libdecor_frame_get_min_content_size(struct libdecor_frame *frame,
-				    int *pcontent_width,
-				    int *pcontent_height)
+libdecor_frame_get_min_content_size(const struct libdecor_frame *frame,
+				    int *content_width,
+				    int *content_height)
 {
 	struct libdecor_frame_private *frame_priv = frame->priv;
 
-	*pcontent_width = frame_priv->state.content_limits.min_width;
-	*pcontent_height = frame_priv->state.content_limits.min_height;
+	*content_width = frame_priv->state.content_limits.min_width;
+	*content_height = frame_priv->state.content_limits.min_height;
 }
 
 LIBDECOR_EXPORT void
-libdecor_frame_get_max_content_size(struct libdecor_frame *frame,
-				    int *pcontent_width,
-				    int *pcontent_height)
+libdecor_frame_get_max_content_size(const struct libdecor_frame *frame,
+				    int *content_width,
+				    int *content_height)
 {
 	struct libdecor_frame_private *frame_priv = frame->priv;
 
-	*pcontent_width = frame_priv->state.content_limits.max_width;
-	*pcontent_height = frame_priv->state.content_limits.max_height;
+	*content_width = frame_priv->state.content_limits.max_width;
+	*content_height = frame_priv->state.content_limits.max_height;
 }
 
 LIBDECOR_EXPORT enum libdecor_capabilities
@@ -1495,7 +1495,7 @@ init_plugins(struct libdecor *context)
 				if (!de)
 					break;
 
-				plugin_loader = load_plugin_loader(context, 
+				plugin_loader = load_plugin_loader(context,
 								   plugin_dir,
 								   de->d_name);
 				if (!plugin_loader)
diff --git libdecor/src/libdecor.h libdecor/src/libdecor.h
index 214a10c..d3ccea1 100644
--- libdecor/src/libdecor.h
+++ libdecor/src/libdecor.h
@@ -347,26 +347,42 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame,
 				    int *frame_y);
 
 /**
- * Set the max content size.
+ * Set the min content size.
  *
- * This translates roughly to xdg_toplevel_set_max_size().
+ * This translates roughly to xdg_toplevel_set_min_size().
  */
 void
-libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
+libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
 				    int content_width,
 				    int content_height);
 
 /**
- * Set the min content size.
+ * Set the max content size.
  *
- * This translates roughly to xdg_toplevel_set_min_size().
+ * This translates roughly to xdg_toplevel_set_max_size().
  */
 void
-libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
+libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
 				    int content_width,
 				    int content_height);
 
 /**
+ * Get the min content size.
+ */
+void
+libdecor_frame_get_min_content_size(const struct libdecor_frame *frame,
+				    int *content_width,
+				    int *content_height);
+
+/**
+ * Get the max content size.
+ */
+void
+libdecor_frame_get_max_content_size(const struct libdecor_frame *frame,
+				    int *content_width,
+				    int *content_height);
+
+/**
  * Initiate an interactive resize.
  *
  * This roughly translates to xdg_toplevel_resize().
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.