#!/usr/bin/env python3
#
# Copyright (c) 2024 Stormux
# Copyright (c) 2010-2012 The Orca Team
# Copyright (c) 2012 Igalia, S.L.
# Copyright (c) 2005-2010 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA  02110-1301 USA.
#
# Forked from Orca screen reader.
# Cthulhu project: https://git.stormux.org/storm/cthulhu

"""Holds state that is shared among many modules.
"""

from typing import Optional, Any

__id__        = "$Id$"
__version__   = "$Revision$"
__date__      = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc." \
                "Copyright (c) 2010 Joanmarie Diggs, Mesar Hameed."
__license__   = "LGPL"

# NOTE: resist the temptation to do any imports here.  They can
# easily cause circular imports.
#
# We use forward references in type hints to avoid importing:
# - Atspi.Accessible for focus and window
# - Script for activeScript
# - InputEvent for lastInputEvent

# The Accessible that has visual focus.
#
locusOfFocus: Optional[Any] = None  # Actually: Optional[Atspi.Accessible]

# A pending focused object from a Cthulhu-owned window that should be used
# for keyboard-event context until the queued focus event is processed.
#
pendingSelfHostedFocus: Optional[Any] = None  # Actually: Optional[Atspi.Accessible]

# The currently active window.
#
activeWindow: Optional[Any] = None  # Actually: Optional[Atspi.Accessible]

# The latest compositor snapshot.
#
compositorSnapshot: Optional[Any] = None

# Whether AT-SPI churn should be paused for compositor transitions.
#
pauseAtspiChurn: bool = False

# The desktop-context token that should be prioritized next.
#
prioritizedDesktopContextToken: Optional[str] = None

# The currently active script.
#
activeScript: Optional[Any] = None  # Actually: Optional[Script]

# The currently active mode (focus, say all, flat review, etc.) and obj
activeMode: Optional[str] = None
objOfInterest: Optional[Any] = None  # Actually: Optional[Atspi.Accessible]

# Used to capture keys to redefine key bindings by the user.
#
capturingKeys: bool = False

# The last non-modifier key event received.
#
lastNonModifierKeyEvent: Optional[Any] = None  # Actually: Optional[KeyboardEvent]

# The InputEvent instance representing the last input event.  This is
# set each time a mouse, keyboard or braille event is received.
#
lastInputEvent: Optional[Any] = None  # Actually: Optional[InputEvent]

# Used to determine if the user wishes Cthulhu to pass the next command
# along to the current application rather than consuming it.
#
bypassNextCommand: bool = False

# The last searchQuery
#
searchQuery: Optional[str] = None

# Handle to the Cthulhu Preferences Glade GUI object.
#
cthulhuOS: Optional[Any] = None  # Actually: Optional[CthulhuSetupGUI]

# Set to True if the last key opened the preferences dialog
#
openingDialog: bool = False

# The AT-SPI device (needed for key grabs). Will be set to None if AT-SPI
# is too old to support the new device API.
#
device: Optional[Any] = None  # Actually: Optional[Atspi.Device]
