aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Walsh2020-01-09 16:36:11 +1100
committerJeff Walsh2020-11-24 12:24:39 +1100
commitc9e6b4486b6aee1e1011c81fdf0ef8270e237a15 (patch)
treecbe5a6dc5428d60dd2a736a17cfd0f46a2c73272 /src
parente021e233b4e96740dbc78bbc2717de6ee6e68291 (diff)
downloademacs-c9e6b4486b6aee1e1011c81fdf0ef8270e237a15.tar.gz
emacs-c9e6b4486b6aee1e1011c81fdf0ef8270e237a15.zip
Some work toward posframe on wayland
* src/pgtkterm.c (flip_cr_context, x_set_offset): update for new functionality (pgtk_set_window_size): remove dead code (x_set_parent_frame): cleanup trace code (pgtk_cr_update_surface_desired_size): add comment * src/pgtkmenu.c (Fmenu_or_popup_active_p): * src/pgtkfns.c (pgtk_frame_parm_handlers, Fx_create_frame): * src/gtkutil.c (xg_create_frame_widgets, x_wm_set_size_hint): * src/gtkutil.c (xg_create_frame_widgets): hacky GTK offsets taht will need better calculations Get parent frame's editor widget allocation for the offset Fix child-frame offsets for negative values Add some function comments around the new double context handling
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c19
-rw-r--r--src/pgtkfns.c20
-rw-r--r--src/pgtkmenu.c5
-rw-r--r--src/pgtkterm.c109
4 files changed, 120 insertions, 33 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8cdbe3e4ad5..6573205e7b9 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1353,6 +1353,7 @@ xg_create_frame_widgets (struct frame *f)
1353#ifndef HAVE_GTK3 1353#ifndef HAVE_GTK3
1354 GtkRcStyle *style; 1354 GtkRcStyle *style;
1355#endif 1355#endif
1356 GtkWindowType type = GTK_WINDOW_TOPLEVEL;
1356 char *title = 0; 1357 char *title = 0;
1357 1358
1358 PGTK_TRACE("xg_create_frame_widgets."); 1359 PGTK_TRACE("xg_create_frame_widgets.");
@@ -1366,9 +1367,17 @@ xg_create_frame_widgets (struct frame *f)
1366 } 1367 }
1367 else 1368 else
1368#endif 1369#endif
1369 wtop = gtk_window_new (GTK_WINDOW_TOPLEVEL); 1370
1370#ifdef HAVE_PGTK 1371#ifdef HAVE_PGTK
1371 gtk_widget_add_events(wtop, GDK_ALL_EVENTS_MASK); 1372 if (!NILP(f->parent_frame)){
1373 type = GTK_WINDOW_POPUP;
1374 }
1375#endif
1376
1377 wtop = gtk_window_new (type);
1378#ifdef HAVE_PGTK
1379 gtk_widget_add_events(wtop, GDK_ALL_EVENTS_MASK);
1380 gtk_window_set_hide_titlebar_when_maximized(GTK_WINDOW(wtop), TRUE);
1372#endif 1381#endif
1373 1382
1374 /* gtk_window_set_has_resize_grip is a Gtk+ 3.0 function but Ubuntu 1383 /* gtk_window_set_has_resize_grip is a Gtk+ 3.0 function but Ubuntu
@@ -1494,7 +1503,7 @@ xg_create_frame_widgets (struct frame *f)
1494#ifndef HAVE_PGTK 1503#ifndef HAVE_PGTK
1495 gtk_widget_realize (wfixed); 1504 gtk_widget_realize (wfixed);
1496#else 1505#else
1497 gtk_widget_show_all(wtop); 1506 // gtk_widget_show_all(wtop);
1498#endif 1507#endif
1499#ifndef HAVE_PGTK 1508#ifndef HAVE_PGTK
1500 FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed); 1509 FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed);
@@ -1712,10 +1721,8 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
1712 sizeof (size_hints)) != 0) 1721 sizeof (size_hints)) != 0)
1713 { 1722 {
1714 block_input (); 1723 block_input ();
1715#ifndef HAVE_PGTK
1716 gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 1724 gtk_window_set_geometry_hints (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1717 NULL, &size_hints, hint_flags); 1725 NULL, &size_hints, hint_flags);
1718#endif
1719 f->output_data.xp->size_hints = size_hints; 1726 f->output_data.xp->size_hints = size_hints;
1720 f->output_data.xp->hint_flags = hint_flags; 1727 f->output_data.xp->hint_flags = hint_flags;
1721 unblock_input (); 1728 unblock_input ();
diff --git a/src/pgtkfns.c b/src/pgtkfns.c
index 2c8f73ebcb6..e7ab20897b7 100644
--- a/src/pgtkfns.c
+++ b/src/pgtkfns.c
@@ -915,7 +915,7 @@ frame_parm_handler pgtk_frame_parm_handlers[] =
915 pgtk_set_tool_bar_position, 915 pgtk_set_tool_bar_position,
916 0, /* x_set_inhibit_double_buffering */ 916 0, /* x_set_inhibit_double_buffering */
917 x_set_undecorated, 917 x_set_undecorated,
918 0, /* x_set_parent_frame, */ 918 x_set_parent_frame,
919 x_set_skip_taskbar, 919 x_set_skip_taskbar,
920 x_set_no_focus_on_map, 920 x_set_no_focus_on_map,
921 x_set_no_accept_focus, 921 x_set_no_accept_focus,
@@ -1454,17 +1454,23 @@ This function is an internal primitive--use `make-frame' instead. */)
1454 gui_default_parameter (f, parms, Qalpha, Qnil, 1454 gui_default_parameter (f, parms, Qalpha, Qnil,
1455 "alpha", "Alpha", RES_TYPE_NUMBER); 1455 "alpha", "Alpha", RES_TYPE_NUMBER);
1456 1456
1457#if 0
1458 if (!NILP (parent_frame)) 1457 if (!NILP (parent_frame))
1459 { 1458 {
1460 struct frame *p = XFRAME (parent_frame); 1459 struct frame *p = XFRAME (parent_frame);
1461 1460
1462 block_input (); 1461 block_input ();
1463 XReparentWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 1462 PGTK_TRACE ("x_set_parent_frame x: %d, y: %d", f->left_pos, f->top_pos);
1464 FRAME_X_WINDOW (p), 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));
1465 unblock_input (); 1470 unblock_input ();
1466 } 1471 }
1467#endif 1472
1473 gtk_widget_show_all(FRAME_GTK_OUTER_WIDGET(f));
1468 1474
1469 gui_default_parameter (f, parms, Qno_focus_on_map, Qnil, 1475 gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
1470 NULL, NULL, RES_TYPE_BOOLEAN); 1476 NULL, NULL, RES_TYPE_BOOLEAN);
@@ -3153,7 +3159,7 @@ When using Gtk+ tooltips, the tooltip face is not used. */);
3153 DEFSYM (Qreverse_landscape, "reverse-landscape"); 3159 DEFSYM (Qreverse_landscape, "reverse-landscape");
3154} 3160}
3155 3161
3156#ifdef PGTK_DEBUG 3162
3157 3163
3158#include <stdarg.h> 3164#include <stdarg.h>
3159#include <time.h> 3165#include <time.h>
@@ -3175,7 +3181,7 @@ void pgtk_log(const char *file, int lineno, const char *fmt, ...)
3175 va_end(ap); 3181 va_end(ap);
3176 fputc('\n', stderr); 3182 fputc('\n', stderr);
3177} 3183}
3178 3184#ifdef PGTK_DEBUG
3179void pgtk_backtrace(const char *file, int lineno) 3185void pgtk_backtrace(const char *file, int lineno)
3180{ 3186{
3181 Lisp_Object bt = make_uninit_vector(10); 3187 Lisp_Object bt = make_uninit_vector(10);
diff --git a/src/pgtkmenu.c b/src/pgtkmenu.c
index bbe47ddad6b..9148504f8ee 100644
--- a/src/pgtkmenu.c
+++ b/src/pgtkmenu.c
@@ -457,9 +457,8 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_
457 doc: /* SKIP: real doc in xmenu.c. */) 457 doc: /* SKIP: real doc in xmenu.c. */)
458 (void) 458 (void)
459{ 459{
460 struct frame *f; 460 /* struct frame *f = SELECTED_FRAME (); */
461 f = SELECTED_FRAME (); 461 /* return (f->output_data.pgtk->menubar_active > 0) ? Qt : Qnil; */
462 // return (f->output_data.pgtk->menubar_active > 0) ? Qt : Qnil;
463 return Qnil; 462 return Qnil;
464} 463}
465 464
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 86ebf864a77..d7ac68c32f2 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
38 38
39#include "lisp.h" 39#include "lisp.h"
40#include "blockinput.h" 40#include "blockinput.h"
41#include "frame.h"
41#include "sysselect.h" 42#include "sysselect.h"
42#include "gtkutil.h" 43#include "gtkutil.h"
43#include "systime.h" 44#include "systime.h"
@@ -97,6 +98,13 @@ static void pgtk_clip_to_row (struct window *w, struct glyph_row *row,
97static struct frame * 98static struct frame *
98pgtk_any_window_to_frame (GdkWindow *window); 99pgtk_any_window_to_frame (GdkWindow *window);
99 100
101/*
102 * This is not a flip context in the same sense as gpu rendering
103 * scences, it only occurs when a new context was required due to a
104 * resize or other fundamental change. This is called when that
105 * context's surface has completed drawing
106 */
107
100static void flip_cr_context(struct frame *f) 108static void flip_cr_context(struct frame *f)
101{ 109{
102 PGTK_TRACE("flip_cr_context"); 110 PGTK_TRACE("flip_cr_context");
@@ -356,23 +364,36 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity)
356 External: Position the window 364 External: Position the window
357 -------------------------------------------------------------------------- */ 365 -------------------------------------------------------------------------- */
358{ 366{
359 /* not working on wayland. */
360
361 PGTK_TRACE("x_set_offset: %d,%d,%d.", xoff, yoff, change_gravity); 367 PGTK_TRACE("x_set_offset: %d,%d,%d.", xoff, yoff, change_gravity);
362 368
363 if (change_gravity > 0) 369 struct frame *parent = FRAME_PARENT_FRAME(f);
364 { 370 GtkAllocation a = {0};
365 PGTK_TRACE("x_set_offset: change_gravity > 0"); 371 if (change_gravity > 0) {
366 f->top_pos = yoff; 372 if (parent) {
373 /* determing the "height" of the titlebar, by finding the
374 location of the "emacsfixed" widget on the surface/window */
375 GtkWidget *w = FRAME_GTK_WIDGET(parent);
376 gtk_widget_get_allocation(w, &a);
377 }
378
379 f->size_hint_flags &= ~ (XNegative | YNegative);
380 /* if the value is negative, don't include the titlebar offset */
381 if (xoff < 0) {
382 f->size_hint_flags |= XNegative;
367 f->left_pos = xoff; 383 f->left_pos = xoff;
368 f->size_hint_flags &= ~ (XNegative | YNegative); 384 } else {
369 if (xoff < 0) 385 f->left_pos = xoff + a.x; //~25
370 f->size_hint_flags |= XNegative;
371 if (yoff < 0)
372 f->size_hint_flags |= YNegative;
373 f->win_gravity = NorthWestGravity;
374 } 386 }
375 387
388 if (yoff < 0){
389 f->size_hint_flags |= YNegative;
390 f->top_pos = yoff;
391 } else {
392 f->top_pos = yoff + a.y; //~60
393 }
394 f->win_gravity = NorthWestGravity;
395 }
396
376 x_calc_absolute_position (f); 397 x_calc_absolute_position (f);
377 398
378 block_input (); 399 block_input ();
@@ -431,8 +452,6 @@ pgtk_set_window_size (struct frame *f,
431 for (GtkWidget *w = FRAME_GTK_WIDGET(f); w != NULL; w = gtk_widget_get_parent(w)) { 452 for (GtkWidget *w = FRAME_GTK_WIDGET(f); w != NULL; w = gtk_widget_get_parent(w)) {
432 gint wd, hi; 453 gint wd, hi;
433 gtk_widget_get_size_request(w, &wd, &hi); 454 gtk_widget_get_size_request(w, &wd, &hi);
434 GtkAllocation alloc;
435 gtk_widget_get_allocation(w, &alloc);
436 } 455 }
437 456
438 f->output_data.pgtk->preferred_width = pixelwidth; 457 f->output_data.pgtk->preferred_width = pixelwidth;
@@ -673,6 +692,56 @@ x_display_pixel_width (struct pgtk_display_info *dpyinfo)
673 return gdk_screen_get_width(gscr); 692 return gdk_screen_get_width(gscr);
674} 693}
675 694
695void
696x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
697/* --------------------------------------------------------------------------
698 Set frame F's `parent-frame' parameter. If non-nil, make F a child
699 frame of the frame specified by that parameter. Technically, this
700 makes F's window-system window a child window of the parent frame's
701 window-system window. If nil, make F's window-system window a
702 top-level window--a child of its display's root window.
703
704 A child frame's `left' and `top' parameters specify positions
705 relative to the top-left corner of its parent frame's native
706 rectangle. On macOS moving a parent frame moves all its child
707 frames too, keeping their position relative to the parent
708 unaltered. When a parent frame is iconified or made invisible, its
709 child frames are made invisible. When a parent frame is deleted,
710 its child frames are deleted too.
711
712 Whether a child frame has a tool bar may be window-system or window
713 manager dependent. It's advisable to disable it via the frame
714 parameter settings.
715
716 Some window managers may not honor this parameter.
717 -------------------------------------------------------------------------- */
718{
719 struct frame *p = NULL;
720 PGTK_TRACE ("x_set_parent_frame x: %d, y: %d", f->left_pos, f->top_pos);
721
722 if (!NILP (new_value)
723 && (!FRAMEP (new_value)
724 || !FRAME_LIVE_P (p = XFRAME (new_value))
725 || !FRAME_PGTK_P (p)))
726 {
727 store_frame_param (f, Qparent_frame, old_value);
728 error ("Invalid specification of `parent-frame'");
729 }
730
731 if (p != FRAME_PARENT_FRAME (f)
732 && (p != NULL))
733 {
734 block_input ();
735 gtk_window_set_transient_for(FRAME_NATIVE_WINDOW(f), FRAME_NATIVE_WINDOW(p));
736 gtk_window_set_attached_to(FRAME_NATIVE_WINDOW(f), FRAME_GTK_WIDGET(p));
737 gtk_window_move(FRAME_NATIVE_WINDOW(f), f->left_pos, f->top_pos);
738 gtk_window_set_keep_above(FRAME_NATIVE_WINDOW(f), true);
739 unblock_input ();
740
741 fset_parent_frame (f, new_value);
742 }
743}
744
676 745
677void 746void
678x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) 747x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
@@ -2627,7 +2696,6 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
2627{ 2696{
2628 PGTK_TRACE("draw_window_cursor: %d, %d, %d, %d, %d, %d.", 2697 PGTK_TRACE("draw_window_cursor: %d, %d, %d, %d, %d, %d.",
2629 x, y, cursor_type, cursor_width, on_p, active_p); 2698 x, y, cursor_type, cursor_width, on_p, active_p);
2630
2631 if (on_p) 2699 if (on_p)
2632 { 2700 {
2633 w->phys_cursor_type = cursor_type; 2701 w->phys_cursor_type = cursor_type;
@@ -2676,6 +2744,7 @@ pgtk_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
2676 xic_set_preeditarea (w, x, y); 2744 xic_set_preeditarea (w, x, y);
2677#endif 2745#endif
2678 } 2746 }
2747
2679} 2748}
2680 2749
2681static void 2750static void
@@ -6538,10 +6607,16 @@ If set to a non-float value, there will be no wait at all. */);
6538 6607
6539 /* Tell Emacs about this window system. */ 6608 /* Tell Emacs about this window system. */
6540 Fprovide (Qpgtk, Qnil); 6609 Fprovide (Qpgtk, Qnil);
6541
6542} 6610}
6543 6611
6544 6612/* Cairo does not allow resizing a surface/context after it is
6613 * created, so we need to trash the old context, create a new context
6614 * on the next cr_clip_begin with the new dimensions and request a
6615 * re-draw.
6616 *
6617 * This Will leave the active context available to present on screen
6618 * until a redrawn frame is completed.
6619 */
6545void 6620void
6546pgtk_cr_update_surface_desired_size (struct frame *f, int width, int height) 6621pgtk_cr_update_surface_desired_size (struct frame *f, int width, int height)
6547{ 6622{