Skip to content

Commit

Permalink
fix: Disable show on tab on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Amund211 committed May 29, 2023
1 parent 40d7c2b commit ddebc01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/prism/overlay/output/overlay/gui_components.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import logging
import platform
import sys
import tkinter as tk
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
Expand Down Expand Up @@ -131,6 +132,11 @@ def _on_press(self, pynput_key: "keyboard.Key | keyboard.KeyCode | None") -> Non
self.toggle()

def _start_listener(self) -> None:
if sys.platform == "darwin":
# pynput crashes when starting keyboard event listeners on mac
# I think it's due to an issue in pyobjc that leads to a segfault in libffi
return

try:
from pynput import keyboard
except Exception:
Expand Down
15 changes: 15 additions & 0 deletions src/prism/overlay/output/overlay/settings_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import logging
import string
import sys
import tkinter as tk
from typing import TYPE_CHECKING, Any, Literal, TypedDict

Expand Down Expand Up @@ -147,6 +148,20 @@ def __init__(self, parent: "SettingsPage") -> None:
self.check_for_updates_toggle.button,
)

if sys.platform == "darwin":
self.show_on_tab_toggle.button.config(state=tk.DISABLED)
self.show_on_tab_keybind_selector.button.config(state=tk.DISABLED)

show_on_tab_disabled_label = tk.Label(
self.frame,
text="SHOW ON TAB IS NOT AVAILABLE ON MAC",
font=("Consolas", "12"),
foreground="white",
background="black",
)
show_on_tab_disabled_label.grid(row=5, column=0, columnspan=2)
parent.make_widgets_scrollable(show_on_tab_disabled_label)

def set(
self,
autodenick_teammates: bool,
Expand Down
6 changes: 6 additions & 0 deletions src/prism/overlay/output/overlay/stats_overlay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
import threading
import tkinter as tk
from collections.abc import Callable
Expand Down Expand Up @@ -85,6 +86,11 @@ def __init__(
self.window.root.update_idletasks()

def setup_tab_listener(self, *, restart: bool = False) -> None:
if sys.platform == "darwin":
# pynput crashes when starting keyboard event listeners on mac
# I think it's due to an issue in pyobjc that leads to a segfault in libffi
return

if self.listener is not None:
if restart:
# Stop the current listener and start a new one
Expand Down

0 comments on commit ddebc01

Please sign in to comment.