[vlc-devel] [PATCH] Added window roles for X11

Nick Pope nick at nickpope.me.uk
Tue Sep 1 22:45:46 CEST 2009


Rémi Denis-Courmont wrote:
> Le mardi 1 septembre 2009 23:04:22 Nick Pope, vous avez écrit :
>   
>> Window roles can be used when configuring window managers to help users
>> place their windows and dialogs according to their preference.  This is
>> particularly useful for some of the *box window managers.
>> ---
>>  modules/gui/qt4/components/open_panels.cpp         |    1 +
>>  modules/gui/qt4/components/playlist/playlist.cpp   |    1 +
>>  modules/gui/qt4/components/preferences_widgets.cpp |    1 +
>>  modules/gui/qt4/dialogs/bookmarks.cpp              |    1 +
>>  modules/gui/qt4/dialogs/convert.cpp                |    1 +
>>  modules/gui/qt4/dialogs/errors.cpp                 |    1 +
>>  modules/gui/qt4/dialogs/extended.cpp               |    1 +
>>  modules/gui/qt4/dialogs/external.cpp               |    2 ++
>>  modules/gui/qt4/dialogs/gototime.cpp               |    1 +
>>  modules/gui/qt4/dialogs/help.cpp                   |    3 +++
>>  modules/gui/qt4/dialogs/mediainfo.cpp              |    1 +
>>  modules/gui/qt4/dialogs/messages.cpp               |    1 +
>>  modules/gui/qt4/dialogs/open.cpp                   |    1 +
>>  modules/gui/qt4/dialogs/openurl.cpp                |    1 +
>>  modules/gui/qt4/dialogs/playlist.cpp               |    1 +
>>  modules/gui/qt4/dialogs/plugins.cpp                |    1 +
>>  modules/gui/qt4/dialogs/preferences.cpp            |    1 +
>>  modules/gui/qt4/dialogs/sout.cpp                   |    1 +
>>  modules/gui/qt4/dialogs/toolbar.cpp                |    1 +
>>  modules/gui/qt4/main_interface.cpp                 |    2 ++
>>  modules/video_output/xcb/window.c                  |    5 +++++
>>  21 files changed, 29 insertions(+), 0 deletions(-)
>>
>> diff --git a/modules/gui/qt4/components/open_panels.cpp
>> b/modules/gui/qt4/components/open_panels.cpp index 59e42b0..c130c6c 100644
>> --- a/modules/gui/qt4/components/open_panels.cpp
>> +++ b/modules/gui/qt4/components/open_panels.cpp
>> @@ -1304,6 +1304,7 @@ void CaptureOpenPanel::advancedDialog()
>>      /* New Adv Prop dialog */
>>      adv = new QDialog( this );
>>      adv->setWindowTitle( qtr( "Advanced Options" ) );
>> +    adv->setWindowRole( "vlc-advanced-options" );
>>
>>      /* A main Layout with a Frame */
>>      QVBoxLayout *mainLayout = new QVBoxLayout( adv );
>> diff --git a/modules/gui/qt4/components/playlist/playlist.cpp
>> b/modules/gui/qt4/components/playlist/playlist.cpp index 8ad5d11..4ae5a30
>> 100644
>> --- a/modules/gui/qt4/components/playlist/playlist.cpp
>> +++ b/modules/gui/qt4/components/playlist/playlist.cpp
>> @@ -115,6 +115,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) :
>> p_intf ( _p_i )
>>
>>      setAcceptDrops( true );
>>      setWindowTitle( qtr( "Playlist" ) );
>> +    setWindowRole( "vlc-playlist" );
>>      setWindowIcon( QApplication::windowIcon() );
>>  }
>>
>> diff --git a/modules/gui/qt4/components/preferences_widgets.cpp
>> b/modules/gui/qt4/components/preferences_widgets.cpp index a96e437..20b65d4
>> 100644
>> --- a/modules/gui/qt4/components/preferences_widgets.cpp
>> +++ b/modules/gui/qt4/components/preferences_widgets.cpp
>> @@ -1381,6 +1381,7 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
>>      table = _table;
>>      setWindowTitle( b_global ? qtr( "Global" ): ""
>>                      + qtr( "Hotkey for " ) + keyToChange );
>> +    setWindowRole( "vlc-key-input" );
>>
>>      vLayout = new QVBoxLayout( this );
>>      selected = new QLabel( qtr( "Press the new keys for " ) + keyToChange
>> ); diff --git a/modules/gui/qt4/dialogs/bookmarks.cpp
>> b/modules/gui/qt4/dialogs/bookmarks.cpp index 9fa7615..950f724 100644
>> --- a/modules/gui/qt4/dialogs/bookmarks.cpp
>> +++ b/modules/gui/qt4/dialogs/bookmarks.cpp
>> @@ -38,6 +38,7 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf
>> ):QVLCFrame( _p_intf ) setWindowFlags( Qt::Tool );
>>      setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
>>      setWindowTitle( qtr( "Edit Bookmarks" ) );
>> +    setWindowRole( "vlc-bookmarks" );
>>
>>      QGridLayout *layout = new QGridLayout( this );
>>
>> diff --git a/modules/gui/qt4/dialogs/convert.cpp
>> b/modules/gui/qt4/dialogs/convert.cpp index 332aa85..cd2c8a8 100644
>> --- a/modules/gui/qt4/dialogs/convert.cpp
>> +++ b/modules/gui/qt4/dialogs/convert.cpp
>> @@ -42,6 +42,7 @@ ConvertDialog::ConvertDialog( QWidget *parent,
>> intf_thread_t *_p_intf,
>>
>>                : QVLCDialog( parent, _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Convert" ) );
>> +    setWindowRole( "vlc-convert" );
>>
>>      QGridLayout *mainLayout = new QGridLayout( this );
>>      SoutInputBox *inputBox = new SoutInputBox( this );
>> diff --git a/modules/gui/qt4/dialogs/errors.cpp
>> b/modules/gui/qt4/dialogs/errors.cpp index a2bd94f..2dd0b8b 100644
>> --- a/modules/gui/qt4/dialogs/errors.cpp
>> +++ b/modules/gui/qt4/dialogs/errors.cpp
>> @@ -40,6 +40,7 @@ ErrorsDialog::ErrorsDialog( QWidget *parent,
>> intf_thread_t *_p_intf )
>>
>>               : QVLCDialog( parent, _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Errors" ) );
>> +    setWindowRole( "vlc-errors" );
>>      resize( 500 , 300 );
>>
>>      QGridLayout *layout = new QGridLayout( this );
>> diff --git a/modules/gui/qt4/dialogs/extended.cpp
>> b/modules/gui/qt4/dialogs/extended.cpp index ffc34f0..f4fe68b 100644
>> --- a/modules/gui/qt4/dialogs/extended.cpp
>> +++ b/modules/gui/qt4/dialogs/extended.cpp
>> @@ -40,6 +40,7 @@ ExtendedDialog::ExtendedDialog( intf_thread_t *_p_intf ):
>> QVLCFrame( _p_intf ) setWindowFlags( Qt::Tool );
>>      setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
>>      setWindowTitle( qtr( "Adjustments and Effects" ) );
>> +    setWindowRole( "vlc-extended" );
>>
>>      QGridLayout *layout = new QGridLayout( this );
>>      layout->setLayoutMargins( 0, 2, 0, 1, 1 );
>> diff --git a/modules/gui/qt4/dialogs/external.cpp
>> b/modules/gui/qt4/dialogs/external.cpp index 69fa27e..f14586a 100644
>> --- a/modules/gui/qt4/dialogs/external.cpp
>> +++ b/modules/gui/qt4/dialogs/external.cpp
>> @@ -106,6 +106,7 @@ void DialogHandler::requestLogin (vlc_object_t *, void
>> *value) QLayout *layout = new QVBoxLayout (dialog);
>>
>>      dialog->setWindowTitle (qfu(data->title));
>> +    dialog->setWindowRole ("vlc-login");
>>      layout->setMargin (2);
>>
>>      /* User name and password fields */
>> @@ -185,6 +186,7 @@ QVLCProgressDialog::QVLCProgressDialog (DialogHandler
>> *parent, {
>>      if (data->title != NULL)
>>          setWindowTitle (qfu(data->title));
>> +    setWindowRole ("vlc-progress");
>>      setMinimumDuration (0);
>>
>>      connect (this, SIGNAL(progressed(int)), SLOT(setValue(int)));
>> diff --git a/modules/gui/qt4/dialogs/gototime.cpp
>> b/modules/gui/qt4/dialogs/gototime.cpp index 78ecbc1..5832acd 100644
>> --- a/modules/gui/qt4/dialogs/gototime.cpp
>> +++ b/modules/gui/qt4/dialogs/gototime.cpp
>> @@ -41,6 +41,7 @@ GotoTimeDialog::GotoTimeDialog( QWidget *parent,
>> intf_thread_t *_p_intf) {
>>      setWindowFlags( Qt::Tool );
>>      setWindowTitle( qtr( "Go to Time" ) );
>> +    setWindowRole( "vlc-goto-time" );
>>
>>      QGridLayout *mainLayout = new QGridLayout( this );
>>      mainLayout->setSizeConstraint( QLayout::SetFixedSize );
>> diff --git a/modules/gui/qt4/dialogs/help.cpp
>> b/modules/gui/qt4/dialogs/help.cpp index edcba52..c793467 100644
>> --- a/modules/gui/qt4/dialogs/help.cpp
>> +++ b/modules/gui/qt4/dialogs/help.cpp
>> @@ -53,6 +53,7 @@ HelpDialog::HelpDialog( intf_thread_t *_p_intf ) :
>> QVLCFrame( _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Help" ) );
>> +    setWindowRole( "vlc-help" );
>>      setMinimumSize( 350, 300 );
>>
>>      QGridLayout *layout = new QGridLayout( this );
>> @@ -85,6 +86,7 @@ AboutDialog::AboutDialog( QWidget *parent, intf_thread_t
>> *_p_intf)
>>
>>              : QVLCDialog( parent, _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "About" ) );
>> +    setWindowRole( "vlc-about" );
>>      resize( 600, 500 );
>>      setMinimumSize( 600, 500 );
>>
>> @@ -201,6 +203,7 @@ UpdateDialog *UpdateDialog::instance = NULL;
>>  UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf
>> ) {
>>      setWindowTitle( qtr( "VLC media player updates" ) );
>> +    setWindowRole( "vlc-update" );
>>
>>      QGridLayout *layout = new QGridLayout( this );
>>
>> diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp
>> b/modules/gui/qt4/dialogs/mediainfo.cpp index eb3f242..371e878 100644
>> --- a/modules/gui/qt4/dialogs/mediainfo.cpp
>> +++ b/modules/gui/qt4/dialogs/mediainfo.cpp
>> @@ -48,6 +48,7 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
>>      isMainInputInfo = ( p_item == NULL );
>>
>>      setWindowTitle( qtr( "Media Information" ) );
>> +    setWindowRole( "vlc-media-info" );
>>
>>      /* TabWidgets and Tabs creation */
>>      infoTabW = new QTabWidget;
>> diff --git a/modules/gui/qt4/dialogs/messages.cpp
>> b/modules/gui/qt4/dialogs/messages.cpp index 9789cf7..06442e5 100644
>> --- a/modules/gui/qt4/dialogs/messages.cpp
>> +++ b/modules/gui/qt4/dialogs/messages.cpp
>> @@ -73,6 +73,7 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
>>
>>                 : QVLCFrame( _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Messages" ) );
>> +    setWindowRole( "vlc-messages" );
>>
>>      /* General widgets */
>>      QGridLayout *mainLayout = new QGridLayout( this );
>> diff --git a/modules/gui/qt4/dialogs/open.cpp
>> b/modules/gui/qt4/dialogs/open.cpp index 487745c..ceb356f 100644
>> --- a/modules/gui/qt4/dialogs/open.cpp
>> +++ b/modules/gui/qt4/dialogs/open.cpp
>> @@ -78,6 +78,7 @@ OpenDialog::OpenDialog( QWidget *parent,
>>      /* Basic Creation of the Window */
>>      ui.setupUi( this );
>>      setWindowTitle( qtr( "Open Media" ) );
>> +    setWindowRole( "vlc-open-media" );
>>      setWindowModality( Qt::WindowModal );
>>
>>      /* Tab definition and creation */
>> diff --git a/modules/gui/qt4/dialogs/openurl.cpp
>> b/modules/gui/qt4/dialogs/openurl.cpp index 49a791b..24f4adc 100644
>> --- a/modules/gui/qt4/dialogs/openurl.cpp
>> +++ b/modules/gui/qt4/dialogs/openurl.cpp
>> @@ -60,6 +60,7 @@ OpenUrlDialog::OpenUrlDialog( QWidget *parent,
>>          QVLCDialog( parent, _p_intf ), bClipboard( _bClipboard )
>>  {
>>      setWindowTitle( qtr( "Open URL" ) );
>> +    setWindowRole( "vlc-open-url" );
>>
>>      /* Buttons */
>>      QPushButton *but;
>> diff --git a/modules/gui/qt4/dialogs/playlist.cpp
>> b/modules/gui/qt4/dialogs/playlist.cpp index 2736e52..2b51810 100644
>> --- a/modules/gui/qt4/dialogs/playlist.cpp
>> +++ b/modules/gui/qt4/dialogs/playlist.cpp
>> @@ -41,6 +41,7 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
>>      QWidget *main = new QWidget( this );
>>      setCentralWidget( main );
>>      setWindowTitle( qtr( "Playlist" ) );
>> +    setWindowRole( "vlc-playlist" );
>>      setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
>>
>>      QHBoxLayout *l = new QHBoxLayout( centralWidget() );
>> diff --git a/modules/gui/qt4/dialogs/plugins.cpp
>> b/modules/gui/qt4/dialogs/plugins.cpp index 1575ca0..9ab3e36 100644
>> --- a/modules/gui/qt4/dialogs/plugins.cpp
>> +++ b/modules/gui/qt4/dialogs/plugins.cpp
>> @@ -43,6 +43,7 @@ PluginDialog *PluginDialog::instance = NULL;
>>  PluginDialog::PluginDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf
>> ) {
>>      setWindowTitle( qtr( "Plugins and extensions" ) );
>> +    setWindowRole( "vlc-plugins" );
>>      QGridLayout *layout = new QGridLayout( this );
>>
>>      /* Main Tree for modules */
>> diff --git a/modules/gui/qt4/dialogs/preferences.cpp
>> b/modules/gui/qt4/dialogs/preferences.cpp index 89864d7..150dea8 100644
>> --- a/modules/gui/qt4/dialogs/preferences.cpp
>> +++ b/modules/gui/qt4/dialogs/preferences.cpp
>> @@ -44,6 +44,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t
>> *_p_intf ) {
>>      QGridLayout *main_layout = new QGridLayout( this );
>>      setWindowTitle( qtr( "Preferences" ) );
>> +    setWindowRole( "vlc-preferences" );
>>
>>      /* Whether we want it or not, we need to destroy on close to get
>>         consistency when reset */
>> diff --git a/modules/gui/qt4/dialogs/sout.cpp
>> b/modules/gui/qt4/dialogs/sout.cpp index ee603e5..2b99389 100644
>> --- a/modules/gui/qt4/dialogs/sout.cpp
>> +++ b/modules/gui/qt4/dialogs/sout.cpp
>> @@ -40,6 +40,7 @@ SoutDialog::SoutDialog( QWidget *parent, intf_thread_t
>> *_p_intf, const QString&
>>
>>             : QVLCDialog( parent,  _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Stream Output" ) );
>> +    setWindowRole( "vlc-stream-output" );
>>
>>      /* UI stuff */
>>      ui.setupUi( this );
>> diff --git a/modules/gui/qt4/dialogs/toolbar.cpp
>> b/modules/gui/qt4/dialogs/toolbar.cpp index f3a6ca3..0f67025 100644
>> --- a/modules/gui/qt4/dialogs/toolbar.cpp
>> +++ b/modules/gui/qt4/dialogs/toolbar.cpp
>> @@ -45,6 +45,7 @@ ToolbarEditDialog::ToolbarEditDialog( QWidget *_w,
>> intf_thread_t *_p_intf)
>>
>>                    : QVLCDialog( _w,  _p_intf )
>>
>>  {
>>      setWindowTitle( qtr( "Toolbars Editor" ) );
>> +    setWindowRole( "vlc-toolbars-editor" );
>>      QGridLayout *mainLayout = new QGridLayout( this );
>>      setMinimumWidth( 600 );
>>      setAttribute( Qt::WA_DeleteOnClose );
>> diff --git a/modules/gui/qt4/main_interface.cpp
>> b/modules/gui/qt4/main_interface.cpp index 1807f3c..504d161 100644
>> --- a/modules/gui/qt4/main_interface.cpp
>> +++ b/modules/gui/qt4/main_interface.cpp
>> @@ -105,6 +105,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf )
>> : QVLCMW( _p_intf ) /* Main settings */
>>      setFocusPolicy( Qt::StrongFocus );
>>      setAcceptDrops( true );
>> +    setWindowRole( "vlc-main" );
>>      setWindowIcon( QApplication::windowIcon() );
>>      setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
>>
>> @@ -605,6 +606,7 @@ int MainInterface::privacyDialog( QList<ConfigControl
>> *> *controls ) QDialog *privacy = new QDialog( this );
>>
>>      privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
>> +    privacy->setWindowRole( "vlc-privacy" );
>>
>>      QGridLayout *gLayout = new QGridLayout( privacy );
>>
>> diff --git a/modules/video_output/xcb/window.c
>> b/modules/video_output/xcb/window.c index 5c9bd4a..5a17ba5 100644
>> --- a/modules/video_output/xcb/window.c
>> +++ b/modules/video_output/xcb/window.c
>> @@ -266,6 +266,8 @@ static int Open (vlc_object_t *obj)
>>          = intern_string (conn, "_NET_WM_NAME");
>>      xcb_intern_atom_cookie_t net_wm_icon_name_ck
>>          = intern_string (conn, "_NET_WM_ICON_NAME");
>> +    xcb_intern_atom_cookie_t wm_window_role_ck
>> +        = intern_string (conn, "WM_WINDOW_ROLE");
>>
>>      xcb_atom_t utf8 = get_atom (conn, utf8_string_ck);
>>
>> @@ -282,6 +284,9 @@ static int Open (vlc_object_t *obj)
>>      xcb_atom_t net_wm_icon_name = get_atom (conn, net_wm_icon_name_ck);
>>      set_string (conn, window, utf8, net_wm_icon_name, _("VLC"));
>>
>> +    xcb_atom_t wm_window_role = get_atom (conn, wm_window_role_ck);
>> +    set_string (conn, window, utf8, wm_window_role, "vlc-xcb");
>>     
> It should probably be set_ascii_prop() instead of set_string():
>
> | The client must set the WM_WINDOW_ROLE property to a string that
> | uniquely identifies that window among all windows that have the same
> | client leader window. The property must: 
> |  * be of type STRING; 
> |  * be of format 8; and 
> |  * contain a string restricted to the XPCS characters, encoded in
> |    ISO 8859-1.
>
> And I don't think "xcb" has anything to do with the role of the window... 
> "vlc-video" seems more logical to me.
>
>   
Thanks for the help.  Admittedly I am jumping in at the deep end with no 
real experience of ICCCM, Qt or XCB!  But it is a relatively simple thing :)

New patch coming...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090901/35f30a6e/attachment.html>


More information about the vlc-devel mailing list