[PATCH 53/66] kconfig: gconf: use size_allocate event handler

Masahiro Yamada posted 66 patches 3 months, 2 weeks ago
[PATCH 53/66] kconfig: gconf: use size_allocate event handler
Posted by Masahiro Yamada 3 months, 2 weeks ago
The size_request event is not available in GTK 3. Use the size_allocate
event handler instead.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/gconf.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index b86d54c222e3..6487d6a0dd9d 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -660,21 +660,13 @@ static void on_window1_destroy(GtkObject *object, gpointer user_data)
 	gtk_main_quit();
 }
 
-static void on_window1_size_request(GtkWidget *widget,
-				    GtkRequisition *requisition,
+static void on_window_size_allocate(GtkWidget *widget,
+				    GtkAllocation *allocation,
 				    gpointer user_data)
 {
-	static gint old_h;
-	gint w, h;
+	gint h;
 
-	if (widget->window == NULL)
-		gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
-	else
-		gdk_window_get_size(widget->window, &w, &h);
-
-	if (h == old_h)
-		return;
-	old_h = h;
+	h = allocation->height;
 
 	gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
 }
@@ -1000,8 +992,8 @@ static void init_main_window(const gchar *glade_file)
 	main_wnd = glade_xml_get_widget(xml, "window1");
 	g_signal_connect(main_wnd, "destroy",
 			 G_CALLBACK(on_window1_destroy), NULL);
-	g_signal_connect(main_wnd, "size_request",
-			 G_CALLBACK(on_window1_size_request), NULL);
+	g_signal_connect(main_wnd, "size_allocate",
+			 G_CALLBACK(on_window_size_allocate), NULL);
 	g_signal_connect(main_wnd, "delete_event",
 			 G_CALLBACK(on_window1_delete_event), NULL);
 
-- 
2.43.0
Re: [PATCH 53/66] kconfig: gconf: use size_allocate event handler
Posted by Masahiro Yamada 3 months, 1 week ago
On Wed, Jun 25, 2025 at 12:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The size_request event is not available in GTK 3. Use the size_allocate
> event handler instead.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

This has a regression - with this, we cannot move
the horizontal separator between in the right pane.

I will use the "configure-event" event instead.

>
>  scripts/kconfig/gconf.c | 20 ++++++--------------
>  1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
> index b86d54c222e3..6487d6a0dd9d 100644
> --- a/scripts/kconfig/gconf.c
> +++ b/scripts/kconfig/gconf.c
> @@ -660,21 +660,13 @@ static void on_window1_destroy(GtkObject *object, gpointer user_data)
>         gtk_main_quit();
>  }
>
> -static void on_window1_size_request(GtkWidget *widget,
> -                                   GtkRequisition *requisition,
> +static void on_window_size_allocate(GtkWidget *widget,
> +                                   GtkAllocation *allocation,
>                                     gpointer user_data)
>  {
> -       static gint old_h;
> -       gint w, h;
> +       gint h;
>
> -       if (widget->window == NULL)
> -               gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
> -       else
> -               gdk_window_get_size(widget->window, &w, &h);
> -
> -       if (h == old_h)
> -               return;
> -       old_h = h;
> +       h = allocation->height;
>
>         gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
>  }
> @@ -1000,8 +992,8 @@ static void init_main_window(const gchar *glade_file)
>         main_wnd = glade_xml_get_widget(xml, "window1");
>         g_signal_connect(main_wnd, "destroy",
>                          G_CALLBACK(on_window1_destroy), NULL);
> -       g_signal_connect(main_wnd, "size_request",
> -                        G_CALLBACK(on_window1_size_request), NULL);
> +       g_signal_connect(main_wnd, "size_allocate",
> +                        G_CALLBACK(on_window_size_allocate), NULL);
>         g_signal_connect(main_wnd, "delete_event",
>                          G_CALLBACK(on_window1_delete_event), NULL);
>
> --
> 2.43.0
>


-- 
Best Regards
Masahiro Yamada
Re: [PATCH 53/66] kconfig: gconf: use size_allocate event handler
Posted by Randy Dunlap 3 months, 1 week ago

On 6/29/25 10:56 AM, Masahiro Yamada wrote:
> On Wed, Jun 25, 2025 at 12:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>>
>> The size_request event is not available in GTK 3. Use the size_allocate
>> event handler instead.
>>
>> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>> ---
> 
> This has a regression - with this, we cannot move
> the horizontal separator between in the right pane.

Between the menu items and the message area?
That's what I see.

> 
> I will use the "configure-event" event instead.
> 
>>
>>  scripts/kconfig/gconf.c | 20 ++++++--------------
>>  1 file changed, 6 insertions(+), 14 deletions(-)
>>
>> diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
>> index b86d54c222e3..6487d6a0dd9d 100644
>> --- a/scripts/kconfig/gconf.c
>> +++ b/scripts/kconfig/gconf.c
>> @@ -660,21 +660,13 @@ static void on_window1_destroy(GtkObject *object, gpointer user_data)
>>         gtk_main_quit();
>>  }
>>
>> -static void on_window1_size_request(GtkWidget *widget,
>> -                                   GtkRequisition *requisition,
>> +static void on_window_size_allocate(GtkWidget *widget,
>> +                                   GtkAllocation *allocation,
>>                                     gpointer user_data)
>>  {
>> -       static gint old_h;
>> -       gint w, h;
>> +       gint h;
>>
>> -       if (widget->window == NULL)
>> -               gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
>> -       else
>> -               gdk_window_get_size(widget->window, &w, &h);
>> -
>> -       if (h == old_h)
>> -               return;
>> -       old_h = h;
>> +       h = allocation->height;
>>
>>         gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
>>  }
>> @@ -1000,8 +992,8 @@ static void init_main_window(const gchar *glade_file)
>>         main_wnd = glade_xml_get_widget(xml, "window1");
>>         g_signal_connect(main_wnd, "destroy",
>>                          G_CALLBACK(on_window1_destroy), NULL);
>> -       g_signal_connect(main_wnd, "size_request",
>> -                        G_CALLBACK(on_window1_size_request), NULL);
>> +       g_signal_connect(main_wnd, "size_allocate",
>> +                        G_CALLBACK(on_window_size_allocate), NULL);
>>         g_signal_connect(main_wnd, "delete_event",
>>                          G_CALLBACK(on_window1_delete_event), NULL);
>>
>> --
>> 2.43.0
>>
> 
> 

-- 
~Randy

Re: [PATCH 53/66] kconfig: gconf: use size_allocate event handler
Posted by Masahiro Yamada 3 months, 1 week ago
On Mon, Jun 30, 2025 at 2:23 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
>
>
> On 6/29/25 10:56 AM, Masahiro Yamada wrote:
> > On Wed, Jun 25, 2025 at 12:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >>
> >> The size_request event is not available in GTK 3. Use the size_allocate
> >> event handler instead.
> >>
> >> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >> ---
> >
> > This has a regression - with this, we cannot move
> > the horizontal separator between in the right pane.
>
> Between the menu items and the message area?
> That's what I see.

Right.

The horizontal bar between the menu tree and the
help message area.

Before this patch series, you can drag it up and down
using a mouse.

With v1 applied, you cannot move it.

This problem was fixed in v2.





-- 
Best Regards
Masahiro Yamada