krfb: add settings page allowing user to change framebuffer plugin
ClosedPublic

Authored by alexeymin on Jun 21 2017, 5:07 PM.

Details

Summary

Added a new page to config dialog: "Screen capture", allowing to choose a framebuffer plugin.
Added a brief description about xcb and qt plugins.
Changed an icon for first tab "Network" to more appropriate one.
Code is prepared to expect "x11" as preferredFramebufferPlugin and automatically change this setting to "xcb".
Do not hardcode possible list of framebuffer plugins in combobox, but instead find actual available plugins at runtime.
If preferred plugin has changed in settings, inform user that krfb needs to be restarted to apply changes.

It looks like: http://i.imgur.com/VKIgNKz.png

Test Plan

Compile, run. Change framebuffer plugin, verify that ~/.config/krfbrc has changed accordingly, restart krfb, look in settings again to verify that framebuffer setting was loaded correctly.
Change framebuffer setting, see a messagebox with information about need to restart.
Manually edit ~/.config/krfbrc, set preferredFramebufferPlugin=x11 there. Launch krfb, verify that it automatically changed to xcb.

Diff Detail

Repository
R437 Desktop Sharing
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
alexeymin created this revision.Jun 21 2017, 5:07 PM
alexeymin added a comment.EditedJun 21 2017, 5:30 PM

I used a hidden line edit, connected to KConfig parameter preferredFramebufferPlugin, and manually filled dropdown combobox (not automatically connected to KConfig) with texts that can be found in config parameter: "xcb", "qt". This allows to keep compatibility with old config format and the code that loads the preferred plugin (it expects a string). I tried to use directly connected combobox, but in that case the string that is saved into config looks like: preferredFramebufferPlugin=1, kconfig saves selected index. And we need a string (preferredFramebufferPlugin=xcb).

Icon change for settings tab is questionable, and could be done in another revision, but I couldn't resist...

What can be improved:

  1. do not hardcode possible list of choices in combobox, but instead find actual available plugins as it is done in code that loads plugins: https://cgit.kde.org/krfb.git/tree/krfb/framebuffermanager.cpp#n66
  2. if preferred plugin has changed, inform user that krfb needs to be restarted to apply changes
  3. or, apply the change immediately: force restart of InvitationsRfbServer (will this break existing connections?..)

Not sure, what to do.

Also, code needs to be prepared to expect "x11" as preferredFramebufferPlugin and probably automatically change this setting to "xcb" early at program startup, before initialization of rfb server and loading plugins.

aacid edited edge metadata.Jun 21 2017, 8:18 PM

What can be improved:

  1. do not hardcode possible list of choices in combobox, but instead find actual available plugins as it is done in code that loads plugins: https://cgit.kde.org/krfb.git/tree/krfb/framebuffermanager.cpp#n66

Yes

  1. if preferred plugin has changed, inform user that krfb needs to be restarted to apply changes

Yes

  1. or, apply the change immediately: force restart of InvitationsRfbServer (will this break existing connections?..)

Seems too aggressive, people may lose data, not something we want to be resposinble

In D6319#118408, @aacid wrote:

Yes

Yes

ok

In D6319, @alexeymin wrote:

code needs to be prepared to expect "x11" as preferredFramebufferPlugin and probably automatically change this setting to "xcb"

I assume no answer to this as a third "yes" ;) and will continue work, thx

alexeymin retitled this revision from krfb: add settings page allowing user to change framebuffer plugin to [WIP] krfb: add settings page allowing user to change framebuffer plugin.Jun 22 2017, 5:40 AM
aacid requested changes to this revision.Jul 28 2017, 8:43 AM

Marking as needs fixes so that it doesn't appear on my "needs review" list while you work on the finishing touches

This revision now requires changes to proceed.Jul 28 2017, 8:43 AM
alexeymin updated this revision to Diff 17372.Jul 30 2017, 7:13 AM
alexeymin edited edge metadata.
alexeymin retitled this revision from [WIP] krfb: add settings page allowing user to change framebuffer plugin to krfb: add settings page allowing user to change framebuffer plugin.
alexeymin edited the summary of this revision. (Show Details)
alexeymin edited the test plan for this revision. (Show Details)

Code is prepared to expect "x11" as preferredFramebufferPlugin and automatically change this setting to "xcb".
Do not hardcode possible list of framebuffer plugins in combobox, but instead find actual available plugins at runtime.
If preferred plugin has changed in settings, inform user that krfb needs to be restarted to apply changes.
Fix code indentation issues in krfb/frambuffermanager.cpp and add const reference instead of object copying.

Hoping I'm not too late!..

aacid added inline comments.Jul 30 2017, 10:16 PM
krfb/mainwindow.cpp
37

Making this static is bad form.

There's two options:

  • Make it be part of the mainwindow class, it's still a bit bad since it doesn't really seem to belong to "mainwindow"
  • Define it as part of MainWindow::showConfiguration and then make MainWindow::onSettingsChanged be a lambda instead of a function, this way you can capture the prevFramebufferPlugin. This seems the "cleanest" since the scope of the revFramebufferPlugin variable is just one function.

Do you know how lambdas work? Does what i said make any sense?

alexeymin updated this revision to Diff 17416.Jul 31 2017, 9:05 AM

Connect settingsChanged() to lambda instead of a slot function; narrow the scope of s_prevFramebufferPlugin to showConfiguration() function only.

alexeymin marked an inline comment as done.Jul 31 2017, 9:10 AM

Does what i said make any sense?

Yes, I agree. Lambda works too, and the code looks cleaner.

aacid added inline comments.Jul 31 2017, 8:31 PM
krfb/mainwindow.cpp
239

Why this change?

Why this change?

This is not related, but I can explain: network-workgroup vs network-wired:


Folder icon does not associate with network for me, but the second, with ethernet socket (?) is the same as used in plasma notification area "networks" - directly associates with networking settings.
This of course can be removed if you don't like...

aacid added a comment.Aug 2 2017, 10:01 PM

Looks good, i'll wait to see if you want to get an exception to commit it to Applications/17.08, otherwise i'll commit to master.

krfb/mainwindow.cpp
229

Actually you don't really need this to be static, just capture it in the lamba as a copy, i.e [this, prevFramebufferPlugin]

alexeymin added a comment.EditedAug 3 2017, 6:44 AM

Actually you don't really need this to be static, just capture it in the lamba as a copy, i.e [this, prevFramebufferPlugin]

No, I've tested that, and it works only for the first time config dialog is shown, the first time lambda is created. If don't make prevFramebufferPlugin static, and capture it by copy, lambda remembers only the initial value of prevFramebufferPlugin, at the moment when QObject connection to lambda is done, and does not see updates to its value. So, on the second dialog show it can behave incorrectly. To make lambda see the updates, we need to capture by reference, and so prevFramebufferPlugin has to be static, to prevent it going out of scope.

aacid added a comment.Aug 3 2017, 9:09 PM

Actually you don't really need this to be static, just capture it in the lamba as a copy, i.e [this, prevFramebufferPlugin]

No, I've tested that, and it works only for the first time config dialog is shown, the first time lambda is created. If don't make prevFramebufferPlugin static, and capture it by copy, lambda remembers only the initial value of prevFramebufferPlugin, at the moment when QObject connection to lambda is done, and does not see updates to its value. So, on the second dialog show it can behave incorrectly. To make lambda see the updates, we need to capture by reference, and so prevFramebufferPlugin has to be static, to prevent it going out of scope.

Actually you are right that the static is needed, but you're explanation in your comment is wrong.

The real reason the static is needed is that only one KConfigDialog is created, the rest of the times the function to show the dialog is called, the

if (KConfigDialog::showDialog("settings")) {
    return;
}

returns early, so you need the static to update the value of the varaible that will be used inside the lambda of the "first/old" dialog, not because the variable goes away.

aacid accepted this revision.Aug 3 2017, 9:10 PM

Anyhow, it's good (maybe try to explain why the static is needed in the function).

And commit to Applications/17.08 if you get the exception, otherwise to master.

This revision is now accepted and ready to land.Aug 3 2017, 9:10 PM
cfeck added a subscriber: cfeck.Aug 7 2017, 9:57 PM
This revision was automatically updated to reflect the committed changes.