unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: martin rudalics <rudalics@gmx.at>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,
	"43672@debbugs.gnu.org" <43672@debbugs.gnu.org>
Subject: bug#43672: 28.0.50; select-frame-set-input-focus does not set focus first time called
Date: Sat, 17 Oct 2020 23:51:16 +0200	[thread overview]
Message-ID: <VI1PR06MB4526CF234B65ED5EE0EFD6F496000@VI1PR06MB4526.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <fb255f33-cdfa-7a30-f8e0-d3272002a6e0@gmx.at> (martin rudalics's message of "Thu, 1 Oct 2020 10:39:15 +0200")

[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]

martin rudalics <rudalics@gmx.at> writes:

>> I am sorry för the confusion, I was just to fast typing. Yes, you
>> understand me correctly. It works correctly in emacsclient; not
>> correctly when I run Emacs as a standalone process, either with -Q
>> flag or without.
>
> Then please with emacs -Q try the simpler
>
> (defvar child-frame nil)
>
> (defun make-child-frame ()
>   (interactive)
>   (setq child-frame
>     (make-frame `((parent-frame . ,(selected-frame))
>               (left . 10)
>               (top . 10)
>               (width . 20)
>               (height . 10))))
>   (select-frame-set-input-focus child-frame))
>
> (defun delete-child-frame ()
>   (interactive)
>   (delete-frame child-frame))
>
> and tell us whether the child frame gets focus.
>
> martin
Hello Martin,

sorry for being a bit late with this. I have tested and it was very
strange, so I realized I need more time to play with it.

Here is how I got it:

If I pass parent in the frame-params list to make-frame, then all is
grandy-dandy; but if I don't then the behaviour is as following:

If parent is set after creation; the frame will be reparented correctly
and appear at correct place on the screen, but it won't switch focus.

If parent is not set after the creation; the frame will switch focus,
buf it will of course appear somewhere at the screen (absolute
coordinates I guess).

I have tested only emacsclient. I hope it helps.

I have attached a simplified test file:


[-- Attachment #2: poorman-menu.el --]
[-- Type: text/plain, Size: 3436 bytes --]

;;; poorman-menu.el ---                                 -*- lexical-binding: t; -*-

;; Copyright (C) 2020  Arthur Miller

;; Author: Arthur Miller <arthur.miller@live.com>
;; Keywords: 

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; 

;;; Code:

(defvar pm-menu-dir )

(defun pm-load-menu (menuname)
  (with-current-buffer (get-buffer-create menuname)
    (insert-file-contents (concat pm-menu-dir menuname))
    (not-modified)
    (current-buffer)))

(defun pm-menutest ()
  (interactive)
  (let ((test (get-buffer "testmenu")))
    (when (not test)
      (with-current-buffer (get-buffer-create "testmenu")
        (insert "one")
        (newline)
        (insert "two")
        (newline)
        (insert "three")
        (newline)
        (insert "four"))))
  (pm-show-at-cursor "testmenu"))

(defun pm-unload-menu (menuname)
  (let ((b (get-buffer menuname)))
  (if b (kill-buffer b))))

(define-minor-mode pm-minor-mode
  ""
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map (kbd "C-g")   'pm-quit)
            map))

(defun pm-hide-menu (menuframe)
      (make-frame-invisible))

(defun pm-quit ()
  (interactive)
  (let ((b (window-buffer)))
        (when b (kill-buffer b)))
  (delete-frame (selected-frame)))

(defun pm-show-at-point (menuname)
  (let ((pos (pos-visible-in-window-p nil nil t)))
      (pm-create-menu menuname (nth 0 pos) (nth 1 pos))))

(defun pm-show-at-cursor (menuname)
  (let ((pos (mouse-pixel-position)))
    (if pos
        (pm-create-menu menuname (cadr pos) (cddr pos))
      (pm-show-at-point (menuname)))))
    
(defun pm-create-menu (menuname x y)
  "Displays a menu MENUNAME as a vertical menu.
If x and y are given, the menu will be shown at those coordinates. Default is
  current cursor position. If cursor is outside an Emacs frame window is
  displayed at active point."

  (when (not (get-buffer menuname))
    (pm-load-menu menuname))
  
  (with-current-buffer (get-buffer menuname)
    (pm-minor-mode)

    (setq tab-line-format nil)
    (setq mode-line-format nil)
    
    (let ((parent (selected-frame))
          (child-frame

           ;; (make-frame `((parent-frame . ,(selected-frame))
           ;;               (left . ,x)
           ;;               (top . ,y)
           ;;               (width . 20)
           ;;               (height . 10)))))
           ;; (select-frame-set-input-focus child-frame)))

           (make-frame `((visible . nil)
                         ;;(parent-frame . ,(selected-frame))
                         (undecorated . nil)))))
      
          (fit-frame-to-buffer child-frame)
          (set-frame-position child-frame x y)
          (set-frame-parameter child-frame 'parent-frame parent)
          (select-frame-set-input-focus child-frame)))
  )

(provide 'poorman-menu)

;;; pure-menu.el ends here

  reply	other threads:[~2020-10-17 21:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 13:34 bug#43672: 28.0.50; select-frame-set-input-focus does not set focus first time called Arthur Miller
2020-09-28 13:57 ` Lars Ingebrigtsen
2020-09-28 14:11   ` Arthur Miller
2020-09-28 14:14     ` Lars Ingebrigtsen
2020-09-28 14:40       ` Arthur Miller
2020-09-29 13:46         ` Lars Ingebrigtsen
2020-09-29 14:34           ` martin rudalics
2020-09-29 14:44             ` Lars Ingebrigtsen
2020-09-29 20:43             ` Arthur Miller
2020-09-30  8:15               ` martin rudalics
2020-09-30  9:31                 ` Arthur Miller
2020-09-30 17:33                   ` martin rudalics
2020-09-30 17:36                     ` arthur miller
2020-10-01  8:39                       ` martin rudalics
2020-10-17 21:51                         ` Arthur Miller [this message]
2020-10-18  7:56                           ` martin rudalics
2020-10-18 14:10                             ` Arthur Miller
2020-10-20  7:20                               ` martin rudalics
2022-04-21 14:02                               ` Lars Ingebrigtsen
2020-09-28 17:59   ` martin rudalics
2020-09-28 17:59 ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR06MB4526CF234B65ED5EE0EFD6F496000@VI1PR06MB4526.eurprd06.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=43672@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).