Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable AppFocus and AppBlur in terminal emulators #4265

Merged
merged 15 commits into from
Mar 11, 2024

Commits on Mar 6, 2024

  1. Add support for XTerm FocusIn/FocusOut detection

    This enables support for receiving and handling FocusIn and FocusOut
    sequences, and turns then into AppFocus and AppBlur events.
    davep committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    775d1b4 View commit details
    Browse the repository at this point in the history
  2. Fix a copy/paste snafu

    davep committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    2f13d7f View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Configuration menu
    Copy the full SHA
    67b4d45 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b96bc9a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d28596a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    497dc54 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    68ac360 View commit details
    Browse the repository at this point in the history
  6. Only restore widget focus if the widget belongs to the current screen

    While the terminal window didn't have focus, anything can could happen. The
    widget could be removed, the screen could change, etc. So by the time
    AppFocus happens the widget might not be one to focus any more.
    
    Initially I was just making it the focused widget anyway and letting the
    focus-handling code do what it needed to do. Sending focus to a widget that
    isn't part of the DOM any more isn't exactly a breaking problem; but...
    
    One issue is that you can end up with App.focused saying that a widget is
    focused that isn't in the DOM any more. We don't want that. So here I'm a
    bit more defensive. This changes things so that we check that the widget's
    screen is still the screen that's in play. If the widget has been removed it
    won't have a parent and so can't find its screen. All of this means that if
    the screen has changed *or* if the widget has been removed, we're covered.
    davep committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    faea8fa View commit details
    Browse the repository at this point in the history
  7. Add tests for AppFocus and AppBlur

    These tests don't test the actual act of blurring or focusing the
    application (that's kind of hard to do in tests, really). What it does do is
    test that widget focus does the right thing after each of those app-level
    events.
    davep committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    8c18c9e View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f148e1f View commit details
    Browse the repository at this point in the history
  9. Update the docstrings of AppFocus and AppBlur

    Remove the text so say they're only for textual-web, but make it clear
    textual-web is supported, as are any other terminals that support the
    required sequences.
    davep committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    11fbf4f View commit details
    Browse the repository at this point in the history
  10. Update the ChangeLog

    Co-authored-by: TomJGooding <101601846+TomJGooding@users.noreply.github.com>
    Co-authored-by: Will McGugan <willmcgugan@gmail.com>
    3 people committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    a687be9 View commit details
    Browse the repository at this point in the history
  11. Don't restore focus on AppFocus if something has focus

    While the application is in an AppBlur state, it's possible that some code
    could have been running that updated what's focused. It doesn't make sense
    to have Textual itself override the dev's choice to have focus be somewhere
    else (perhaps the result of some long-running background process, that
    they've tabbed away from, and when they tab back they expect to be in a
    specific control).
    
    So here I tweak the code that restores the focused widget so that it only
    restores if it's still the case that nothing has focus.
    davep committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    4bb9b59 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Configuration menu
    Copy the full SHA
    02e9109 View commit details
    Browse the repository at this point in the history
  2. Add a snapshot test for AppBlur

    davep committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    c768beb View commit details
    Browse the repository at this point in the history