File indexing completed on 2024-04-28 05:46:51

0001 /*****************************************************************************
0002  *   Copyright 2014 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
0003  *                                                                           *
0004  *   This program is free software; you can redistribute it and/or modify    *
0005  *   it under the terms of the GNU Lesser General Public License as          *
0006  *   published by the Free Software Foundation; either version 2.1 of the    *
0007  *   License, or (at your option) version 3, or any later version accepted   *
0008  *   by the membership of KDE e.V. (or its successor approved by the         *
0009  *   membership of KDE e.V.), which shall act as a proxy defined in          *
0010  *   Section 6 of version 3 of the license.                                  *
0011  *                                                                           *
0012  *   This program is distributed in the hope that it will be useful,         *
0013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
0014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
0015  *   Lesser General Public License for more details.                         *
0016  *                                                                           *
0017  *   You should have received a copy of the GNU Lesser General Public        *
0018  *   License along with this library. If not,                                *
0019  *   see <http://www.gnu.org/licenses/>.                                     *
0020  *****************************************************************************/
0021 
0022 #include "config.h"
0023 #include "x11wrap.h"
0024 
0025 #ifdef QTC_ENABLE_X11
0026 
0027 #include "x11utils_p.h"
0028 #include <X11/Xlib.h>
0029 
0030 QTC_EXPORT void
0031 qtcX11FlushXlib()
0032 {
0033     QTC_RET_IF_FAIL(qtc_disp);
0034     XFlush((Display*)qtc_disp);
0035 }
0036 
0037 QTC_EXPORT void
0038 qtcX11Flush()
0039 {
0040     QTC_RET_IF_FAIL(qtc_xcb_conn);
0041     xcb_flush(qtc_xcb_conn);
0042 }
0043 
0044 QTC_EXPORT uint32_t
0045 qtcX11GenerateId()
0046 {
0047     QTC_RET_IF_FAIL(qtc_xcb_conn, 0);
0048     return xcb_generate_id(qtc_xcb_conn);
0049 }
0050 
0051 QTC_EXPORT void
0052 qtcX11ChangeProperty(uint8_t mode, xcb_window_t win, xcb_atom_t prop,
0053                      xcb_atom_t type, uint8_t format, uint32_t len,
0054                      const void *data)
0055 {
0056     qtcX11CallVoid(change_property, mode, win, prop, type, format, len, data);
0057 }
0058 
0059 QTC_EXPORT xcb_query_tree_reply_t*
0060 qtcX11QueryTree(xcb_window_t win)
0061 {
0062     return qtcX11Call(query_tree, win);
0063 }
0064 
0065 QTC_EXPORT void
0066 qtcX11ReparentWindow(xcb_window_t win, xcb_window_t parent,
0067                      int16_t x, int16_t y)
0068 {
0069     qtcX11CallVoid(reparent_window, win, parent, x, y);
0070 }
0071 
0072 QTC_EXPORT void
0073 qtcX11SendEvent(uint8_t propagate, xcb_window_t destination,
0074                 uint32_t event_mask, const void *event)
0075 {
0076     qtcX11CallVoid(send_event, propagate, destination, event_mask,
0077                    (const char*)event);
0078 }
0079 
0080 QTC_EXPORT xcb_get_property_reply_t*
0081 qtcX11GetProperty(uint8_t del, xcb_window_t win, xcb_atom_t prop,
0082                   xcb_atom_t type, uint32_t offset, uint32_t len)
0083 {
0084     return qtcX11Call(get_property, del, win, prop, type, offset, len);
0085 }
0086 
0087 QTC_EXPORT void*
0088 qtcX11GetPropertyValue(const xcb_get_property_reply_t *reply)
0089 {
0090     return xcb_get_property_value(reply);
0091 }
0092 
0093 QTC_EXPORT int
0094 qtcX11GetPropertyValueLength(const xcb_get_property_reply_t *reply)
0095 {
0096     return xcb_get_property_value_length(reply);
0097 }
0098 
0099 #else
0100 
0101 QTC_EXPORT void
0102 qtcX11FlushXlib()
0103 {
0104 }
0105 
0106 QTC_EXPORT void
0107 qtcX11Flush()
0108 {
0109 }
0110 
0111 QTC_EXPORT uint32_t
0112 qtcX11GenerateId()
0113 {
0114     return 0;
0115 }
0116 
0117 QTC_EXPORT void
0118 qtcX11ChangeProperty(uint8_t, xcb_window_t, xcb_atom_t, xcb_atom_t,
0119                      uint8_t, uint32_t, const void*)
0120 {
0121 }
0122 
0123 QTC_EXPORT xcb_query_tree_reply_t*
0124 qtcX11QueryTree(xcb_window_t)
0125 {
0126     return nullptr;
0127 }
0128 
0129 QTC_EXPORT void
0130 qtcX11ReparentWindow(xcb_window_t, xcb_window_t, int16_t, int16_t)
0131 {
0132 }
0133 
0134 QTC_EXPORT void
0135 qtcX11SendEvent(uint8_t, xcb_window_t, uint32_t, const void*)
0136 {
0137 }
0138 
0139 QTC_EXPORT xcb_get_property_reply_t*
0140 qtcX11GetProperty(uint8_t, xcb_window_t, xcb_atom_t, xcb_atom_t,
0141                   uint32_t, uint32_t)
0142 {
0143     return nullptr;
0144 }
0145 
0146 QTC_EXPORT void*
0147 qtcX11GetPropertyValue(const xcb_get_property_reply_t*)
0148 {
0149     return nullptr;
0150 }
0151 
0152 QTC_EXPORT int
0153 qtcX11GetPropertyValueLength(const xcb_get_property_reply_t*)
0154 {
0155     return 0;
0156 }
0157 
0158 #endif