From eea50d46a39c0b29ae6f33be25ef93f5b38a9d30 Mon Sep 17 00:00:00 2001 From: ethical_haquer <141518185+ethical-haquer@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:59:37 -0700 Subject: [PATCH 1/6] right-click menu placing #1429 --- porcupine/plugins/directory_tree.py | 2 +- porcupine/plugins/rightclick_menu.py | 2 +- porcupine/plugins/tab_closing.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/porcupine/plugins/directory_tree.py b/porcupine/plugins/directory_tree.py index b501f3cc0..05344df7d 100644 --- a/porcupine/plugins/directory_tree.py +++ b/porcupine/plugins/directory_tree.py @@ -431,7 +431,7 @@ def _on_right_click(self, event: tkinter.Event[DirectoryTree], menu_key: bool) - self._populate_contextmenu() if self.contextmenu.index("end") is not None: # Menu is not empty - self.contextmenu.tk_popup(menu_x, menu_y) + self.contextmenu.tk_popup(menu_x+15, menu_y) return "break" diff --git a/porcupine/plugins/rightclick_menu.py b/porcupine/plugins/rightclick_menu.py index 18f695f64..c4f406ec2 100644 --- a/porcupine/plugins/rightclick_menu.py +++ b/porcupine/plugins/rightclick_menu.py @@ -36,7 +36,7 @@ def create_menu() -> tkinter.Menu: def show_menu(event: tkinter.Event[tkinter.Misc]) -> None: rm = create_menu() - rm.tk_popup(event.x_root, event.y_root) + rm.tk_popup(event.x_root+10, event.y_root) rm.bind("", (lambda event: rm.after_idle(rm.destroy)), add=True) diff --git a/porcupine/plugins/tab_closing.py b/porcupine/plugins/tab_closing.py index 76f8059fc..67f1d6c5f 100644 --- a/porcupine/plugins/tab_closing.py +++ b/porcupine/plugins/tab_closing.py @@ -52,7 +52,7 @@ def show_menu(event: tkinter.Event[tabs.TabManager]) -> None: label="Close other tabs", command=partial(close_clicked_tab, event, what2close="others") ) - menu.tk_popup(event.x_root, event.y_root) + menu.tk_popup(event.x_root+15, event.y_root) menu.bind("", (lambda event: menu.after_idle(menu.destroy)), add=True) From 8daa2a3338435d5846cd91e84b307fefb713ced8 Mon Sep 17 00:00:00 2001 From: ethical_haquer <141518185+ethical-haquer@users.noreply.github.com> Date: Sat, 9 Mar 2024 22:01:18 -0700 Subject: [PATCH 2/6] right-click menu placing #1429 --- porcupine/plugins/directory_tree.py | 2 +- porcupine/plugins/tab_closing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/porcupine/plugins/directory_tree.py b/porcupine/plugins/directory_tree.py index 05344df7d..623c464df 100644 --- a/porcupine/plugins/directory_tree.py +++ b/porcupine/plugins/directory_tree.py @@ -431,7 +431,7 @@ def _on_right_click(self, event: tkinter.Event[DirectoryTree], menu_key: bool) - self._populate_contextmenu() if self.contextmenu.index("end") is not None: # Menu is not empty - self.contextmenu.tk_popup(menu_x+15, menu_y) + self.contextmenu.tk_popup(menu_x+10, menu_y) return "break" diff --git a/porcupine/plugins/tab_closing.py b/porcupine/plugins/tab_closing.py index 67f1d6c5f..b97afe9e2 100644 --- a/porcupine/plugins/tab_closing.py +++ b/porcupine/plugins/tab_closing.py @@ -52,7 +52,7 @@ def show_menu(event: tkinter.Event[tabs.TabManager]) -> None: label="Close other tabs", command=partial(close_clicked_tab, event, what2close="others") ) - menu.tk_popup(event.x_root+15, event.y_root) + menu.tk_popup(event.x_root+10, event.y_root) menu.bind("", (lambda event: menu.after_idle(menu.destroy)), add=True) From 3cb7e21d617d5ba0826d62520d3aeb0d1cc080c9 Mon Sep 17 00:00:00 2001 From: ethical-haquer Date: Sun, 10 Mar 2024 16:20:26 +0000 Subject: [PATCH 3/6] Run pycln, pyupgrade, black and isort --- porcupine/plugins/directory_tree.py | 2 +- porcupine/plugins/rightclick_menu.py | 2 +- porcupine/plugins/tab_closing.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/porcupine/plugins/directory_tree.py b/porcupine/plugins/directory_tree.py index 623c464df..f8fbdb176 100644 --- a/porcupine/plugins/directory_tree.py +++ b/porcupine/plugins/directory_tree.py @@ -431,7 +431,7 @@ def _on_right_click(self, event: tkinter.Event[DirectoryTree], menu_key: bool) - self._populate_contextmenu() if self.contextmenu.index("end") is not None: # Menu is not empty - self.contextmenu.tk_popup(menu_x+10, menu_y) + self.contextmenu.tk_popup(menu_x + 10, menu_y) return "break" diff --git a/porcupine/plugins/rightclick_menu.py b/porcupine/plugins/rightclick_menu.py index c4f406ec2..87f5b35e3 100644 --- a/porcupine/plugins/rightclick_menu.py +++ b/porcupine/plugins/rightclick_menu.py @@ -36,7 +36,7 @@ def create_menu() -> tkinter.Menu: def show_menu(event: tkinter.Event[tkinter.Misc]) -> None: rm = create_menu() - rm.tk_popup(event.x_root+10, event.y_root) + rm.tk_popup(event.x_root + 10, event.y_root) rm.bind("", (lambda event: rm.after_idle(rm.destroy)), add=True) diff --git a/porcupine/plugins/tab_closing.py b/porcupine/plugins/tab_closing.py index b97afe9e2..fd520a3e2 100644 --- a/porcupine/plugins/tab_closing.py +++ b/porcupine/plugins/tab_closing.py @@ -52,7 +52,7 @@ def show_menu(event: tkinter.Event[tabs.TabManager]) -> None: label="Close other tabs", command=partial(close_clicked_tab, event, what2close="others") ) - menu.tk_popup(event.x_root+10, event.y_root) + menu.tk_popup(event.x_root + 10, event.y_root) menu.bind("", (lambda event: menu.after_idle(menu.destroy)), add=True) From a84f73b749ca5d76c1cc0548b5c5b22f2ac8c13b Mon Sep 17 00:00:00 2001 From: ethical_haquer <141518185+ethical-haquer@users.noreply.github.com> Date: Sun, 10 Mar 2024 13:05:11 -0700 Subject: [PATCH 4/6] Correct right-click menu offset Added the missing implementation, and changed the offset to 1 instead of 10. --- porcupine/plugins/directory_tree.py | 2 +- porcupine/plugins/jump_to_definition.py | 3 ++- porcupine/plugins/rightclick_menu.py | 2 +- porcupine/plugins/tab_closing.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/porcupine/plugins/directory_tree.py b/porcupine/plugins/directory_tree.py index f8fbdb176..f1d181a7a 100644 --- a/porcupine/plugins/directory_tree.py +++ b/porcupine/plugins/directory_tree.py @@ -431,7 +431,7 @@ def _on_right_click(self, event: tkinter.Event[DirectoryTree], menu_key: bool) - self._populate_contextmenu() if self.contextmenu.index("end") is not None: # Menu is not empty - self.contextmenu.tk_popup(menu_x + 10, menu_y) + self.contextmenu.tk_popup(menu_x + 1, menu_y + 1) return "break" diff --git a/porcupine/plugins/jump_to_definition.py b/porcupine/plugins/jump_to_definition.py index 5405d1dd3..6017f99f4 100644 --- a/porcupine/plugins/jump_to_definition.py +++ b/porcupine/plugins/jump_to_definition.py @@ -67,9 +67,10 @@ def find_cursor_xy(textwidget: tkinter.Text) -> tuple[int, int]: # Make coords relative to top left corner of screen, not text widget left += textwidget.winfo_rootx() + top += textwidget.winfo_rooty() - return (left, top + height) + return (left + 1, top + height + 1) def receive_jump(event: utils.EventWithData) -> None: diff --git a/porcupine/plugins/rightclick_menu.py b/porcupine/plugins/rightclick_menu.py index 87f5b35e3..84a93a6d7 100644 --- a/porcupine/plugins/rightclick_menu.py +++ b/porcupine/plugins/rightclick_menu.py @@ -36,7 +36,7 @@ def create_menu() -> tkinter.Menu: def show_menu(event: tkinter.Event[tkinter.Misc]) -> None: rm = create_menu() - rm.tk_popup(event.x_root + 10, event.y_root) + rm.tk_popup(event.x_root + 1, event.y_root + 1) rm.bind("", (lambda event: rm.after_idle(rm.destroy)), add=True) diff --git a/porcupine/plugins/tab_closing.py b/porcupine/plugins/tab_closing.py index fd520a3e2..31745d046 100644 --- a/porcupine/plugins/tab_closing.py +++ b/porcupine/plugins/tab_closing.py @@ -52,7 +52,7 @@ def show_menu(event: tkinter.Event[tabs.TabManager]) -> None: label="Close other tabs", command=partial(close_clicked_tab, event, what2close="others") ) - menu.tk_popup(event.x_root + 10, event.y_root) + menu.tk_popup(event.x_root + 1, event.y_root + 1) menu.bind("", (lambda event: menu.after_idle(menu.destroy)), add=True) From 2a9774fed8b8a0f49e3e4af15bc89efa13155559 Mon Sep 17 00:00:00 2001 From: ethical-haquer Date: Sun, 10 Mar 2024 20:05:52 +0000 Subject: [PATCH 5/6] Run pycln, pyupgrade, black and isort --- porcupine/plugins/jump_to_definition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/porcupine/plugins/jump_to_definition.py b/porcupine/plugins/jump_to_definition.py index 6017f99f4..31bde2085 100644 --- a/porcupine/plugins/jump_to_definition.py +++ b/porcupine/plugins/jump_to_definition.py @@ -67,7 +67,7 @@ def find_cursor_xy(textwidget: tkinter.Text) -> tuple[int, int]: # Make coords relative to top left corner of screen, not text widget left += textwidget.winfo_rootx() - + top += textwidget.winfo_rooty() return (left + 1, top + height + 1) From 88466ac719971c15f3177809a9e05798bef73099 Mon Sep 17 00:00:00 2001 From: ethical_haquer <141518185+ethical-haquer@users.noreply.github.com> Date: Sun, 10 Mar 2024 17:04:00 -0700 Subject: [PATCH 6/6] Change offset back to 10 Fixes #1447 --- porcupine/plugins/directory_tree.py | 2 +- porcupine/plugins/jump_to_definition.py | 2 +- porcupine/plugins/rightclick_menu.py | 2 +- porcupine/plugins/tab_closing.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/porcupine/plugins/directory_tree.py b/porcupine/plugins/directory_tree.py index f1d181a7a..c09b5a94a 100644 --- a/porcupine/plugins/directory_tree.py +++ b/porcupine/plugins/directory_tree.py @@ -431,7 +431,7 @@ def _on_right_click(self, event: tkinter.Event[DirectoryTree], menu_key: bool) - self._populate_contextmenu() if self.contextmenu.index("end") is not None: # Menu is not empty - self.contextmenu.tk_popup(menu_x + 1, menu_y + 1) + self.contextmenu.tk_popup(menu_x + 10, menu_y + 10) return "break" diff --git a/porcupine/plugins/jump_to_definition.py b/porcupine/plugins/jump_to_definition.py index 6017f99f4..2a2e720c6 100644 --- a/porcupine/plugins/jump_to_definition.py +++ b/porcupine/plugins/jump_to_definition.py @@ -70,7 +70,7 @@ def find_cursor_xy(textwidget: tkinter.Text) -> tuple[int, int]: top += textwidget.winfo_rooty() - return (left + 1, top + height + 1) + return (left + 10, top + height + 10) def receive_jump(event: utils.EventWithData) -> None: diff --git a/porcupine/plugins/rightclick_menu.py b/porcupine/plugins/rightclick_menu.py index 84a93a6d7..6b11c4f87 100644 --- a/porcupine/plugins/rightclick_menu.py +++ b/porcupine/plugins/rightclick_menu.py @@ -36,7 +36,7 @@ def create_menu() -> tkinter.Menu: def show_menu(event: tkinter.Event[tkinter.Misc]) -> None: rm = create_menu() - rm.tk_popup(event.x_root + 1, event.y_root + 1) + rm.tk_popup(event.x_root + 10, event.y_root + 10) rm.bind("", (lambda event: rm.after_idle(rm.destroy)), add=True) diff --git a/porcupine/plugins/tab_closing.py b/porcupine/plugins/tab_closing.py index 31745d046..5500c5eaf 100644 --- a/porcupine/plugins/tab_closing.py +++ b/porcupine/plugins/tab_closing.py @@ -52,7 +52,7 @@ def show_menu(event: tkinter.Event[tabs.TabManager]) -> None: label="Close other tabs", command=partial(close_clicked_tab, event, what2close="others") ) - menu.tk_popup(event.x_root + 1, event.y_root + 1) + menu.tk_popup(event.x_root + 10, event.y_root + 10) menu.bind("", (lambda event: menu.after_idle(menu.destroy)), add=True)