Port getStringProperty to XCB

icc-effect-5.14.5
Martin Gräßlin 2013-05-02 11:14:40 +02:00
parent cefaa756e7
commit dfec59c60e
4 changed files with 24 additions and 25 deletions

View File

@ -11,7 +11,12 @@ set(kwin_rules_dialog_KDEINIT_SRCS main.cpp ${kwinrules_SRCS})
kde4_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY})
set(kwin_kcm_rules_XCB_LIBS
${XCB_XCB_LIBRARIES}
${X11_XCB_LIBRARIES}
)
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY} ${kwin_kcm_rules_XCB_LIBS})
install(TARGETS kdeinit_kwin_rules_dialog ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_rules_dialog DESTINATION ${LIBEXEC_INSTALL_DIR} )
@ -23,7 +28,7 @@ set(kcm_kwinrules_PART_SRCS kcm.cpp ${kwinrules_SRCS})
kde4_add_plugin(kcm_kwinrules ${kcm_kwinrules_PART_SRCS})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY} ${kwin_kcm_rules_XCB_LIBS})
install(TARGETS kcm_kwinrules DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -36,7 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin {
// mock required function from utils
QByteArray getStringProperty(WId w, Atom prop, char separator)
QByteArray getStringProperty(xcb_window_t w, xcb_atom_t prop, char separator)
{
Q_UNUSED(separator)
ScopedCPointer<xcb_get_property_reply_t> property(xcb_get_property_reply(connection(),

View File

@ -120,29 +120,23 @@ void Motif::readFlags(WId w, bool& got_noborder, bool& noborder,
#endif
QByteArray getStringProperty(WId w, Atom prop, char separator)
QByteArray getStringProperty(xcb_window_t w, xcb_atom_t prop, char separator)
{
Atom type;
int format, status;
unsigned long nitems = 0;
unsigned long extra = 0;
unsigned char *data = 0;
QByteArray result = "";
KXErrorHandler handler; // ignore errors
status = XGetWindowProperty(display(), w, prop, 0, 10000,
false, XA_STRING, &type, &format,
&nitems, &extra, &data);
if (status == Success) {
if (data && separator) {
for (int i = 0; i < (int)nitems; i++)
if (!data[i] && i + 1 < (int)nitems)
data[i] = separator;
}
if (data)
result = (const char*) data;
XFree(data);
const xcb_get_property_cookie_t c = xcb_get_property_unchecked(connection(), false, w, prop,
XCB_ATOM_STRING, 0, 10000);
ScopedCPointer<xcb_get_property_reply_t> property(xcb_get_property_reply(connection(), c, NULL));
if (property.isNull() || property->type == XCB_ATOM_NONE) {
return QByteArray();
}
return result;
char *data = static_cast<char*>(xcb_get_property_value(property.data()));
if (data && separator) {
for (uint32_t i = 0; i < property->value_len; ++i) {
if (!data[i] && i + 1 < property->value_len) {
data[i] = separator;
}
}
}
return QByteArray(data, property->value_len);
}
#ifndef KCMRULES

View File

@ -216,7 +216,7 @@ public:
ScopedCPointer(T *p = 0) : QScopedPointer<T, QScopedPointerPodDeleter>(p) {}
};
QByteArray getStringProperty(Window w, Atom prop, char separator = 0);
QByteArray getStringProperty(xcb_window_t w, xcb_atom_t prop, char separator = 0);
void updateXTime();
void grabXServer();
void ungrabXServer();