| 143 | } |
| 144 | |
| 145 | bool XWindowsEventQueueBuffer::addEvent(uint32_t dataID) |
| 146 | { |
| 147 | // prepare a message |
| 148 | XEvent xevent; |
| 149 | xevent.xclient.type = ClientMessage; |
| 150 | xevent.xclient.window = m_window; |
| 151 | xevent.xclient.message_type = m_userEvent; |
| 152 | xevent.xclient.format = 32; |
| 153 | xevent.xclient.data.l[0] = static_cast<long>(dataID); |
| 154 | |
| 155 | // save the message |
| 156 | std::scoped_lock lock{m_mutex}; |
| 157 | m_postedEvents.push_back(xevent); |
| 158 | |
| 159 | // if we're currently waiting for an event then send saved events to |
| 160 | // the X server now. if we're not waiting then some other thread |
| 161 | // might be using the display connection so we can't safely use it |
| 162 | // too. |
| 163 | if (m_waiting) { |
| 164 | flush(); |
| 165 | // Send a character through the round-trip pipe to wake a thread |
| 166 | // that is waiting for a ConnectionNumber() socket to be readable. |
| 167 | // The flush call can read incoming data from the socket and put |
| 168 | // it in Xlib's input buffer. That sneaks it past the other thread. |
| 169 | ssize_t write_response = write(m_pipefd[1], "!", 1); |
| 170 | |
| 171 | // with linux automake, warnings are treated as errors by default |
| 172 | if (write_response < 0) { |
| 173 | // todo: handle read response |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | return true; |
| 178 | } |
| 179 | |
| 180 | bool XWindowsEventQueueBuffer::isEmpty() const |
| 181 | { |
nothing calls this directly
no outgoing calls
no test coverage detected