Re: Key press synthesis (for WebKitGTK)

2018-11-24 Thread Gergely Polonkai
On Sat, Nov 24, 2018 at 09:59:00AM +0100, Pierre Neidhardt wrote:
> Hi Gergely,
> 
> > So if you change your handler’s return type from `void` to `gboolean`
> > and return `FALSE` if the lisp thingy doesn’t understand your key, it
> > will be automatically propagated to the next handler (which, hopefully,
> > will insert your "a" key.
> 
> Thanks for the tip.  Indeed, I had missed that.
> 
> That said, the current situation is a little more complex because the call to
> Lisp is _asynchronous_.  Which means that I can only know the answer from the
> callback of the Soup request, not within the key-press handler.  In the Soup
> callback, the key press event is gone, hence my need to synthesize a new one.
> 
> I have successfully managed to synthesize a key-press event in a dummy 
> program.
> In the above scenario, it fails seemingly because it happens from within a 
> Soup
> callback.  Maybe Libsoup uses different threads, which causes threading issue
> when manipulating GTK widgets?

No, it shouldn’t, at least not by default.

How about you send the event as `user_data` to `soup_request_send()` (or 
whatever method you use) and send that to the webkit widget?

> 
> I also tried to synthesize the key event from another callback started in a
> g_idle_add() in the Soup callback, to no avail.
> g_main_context_invoke() seems to make no difference.
> 
> Thoughts?
> 
> -- 
> Pierre Neidhardt
> https://ambrevar.xyz/



-- 
You must believe in things that are not true.
Otherwise, how will they become?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Issue using the "gtk_widget_get_allocated_height" instruction

2018-11-24 Thread Luca Bacci via gtk-app-devel-list
If you really need, you can fake it by adding a menuitem with empty text
and setting it to invisible with gtk_widget_set_visible(menuitem, false);

Il giorno sab 24 nov 2018 alle ore 15:59 Luca Bacci 
ha scritto:

> Probably it's a consequence of this work for porting GtkMenuBar to use css
> gadgets internally:
> https://gitlab.gnome.org/GNOME/gtk/commit/700286c6
>
> You should be able to get the appropriate size if you add menu items to
> the bar, i.e. as long as the
> menubar is not empty you get the appropriate height with
> gtk_widget_get_allocated_height().
>
> Luca
>
> Il giorno ven 23 nov 2018 alle ore 16:23 Sébastien Le Roux <
> sebastien.ler...@ipcms.unistra.fr> ha scritto:
>
>> Dear all, thanks for reading this,
>> I recently updated GTK from 3.22.24 to 3.22.30 (Fedora 27 to Fedora 28
>> update),
>> doing so something changed in behaviour of the program I am working on
>> (C code) at runtime.
>>
>> In my program I create a GtkMenuBar widget, using the code:
>>
>> GtkWidget * win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>> GtkWidget * gl_vbox =  gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
>> gtk_container_add (GTK_CONTAINER (win), gl_vbox);
>> GtkWidget * menu_bar = gtk_menu_bar_new ();
>> gtk_box_pack_start (GTK_BOX (gl_box), menu_bar, FALSE, FALSE, 0);
>> GtkWidget * gl_area = gtk_gl_area_new ();
>> gtk_widget_set_size_request (gl_area, 100, 100);
>> gtk_box_pack_start (GTK_BOX (gl_box), gl_area, FALSE, FALSE, 0);
>>
>> Before my update I could get the height of the menu bar after drawing
>> using:
>>
>> int size = gtk_widget_get_allocated_height (menu_bar);
>>
>> After my update the value of size is always 1, before the update it was
>> around 15,
>> obviously this new 1 value is messing with my program, not to mention
>> that it is not
>> what I see on the my computer screen, could anyone explain to me what to
>> do the get
>> the proper size of the GtkMenuBar ? (the gtk_widget_get_size_request is
>> useless).
>>
>> Thanks for your help in the matter.
>>
>> Best regards.
>>
>> Sébastien Le Roux
>>
>> --
>> ===
>> Dr. Sébastien Le Roux
>> Ingénieur de Recherche CNRS
>> Institut de Physique et Chimie des Matériaux de Strasbourg
>> Département des Matériaux Organiques
>> 23, rue du Loess
>> BP 43
>> F-67034 Strasbourg Cedex 2, France
>> E-mail: sebastien.ler...@ipcms.unistra.fr
>> Webpage: http://www-ipcms.u-strasbg.fr/spip.php?article1771
>> RINGS project: http://rings-code.sourceforge.net/
>> ISAACS project: http://isaacs.sourceforge.net/
>> Fax:   +33 3 88 10 72 46
>> Phone: +33 3 88 10 71 62
>> ===
>>
>> ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Issue using the "gtk_widget_get_allocated_height" instruction

2018-11-24 Thread Luca Bacci via gtk-app-devel-list
Probably it's a consequence of this work for porting GtkMenuBar to use css
gadgets internally:
https://gitlab.gnome.org/GNOME/gtk/commit/700286c6

You should be able to get the appropriate size if you add menu items to the
bar, i.e. as long as the
menubar is not empty you get the appropriate height with
gtk_widget_get_allocated_height().

Luca

Il giorno ven 23 nov 2018 alle ore 16:23 Sébastien Le Roux <
sebastien.ler...@ipcms.unistra.fr> ha scritto:

> Dear all, thanks for reading this,
> I recently updated GTK from 3.22.24 to 3.22.30 (Fedora 27 to Fedora 28
> update),
> doing so something changed in behaviour of the program I am working on
> (C code) at runtime.
>
> In my program I create a GtkMenuBar widget, using the code:
>
> GtkWidget * win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> GtkWidget * gl_vbox =  gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
> gtk_container_add (GTK_CONTAINER (win), gl_vbox);
> GtkWidget * menu_bar = gtk_menu_bar_new ();
> gtk_box_pack_start (GTK_BOX (gl_box), menu_bar, FALSE, FALSE, 0);
> GtkWidget * gl_area = gtk_gl_area_new ();
> gtk_widget_set_size_request (gl_area, 100, 100);
> gtk_box_pack_start (GTK_BOX (gl_box), gl_area, FALSE, FALSE, 0);
>
> Before my update I could get the height of the menu bar after drawing
> using:
>
> int size = gtk_widget_get_allocated_height (menu_bar);
>
> After my update the value of size is always 1, before the update it was
> around 15,
> obviously this new 1 value is messing with my program, not to mention
> that it is not
> what I see on the my computer screen, could anyone explain to me what to
> do the get
> the proper size of the GtkMenuBar ? (the gtk_widget_get_size_request is
> useless).
>
> Thanks for your help in the matter.
>
> Best regards.
>
> Sébastien Le Roux
>
> --
> ===
> Dr. Sébastien Le Roux
> Ingénieur de Recherche CNRS
> Institut de Physique et Chimie des Matériaux de Strasbourg
> Département des Matériaux Organiques
> 23, rue du Loess
> BP 43
> F-67034 Strasbourg Cedex 2, France
> E-mail: sebastien.ler...@ipcms.unistra.fr
> Webpage: http://www-ipcms.u-strasbg.fr/spip.php?article1771
> RINGS project: http://rings-code.sourceforge.net/
> ISAACS project: http://isaacs.sourceforge.net/
> Fax:   +33 3 88 10 72 46
> Phone: +33 3 88 10 71 62
> ===
>
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Key press synthesis (for WebKitGTK)

2018-11-24 Thread Pierre Neidhardt
Hi Gergely,

> So if you change your handler’s return type from `void` to `gboolean`
> and return `FALSE` if the lisp thingy doesn’t understand your key, it
> will be automatically propagated to the next handler (which, hopefully,
> will insert your "a" key.

Thanks for the tip.  Indeed, I had missed that.

That said, the current situation is a little more complex because the call to
Lisp is _asynchronous_.  Which means that I can only know the answer from the
callback of the Soup request, not within the key-press handler.  In the Soup
callback, the key press event is gone, hence my need to synthesize a new one.

I have successfully managed to synthesize a key-press event in a dummy program.
In the above scenario, it fails seemingly because it happens from within a Soup
callback.  Maybe Libsoup uses different threads, which causes threading issue
when manipulating GTK widgets?

I also tried to synthesize the key event from another callback started in a
g_idle_add() in the Soup callback, to no avail.
g_main_context_invoke() seems to make no difference.

Thoughts?

-- 
Pierre Neidhardt
https://ambrevar.xyz/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list