Keyboard Focus Bug On Linux


#1

When grabbing keyboard focus with a JUCE component in Linux, it seems to take focus away from other applications. On macOS and Windows these calls only take focus away from the other JUCE components in our plugins.

Here’s a PIP for quick testing. We ran on Debian 9 with a text editor open. Every timerCallback() the text editor app had focus taken away from it but remained in the foreground, which was not the same behavior as running on my macOS machine.

/*******************************************************************************
 The block below describes the properties of this PIP. A PIP is a short snippet
 of code that can be read by the Projucer and used to generate a JUCE project.

 BEGIN_JUCE_PIP_METADATA

  name:             UnfocusTest

  dependencies:     juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
  exporters:        linux_make

  type:             Component
  mainClass:        MyComponent

 END_JUCE_PIP_METADATA

*******************************************************************************/

#pragma once

class MyComponent   : public Component,
					  public Timer
{
public:
    MyComponent()
    {
        setSize (600, 400);
        startTimer(1000);
    }

    ~MyComponent()
    {
    }

    void timerCallback () override
    {
    	unfocusAllComponents();
    }

    void paint (Graphics& g) override
    {
        g.fillAll(
        	getLookAndFeel().findColour(ResizableWindow::backgroundColourId)
        );
    }

private:
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyComponent)
};


#2

Is this only in a plug-in setting? Your pip works fine on Ubuntu. I let your PiP run in the background while editing in gedit and everything seems to be working.


#3

Hey Fabian,

We encountered it while running that PIP as well as our plugin

Perhaps it could be distro or WM/DE specific? I’ll try it out in Ubuntu and see, if it only really happens on that Debian setup that would be okay


#4

You are using the newest version of JUCE right? I just remembered that we fixed a bug over a year ago where JUCE would steal the focus from any other application running - exactly like you describe.


#5

We’re currently on 5.3.1