Skip to content

Commit f9eb318

Browse files
author
Yuuki Harano
authored
Merge pull request emacs-mirror#15 from fejfighter/pgtk-childframe
Pgtk childframe support
2 parents ce60c1c + ca590ba commit f9eb318

File tree

5 files changed

+65
-41
lines changed

5 files changed

+65
-41
lines changed

src/ftcrfont.c

+2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
131131
filename = XCAR (val);
132132
size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
133133
if (size == 0)
134+
{
134135
size = pixel_size;
136+
}
135137

136138
block_input ();
137139

src/gtkutil.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ xg_create_frame_widgets (struct frame *f)
13261326
#ifndef HAVE_GTK3
13271327
GtkRcStyle *style;
13281328
#endif
1329+
GtkWindowType type = GTK_WINDOW_TOPLEVEL;
13291330
char *title = 0;
13301331

13311332
PGTK_TRACE("xg_create_frame_widgets.");
@@ -1339,9 +1340,16 @@ xg_create_frame_widgets (struct frame *f)
13391340
}
13401341
else
13411342
#endif
1342-
wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1343+
13431344
#ifdef HAVE_PGTK
1344-
gtk_widget_add_events(wtop, GDK_ALL_EVENTS_MASK);
1345+
if (!NILP(f->parent_frame)){
1346+
type = GTK_WINDOW_POPUP;
1347+
}
1348+
#endif
1349+
1350+
wtop = gtk_window_new (type);
1351+
#ifdef HAVE_PGTK
1352+
gtk_widget_add_events(wtop, GDK_ALL_EVENTS_MASK);
13451353
#endif
13461354

13471355
/* gtk_window_set_has_resize_grip is a Gtk+ 3.0 function but Ubuntu
@@ -1467,7 +1475,7 @@ xg_create_frame_widgets (struct frame *f)
14671475
#ifndef HAVE_PGTK
14681476
gtk_widget_realize (wfixed);
14691477
#else
1470-
gtk_widget_show_all(wtop);
1478+
// gtk_widget_show_all(wtop);
14711479
#endif
14721480
#ifndef HAVE_PGTK
14731481
FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed);
@@ -1684,10 +1692,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
16841692
sizeof (size_hints)) != 0)
16851693
{
16861694
block_input ();
1687-
#ifndef HAVE_PGTK
16881695
gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
16891696
NULL, &size_hints, hint_flags);
1690-
#endif
16911697
f->output_data.xp->size_hints = size_hints;
16921698
f->output_data.xp->hint_flags = hint_flags;
16931699
unblock_input ();

src/pgtkfns.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ frame_parm_handler pgtk_frame_parm_handlers[] =
915915
pgtk_set_tool_bar_position,
916916
0, /* x_set_inhibit_double_buffering */
917917
x_set_undecorated,
918-
0, /* x_set_parent_frame, */
918+
x_set_parent_frame,
919919
x_set_skip_taskbar,
920920
x_set_no_focus_on_map,
921921
x_set_no_accept_focus,
@@ -1454,17 +1454,23 @@ This function is an internal primitive--use `make-frame' instead. */)
14541454
gui_default_parameter (f, parms, Qalpha, Qnil,
14551455
"alpha", "Alpha", RES_TYPE_NUMBER);
14561456

1457-
#if 0
14581457
if (!NILP (parent_frame))
14591458
{
14601459
struct frame *p = XFRAME (parent_frame);
14611460

14621461
block_input ();
1463-
XReparentWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
1464-
FRAME_X_WINDOW (p), f->left_pos, f->top_pos);
1462+
PGTK_TRACE ("x_set_parent_frame x: %d, y: %d", f->left_pos, f->top_pos);
1463+
gtk_window_set_transient_for(GTK_WINDOW(FRAME_GTK_OUTER_WIDGET(f)),
1464+
GTK_WINDOW(FRAME_GTK_OUTER_WIDGET(p)));
1465+
gtk_window_set_attached_to(GTK_WINDOW(FRAME_GTK_OUTER_WIDGET(f)),
1466+
FRAME_GTK_WIDGET(p));
1467+
gtk_window_set_destroy_with_parent(GTK_WINDOW(FRAME_GTK_OUTER_WIDGET(f)),
1468+
TRUE);
1469+
gtk_widget_show_all(FRAME_GTK_OUTER_WIDGET(f));
14651470
unblock_input ();
14661471
}
1467-
#endif
1472+
1473+
gtk_widget_show_all(FRAME_GTK_OUTER_WIDGET(f));
14681474

14691475
gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
14701476
NULL, NULL, RES_TYPE_BOOLEAN);
@@ -3158,8 +3164,8 @@ When using Gtk+ tooltips, the tooltip face is not used. */);
31583164
DEFSYM (Qreverse_landscape, "reverse-landscape");
31593165
}
31603166

3161-
#ifdef PGTK_DEBUG
31623167

3168+
#ifdef PGTK_DEBUG
31633169
#include <stdarg.h>
31643170
#include <time.h>
31653171
void pgtk_log(const char *file, int lineno, const char *fmt, ...)

src/pgtkmenu.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,8 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_
458458
doc: /* SKIP: real doc in xmenu.c. */)
459459
(void)
460460
{
461-
struct frame *f;
462-
f = SELECTED_FRAME ();
463-
// return (f->output_data.pgtk->menubar_active > 0) ? Qt : Qnil;
461+
/* struct frame *f = SELECTED_FRAME (); */
462+
/* return (f->output_data.pgtk->menubar_active > 0) ? Qt : Qnil; */
464463
return Qnil;
465464
}
466465

src/pgtkterm.c

+38-27
Original file line numberDiff line numberDiff line change
@@ -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

27372742
static 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

53965401
static 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

Comments
 (0)