Commit b2cb3e82 authored by Alexey Min's avatar Alexey Min Committed by Albert Astals Cid

Implement XCB framebuffer plugin (port from x11)

Previously used x11 plugin does not compile with Qt5, because Qt5 does
not use Xlib, it uses xcb. Rewrite screen capture plugin from Xlib to
xcb.

I made xcb libs compile required dependency, but availability of X
shared memory extension is checked at runtime. It is used to effectively
get image pixels data, instead of transfering 8Mb over the wire. Xdamage
is used to limit image getting operations only within actually changed
rectangles of screen.

BUG: 377998

Tested on single-monitor system and dual-monitor, where primary monitor
does not start at (0,0) coordinate. Image transfer works fine.
Dual-monitor only has problems with receiving mouse cursor position and
clicks, but this should be fixed outside of framebuffer plugin.

Differential Revision: https://phabricator.kde.org/D5211
parent c92ef2f2
......@@ -31,10 +31,21 @@ find_package(KF5 REQUIRED COMPONENTS
find_package(X11 REQUIRED)
find_package(XCB REQUIRED COMPONENTS
XCB
RENDER
SHAPE
XFIXES
DAMAGE
SHM
IMAGE
)
if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
endif(WIN32)
add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS})
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
......@@ -46,16 +57,6 @@ set(CMAKE_MODULE_PATH
find_package(LibVNCServer REQUIRED)
if (HAVE_XDAMAGE)
set(X11_Xdamage_FOUND 1)
else()
set(X11_Xdamage_FOUND 0)
endif()
if (HAVE_XSHM)
set(X11_XShm_FOUND 1)
else()
set(X11_XShm_FOUND 0)
endif()
include_directories ("${CMAKE_CURRENT_BINARY_DIR}/krfb"
"${CMAKE_CURRENT_SOURCE_DIR}/krfb"
......
add_subdirectory (qt)
add_subdirectory (x11)
if (${XCB_DAMAGE_FOUND} AND ${XCB_SHM_FOUND} AND ${XCB_IMAGE_FOUND})
add_subdirectory (xcb)
endif()
include_directories (${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set (krfb_framebuffer_xcb_SRCS
xcb_framebufferplugin.cpp
xcb_framebuffer.cpp
)
add_library(krfb_framebuffer_xcb MODULE ${krfb_framebuffer_xcb_SRCS})
target_link_libraries (krfb_framebuffer_xcb
Qt5::Core
Qt5::Gui
XCB::XCB
XCB::RENDER
XCB::SHAPE
XCB::XFIXES
XCB::DAMAGE
XCB::SHM
XCB::IMAGE
KF5::CoreAddons
krfbprivate
)
install (TARGETS krfb_framebuffer_xcb
DESTINATION ${PLUGIN_INSTALL_DIR}/krfb
)
[Desktop Entry]
Encoding=UTF-8
Comment=X11 XDamage/XShm based Framebuffer for KRfb.
Comment[ast]=Búfer de cuadros basáu en XDamage/XShm de X11 pa KRfb.
Comment[bg]=Основан на X11 XDamage/XShm фреймбуфер за KRfb.
Comment[bs]=X11 XDamage/XShm baziran framebafer za KRfb.
Comment[ca]=«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.
Comment[ca@valencia]=«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.
Comment[cs]=Framebuffer založený na X11 XDamage/XShm pro KRfb.
Comment[da]=X11 XDamage/XShm-baseret framebuffer til KRfb.
Comment[de]=X11 XDamage/XShm-basierter Framebuffer für KRfb.
Comment[el]=Μνήμη εξόδου βίντεο καρέ με βάση το X11 XDamage/XShm για το KRfb.
Comment[en_GB]=X11 XDamage/XShm based Framebuffer for KRfb.
Comment[es]=Memoria intermedia de vídeo basada en X11 Damage/XShm para KRfb.
Comment[et]=KRfb X11 XDamage/XShm põhine kaadripuhver
Comment[eu]=X11 XDamage/XShm oinarritutako KRfb-ren irteerako bideoa.
Comment[fi]=X11 XDamage/XShm-perustainen kehyspuskui KRfb:lle.
Comment[fr]=Sortie vidéo fondée sur X11 « XDamage / XShm » pour Krfb.
Comment[ga]=Maolán fráma le haghaidh KRfb, bunaithe ar X11 XDamage/XShm
Comment[gl]=Framebuffer baseado en Xll XDamage/Xshm para XRfb.
Comment[hr]=Međuspreminik okvira baziran na X11 XDamage/XShm za KRfb.
Comment[hu]=X11 XDamage/XShm-alapú framebuffer a Krfb-hez.
Comment[ia]=Framebuffer basate sur X11 XDamage/XShm per KRfb.
Comment[it]=Framebuffer basato su XDamage/XShm di X11 per KRfb.
Comment[kk]=X11 XDamage/XShm негіздеген KRfb кадр буфері.
Comment[km]=X11 XDamage/XShm based Framebuffer សម្រាប់ KRfb ។
Comment[ko]=KRfb를 위한 X11 XDamage/XShm 기반 프레임버퍼.
Comment[lt]=X11 XDamage/XShm paremtas Framebuffer skirtas KRfb.
Comment[lv]=X11 XDamage/XShm balstīts kadrbuferis priekš KRfb.
Comment[nb]=Rammebuffer for KRfb basert på X11 XDamage/XShm.
Comment[nds]=Op X11-XDamage/-XShm opbuut Bildpuffer för KRfb
Comment[nl]=Op X11 XDamage/XShm gebaseerd framebuffer voor KRfb.
Comment[nn]=X11 XDamage/XShm basert framebuffer for KRfb.
Comment[pl]=Bufor ramki na podstawie X11 XDamage/XShm dla KRfb.
Comment[pt]='Framebuffer' baseado no XDamage/XShm do X11 para o KRfb.
Comment[pt_BR]=Framebuffer baseado no XDamage/XShm do X11 para o KRfb.
Comment[ru]=Буфер экрана для KRfb на базе X11 XDamage/XShm
Comment[si]=KRfb සඳහා වන රාමු බෆරය මත පදනම් වූ X11 XDamage/XShm.
Comment[sk]=Framebuffer založený na X11 XDamage/XShm pre KRfb.
Comment[sl]=Slikovni medpomnilnik za KRFB, ki temelji na X11 XDamage/XShm
Comment[sr]=Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.
Comment[sr@ijekavian]=Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.
Comment[sr@ijekavianlatin]=Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.
Comment[sr@latin]=Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.
Comment[sv]=X11 XDamage/XShm-baserad rambuffert för Krfb.
Comment[tr]=KRfb için X11 XDamage/XShm temelli Çerçeve Tamponu.
Comment[uk]=Заснований на XDamage/XShm X11 буфер кадрів для KRfb.
Comment[x-test]=xxX11 XDamage/XShm based Framebuffer for KRfb.xx
Comment[zh_CN]=基于 X11 XDamage/XShm 扩展的 KRfb 帧缓冲机制。
Comment[zh_TW]=KRfb 的 X11 XDamage/XShm based Framebuffer
Name=X11 Framebuffer for KRfb
Name[ast]=Búfer de cuadros de X11 pa KRfb
Name[bg]=X11 фреймбуфер за KRfb
Name[bs]=X11 frame bafer za KRfb
Name[ca]=«Framebuffer» del X11 per al KRfb.
Name[ca@valencia]=«Framebuffer» del X11 per al KRfb.
Name[cs]=X11 Framebuffer pro KRfb
Name[da]=X11-framebuffer til KRfb
Name[de]=X11-Framebuffer für KRfb
Name[el]=X11 Framebuffer for KRfb
Name[en_GB]=X11 Framebuffer for KRfb
Name[es]=Memoria intermedia de vídeo X11 para KRfb
Name[et]=KRfb X11 kaadripuhver
Name[eu]=KRfb-ren X11-ko irteerako bideoa
Name[fi]=X11-kehyspuskuri KRfb:lle
Name[fr]=Sortie vidéo X11 pour Krfb
Name[ga]=Maolán fráma X11 le haghaidh KRfb
Name[gl]=Framebuffer de X11 para KRfb
Name[hr]=Međuspremnik okvira X11 za KRfb
Name[hu]=X11 framebuffer a Krfb-hez
Name[ia]=Framebuffer X11 per KRfb
Name[it]=Framebuffer X11 per KRfb
Name[kk]=X11 KRfb кадр буфері
Name[km]=X11 Framebuffer សម្រាប់ KRfb
Name[ko]=KRfb를 위한 X11 프레임버퍼
Name[lt]=X11 Framebuffer skirtas KRfb
Name[lv]=X11 kadrbuferis priekš KRfb
Name[nb]=X11 rammebuffer for KRfb
Name[nds]=X11-Bildpuffer för KRfb
Name[nl]=X11 framebuffer voor KRfb
Name[nn]=X11-framebuffer for KRfb
Name[pl]=Bufor ramki X11 dla KRfb
Name[pt]='Framebuffer' do X11 para o KRfb
Name[pt_BR]=Framebuffer do X11 para o KRfb
Name[ru]=Буфер экрана X11 для KRfb
Name[si]=KRfb සඳහා X11 රාමු බෆරය
Name[sk]=X11 Framebuffer pre KRfb
Name[sl]=Slikovni medpomnilnik X11 za KRFB
Name[sr]=Икс11 кадробафер за КРФБ.
Name[sr@ijekavian]=Икс11 кадробафер за КРФБ.
Name[sr@ijekavianlatin]=X11 kadrobafer za KRFB.
Name[sr@latin]=X11 kadrobafer za KRFB.
Name[sv]=X11-rambuffert för Krfb
Name[tr]=KRfb için X11 Çerçeve Tamponu
Name[uk]=Буфер кадрів X11 для KRfb
Name[x-test]=xxX11 Framebuffer for KRfbxx
Name[zh_CN]=KRfb 的 X11 帧缓冲机制
Name[zh_TW]=KRfb 的 X11 Framebuffer
Type=Service
ServiceTypes=krfb/framebuffer
X-KDE-Library=krfb_framebuffer_xcb
X-KDE-PluginInfo-Name=xcb
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://www.kde.org
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
{
"Encoding": "UTF-8",
"KPlugin": {
"Description": "X11 XDamage/XShm based Framebuffer for KRfb.",
"Description[ast]": "Búfer de cuadros basáu en XDamage/XShm de X11 pa KRfb.",
"Description[ca@valencia]": "«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.",
"Description[ca]": "«Framebuffer» basat en XDamage/XShmQt del X11 per al KRfb.",
"Description[cs]": "Framebuffer založený na X11 XDamage/XShm pro KRfb.",
"Description[da]": "X11 XDamage/XShm-baseret framebuffer til KRfb.",
"Description[de]": "X11 XDamage/XShm-basierter Framebuffer für KRfb.",
"Description[el]": "Μνήμη ανανέωσης βίντεο με βάση το X11 XDamage/XShm για το KRfb.",
"Description[es]": "Framebuffer basado en XDamage/XShm de X11 para KRfb.",
"Description[et]": "KRfb X11 XDamage/XShm põhine kaadripuhver",
"Description[fi]": "X11 XDamage/XShm-perustainen kehyspuskui KRfb:lle.",
"Description[fr]": "Tampon d'images utilisant XDamage/XShm de X11 pour KRfb.",
"Description[gl]": "Framebuffer baseado en Xll XDamage/Xshm para XRfb.",
"Description[ia]": "Framebuffer basate sur X11 XDamage/XShm per KRfb.",
"Description[it]": "Framebuffer basato su XDamage/XShm di X11 per KRfb.",
"Description[ko]": "KRfb용 X11 XDamage/XShm 기반 프레임버퍼입니다.",
"Description[nl]": "Op X11 XDamage/XShm gebaseerd framebuffer voor KRfb.",
"Description[nn]": "X11 XDamage/XShm-basert biletbuffer for KRfb.",
"Description[pl]": "Bufor ramki na podstawie X11 XDamage/XShm dla KRfb.",
"Description[pt]": "'Framebuffer' do X11, baseado no XDamage/XShm, para o KRfb.",
"Description[pt_BR]": "Framebuffer baseado no XDamage/XShm do X11 para o KRfb.",
"Description[ru]": "Буфер кадров для KRfb на базе X11 XDamage/XShm",
"Description[sk]": "Framebuffer založený na X11 XDamage/XShm pre KRfb.",
"Description[sl]": "Slikovni medpomnilnik za KRfb, ki temelji na X11 XDamage/XShm",
"Description[sr@ijekavian]": "Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.",
"Description[sr@ijekavianlatin]": "Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.",
"Description[sr@latin]": "Kadrobafer za KRFB na osnovu XDamagea/XShma u X11.",
"Description[sr]": "Кадробафер за КРФБ на основу Икс‑демиџа/Икс‑схма у Иксу11.",
"Description[sv]": "X11 XDamage/XShm-baserad rambuffert för Krfb.",
"Description[tr]": "KRfb için X11 XDamage/XShm tabanlı Çerçeve tamponu.",
"Description[uk]": "Заснований на XDamage/XShm X11 буфер кадрів для KRfb.",
"Description[x-test]": "xxX11 XDamage/XShm based Framebuffer for KRfb.xx",
"Description[zh_CN]": "KRfb 的基于 X11 XDamage/XShm 的帧缓冲。",
"Description[zh_TW]": "KRfb 的 X11 XDamage/XShm based Framebuffer",
"EnabledByDefault": true,
"Id": "xcb",
"License": "GPL",
"Name": "X11 Framebuffer for KRfb",
"Name[ast]": "Búfer de cuadros de X11 pa KRfb",
"Name[ca@valencia]": "«Framebuffer» del X11 per al KRfb.",
"Name[ca]": "«Framebuffer» del X11 per al KRfb.",
"Name[cs]": "X11 Framebuffer pro KRfb",
"Name[da]": "X11-framebuffer til KRfb",
"Name[de]": "X11-Framebuffer für KRfb",
"Name[el]": "Μνήμη ανανέωσης βίντεο X11 για το KRfb.",
"Name[es]": "Framebuffer X11 para KRfb",
"Name[et]": "KRfb X11 kaadripuhver",
"Name[fi]": "X11-kehyspuskuri KRfb:lle",
"Name[fr]": "Tampon d'images X11 pour KRfb",
"Name[gl]": "Framebuffer de X11 para KRfb",
"Name[ia]": "Framebuffer X11 per KRfb",
"Name[it]": "Framebuffer X11 per KRfb",
"Name[ko]": "KRfb용 X11 프레임버퍼",
"Name[nl]": "X11 framebuffer voor KRfb",
"Name[nn]": "X11-biletbuffer for KRfb",
"Name[pl]": "Bufor ramki X11 dla KRfb",
"Name[pt]": "'Framebuffer' do X11 para o KRfb",
"Name[pt_BR]": "Framebuffer do X11 para o KRfb",
"Name[ru]": "Буфер кадров X11 для KRfb",
"Name[sk]": "X11 Framebuffer pre KRfb",
"Name[sl]": "Slikovni medpomnilnik X11 za KRfb",
"Name[sr@ijekavian]": "Икс11 кадробафер за КРФБ.",
"Name[sr@ijekavianlatin]": "X11 kadrobafer za KRFB.",
"Name[sr@latin]": "X11 kadrobafer za KRFB.",
"Name[sr]": "Икс11 кадробафер за КРФБ.",
"Name[sv]": "X11-rambuffert för Krfb",
"Name[tr]": "KRfb için X11 Çerçeve tamponu",
"Name[uk]": "Буфер кадрів X11 для KRfb",
"Name[x-test]": "xxX11 Framebuffer for KRfbxx",
"Name[zh_CN]": "XRfb 的 X11 帧缓冲",
"Name[zh_TW]": "KRfb 的 X11 Framebuffer",
"ServiceTypes": [
"krfb/framebuffer"
],
"Version": "0.1",
"Website": "http://www.kde.org"
}
}
This diff is collapsed.
/* This file is part of the KDE project
Copyright (C) 2017 Alexey Min <alexey.min@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef KRFB_FRAMEBUFFER_XCB_XCB_FRAMEBUFFER_H
#define KRFB_FRAMEBUFFER_XCB_XCB_FRAMEBUFFER_H
#include "framebuffer.h"
#include <QWidget>
#include <xcb/xcb.h>
/**
@author Alexey Min <alexey.min@gmail.com>
*/
class XCBFrameBuffer: public FrameBuffer
{
Q_OBJECT
public:
XCBFrameBuffer(WId winid, QObject *parent = 0);
~XCBFrameBuffer();
public:
QList<QRect> modifiedTiles() Q_DECL_OVERRIDE;
int depth() Q_DECL_OVERRIDE;
int height() Q_DECL_OVERRIDE;
int width() Q_DECL_OVERRIDE;
int paddedWidth() Q_DECL_OVERRIDE;
void getServerFormat(rfbPixelFormat &format) Q_DECL_OVERRIDE;
void startMonitor() Q_DECL_OVERRIDE;
void stopMonitor() Q_DECL_OVERRIDE;
public:
void handleXDamageNotify(xcb_generic_event_t *xevent);
private:
void cleanupRects();
class P;
P *const d;
};
#endif
/* This file is part of the KDE project
@author Alexey Min <alexey.min@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "xcb_framebufferplugin.h"
#include "xcb_framebuffer.h"
#include <KPluginFactory>
K_PLUGIN_FACTORY_WITH_JSON(XCBFrameBufferPluginFactory, "krfb_framebuffer_xcb.json",
registerPlugin<XCBFrameBufferPlugin>();)
XCBFrameBufferPlugin::XCBFrameBufferPlugin(QObject *parent, const QVariantList &args)
: FrameBufferPlugin(parent, args)
{
}
XCBFrameBufferPlugin::~XCBFrameBufferPlugin()
{
}
FrameBuffer *XCBFrameBufferPlugin::frameBuffer(WId id)
{
return new XCBFrameBuffer(id);
}
#include "xcb_framebufferplugin.moc"
/* This file is part of the KDE project
@author Alexey Min <alexey.min@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KRFB_FRAMEBUFFER_XCB_XCBFRAMEBUFFERPLUGIN_H
#define KRFB_FRAMEBUFFER_XCB_XCBFRAMEBUFFERPLUGIN_H
#include "framebufferplugin.h"
#include <QWidget>
class FrameBuffer;
class XCBFrameBufferPlugin: public FrameBufferPlugin
{
Q_OBJECT
public:
XCBFrameBufferPlugin(QObject *parent, const QVariantList &args);
virtual ~XCBFrameBufferPlugin();
FrameBuffer *frameBuffer(WId id) override;
private:
Q_DISABLE_COPY(XCBFrameBufferPlugin)
};
#endif // Header guard
......@@ -46,7 +46,7 @@
<group name="FrameBuffer">
<entry name="preferredFrameBufferPlugin" type="String">
<label>Preferred Frame Buffer Plugin</label>
<default>qt</default>
<default>xcb</default>
</entry>
</group>
</kcfg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment