@@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
3838
3939#include "lisp.h"
4040#include "blockinput.h"
41+ #include "frame.h"
4142#include "sysselect.h"
4243#include "gtkutil.h"
4344#include "systime.h"
@@ -355,22 +356,35 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity)
355356 External: Position the window
356357 -------------------------------------------------------------------------- */
357358{
358- /* not working on wayland. */
359-
360359 PGTK_TRACE ("x_set_offset: %d,%d,%d." , xoff , yoff , change_gravity );
361360
362- if (change_gravity > 0 )
363- {
364- PGTK_TRACE ("x_set_offset: change_gravity > 0" );
365- f -> top_pos = yoff ;
361+ struct frame * parent = FRAME_PARENT_FRAME (f );
362+ GtkAllocation a = {0 };
363+ if (change_gravity > 0 ) {
364+ if (parent ) {
365+ /* determing the "height" of the titlebar, by finding the
366+ location of the "emacsfixed" widget on the surface/window */
367+ GtkWidget * w = FRAME_GTK_WIDGET (parent );
368+ gtk_widget_get_allocation (w , & a );
369+ }
370+
371+ f -> size_hint_flags &= ~ (XNegative | YNegative );
372+ /* if the value is negative, don't include the titlebar offset */
373+ if (xoff < 0 ) {
374+ f -> size_hint_flags |= XNegative ;
366375 f -> left_pos = xoff ;
367- f -> size_hint_flags &= ~ (XNegative | YNegative );
368- if (xoff < 0 )
369- f -> size_hint_flags |= XNegative ;
370- if (yoff < 0 )
371- f -> size_hint_flags |= YNegative ;
372- f -> win_gravity = NorthWestGravity ;
376+ } else {
377+ f -> left_pos = xoff + a .x ; //~25
378+ }
379+
380+ if (yoff < 0 ){
381+ f -> size_hint_flags |= YNegative ;
382+ f -> top_pos = yoff ;
383+ } else {
384+ f -> top_pos = yoff + a .y ; //~60
373385 }
386+ f -> win_gravity = NorthWestGravity ;
387+ }
374388
375389 x_calc_absolute_position (f );
376390
@@ -430,8 +444,6 @@ pgtk_set_window_size (struct frame *f,
430444 for (GtkWidget * w = FRAME_GTK_WIDGET (f ); w != NULL ; w = gtk_widget_get_parent (w )) {
431445 gint wd , hi ;
432446 gtk_widget_get_size_request (w , & wd , & hi );
433- GtkAllocation alloc ;
434- gtk_widget_get_allocation (w , & alloc );
435447 }
436448
437449 f -> output_data .pgtk -> preferred_width = pixelwidth ;
@@ -697,13 +709,7 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
697709 -------------------------------------------------------------------------- */
698710{
699711 struct frame * p = NULL ;
700- int width = 0 , height = 0 ;
701-
702- PGTK_TRACE ("x_set_parent_frame x: %d, y: %d, size: %d x %d" , f -> left_pos , f -> top_pos , width , height );
703- gtk_window_get_size (FRAME_NATIVE_WINDOW (f ), & width , & height );
704-
705-
706- PGTK_TRACE ("x_set_parent_frame x: %d, y: %d, size: %d x %d" , f -> left_pos , f -> top_pos , width , height );
712+ PGTK_TRACE ("x_set_parent_frame x: %d, y: %d" , f -> left_pos , f -> top_pos );
707713
708714 if (!NILP (new_value )
709715 && (!FRAMEP (new_value )
@@ -722,7 +728,6 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
722728 gtk_window_set_attached_to (FRAME_NATIVE_WINDOW (f ), FRAME_GTK_WIDGET (p ));
723729 gtk_window_move (FRAME_NATIVE_WINDOW (f ), f -> left_pos , f -> top_pos );
724730 gtk_window_set_keep_above (FRAME_NATIVE_WINDOW (f ), true);
725- //fill this in
726731 unblock_input ();
727732
728733 fset_parent_frame (f , new_value );
@@ -815,8 +820,8 @@ pgtk_initialize_display_info (struct pgtk_display_info *dpyinfo)
815820 Initialize global info and storage for display.
816821 -------------------------------------------------------------------------- */
817822{
818- dpyinfo -> resx = 72.27 ; /* used 75.0, but this makes pt == pixel, expected */
819- dpyinfo -> resy = 72.27 ;
823+ dpyinfo -> resx = 96 ;
824+ dpyinfo -> resy = 96 ;
820825 dpyinfo -> color_p = 1 ;
821826 dpyinfo -> n_planes = 32 ;
822827 dpyinfo -> root_window = 42 ; /* a placeholder.. */
@@ -2683,7 +2688,6 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
26832688{
26842689 PGTK_TRACE ("draw_window_cursor: %d, %d, %d, %d, %d, %d." ,
26852690 x , y , cursor_type , cursor_width , on_p , active_p );
2686-
26872691 if (on_p )
26882692 {
26892693 w -> phys_cursor_type = cursor_type ;
@@ -2732,6 +2736,7 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
27322736 xic_set_preeditarea (w , x , y );
27332737#endif
27342738 }
2739+
27352740}
27362741
27372742static void
@@ -5390,7 +5395,7 @@ static gboolean window_state_event(GtkWidget *widget, GdkEvent *event, gpointer
53905395
53915396 if (inev .ie .kind != NO_EVENT )
53925397 evq_enqueue (& inev );
5393- return TRUE ;
5398+ return FALSE ;
53945399}
53955400
53965401static gboolean delete_event (GtkWidget * widget , GdkEvent * event , gpointer * user_data )
@@ -6285,7 +6290,13 @@ pgtk_term_init (Lisp_Object display_name, char *resource_name)
62856290
62866291 {
62876292 GdkScreen * gscr = gdk_display_get_default_screen (dpyinfo -> gdpy );
6288- gdouble dpi = gdk_screen_get_resolution (gscr );
6293+
6294+ GSettings * set = g_settings_new ("org.gnome.desktop.interface" );
6295+ gdouble x = g_settings_get_double (set ,"text-scaling-factor" );
6296+ gdouble dpi = 0 ;
6297+
6298+ dpi = 96.0 * x ;
6299+ gdk_screen_set_resolution (gscr , dpi );
62896300 dpyinfo -> resx = dpi ;
62906301 dpyinfo -> resy = dpi ;
62916302 }
0 commit comments