ba3e8f9779
- We were using the wrong keycodes for letters, so we never triggered undo/redo/copy/paste in response to Ctrl+Letter combos. - ImGui comes with system clipboard support on Windows and Mac, but not UNIX/Linux. I added a bare bones X11 implementation, enough to support copying and pasting text in and out of the ImGui text windows. There is a bit of a delay when pasting to another program, probably because we're not running a dedicated thread to handle those events. It looks like we get a flurry of events before the real SelectionRequest. - Note that this leaves the virtual clipboard functions on Window only implemented for UNIX. We could supply our own copies for Win/Mac and other platforms, if anyone really cares. Change-Id: I2701e077ff2b6dff5ae3c5127c24b0937b893c89 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334049 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
111 lines
2.4 KiB
C++
111 lines
2.4 KiB
C++
/*
|
|
* Copyright 2016 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef Window_unix_DEFINED
|
|
#define Window_unix_DEFINED
|
|
|
|
#include "include/private/SkChecksum.h"
|
|
#include "src/core/SkTDynamicHash.h"
|
|
#include "tools/sk_app/Window.h"
|
|
|
|
#include <GL/glx.h>
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <string>
|
|
|
|
typedef Window XWindow;
|
|
|
|
namespace sk_app {
|
|
|
|
class Window_unix : public Window {
|
|
public:
|
|
Window_unix()
|
|
: Window()
|
|
, fDisplay(nullptr)
|
|
, fWindow(0)
|
|
, fGC(nullptr)
|
|
, fFBConfig(nullptr)
|
|
, fVisualInfo(nullptr)
|
|
, fMSAASampleCount(1) {}
|
|
~Window_unix() override { this->closeWindow(); }
|
|
|
|
bool initWindow(Display* display);
|
|
|
|
void setTitle(const char*) override;
|
|
void show() override;
|
|
|
|
const char* getClipboardText() override;
|
|
void setClipboardText(const char*) override;
|
|
|
|
bool attach(BackendType) override;
|
|
|
|
void onInval() override;
|
|
|
|
bool handleEvent(const XEvent& event);
|
|
|
|
static const XWindow& GetKey(const Window_unix& w) {
|
|
return w.fWindow;
|
|
}
|
|
|
|
static uint32_t Hash(const XWindow& w) {
|
|
return SkChecksum::Mix(w);
|
|
}
|
|
|
|
static SkTDynamicHash<Window_unix, XWindow> gWindowMap;
|
|
|
|
void markPendingPaint() { fPendingPaint = true; }
|
|
void finishPaint() {
|
|
if (fPendingPaint) {
|
|
this->onPaint();
|
|
fPendingPaint = false;
|
|
}
|
|
}
|
|
|
|
void markPendingResize(int width, int height) {
|
|
if (width != this->width() || height != this->height()){
|
|
fPendingResize = true;
|
|
fPendingWidth = width;
|
|
fPendingHeight = height;
|
|
}
|
|
}
|
|
void finishResize() {
|
|
if (fPendingResize) {
|
|
this->onResize(fPendingWidth, fPendingHeight);
|
|
fPendingResize = false;
|
|
}
|
|
}
|
|
|
|
void setRequestedDisplayParams(const DisplayParams&, bool allowReattach) override;
|
|
|
|
private:
|
|
void closeWindow();
|
|
|
|
Display* fDisplay;
|
|
XWindow fWindow;
|
|
GC fGC;
|
|
GLXFBConfig* fFBConfig;
|
|
XVisualInfo* fVisualInfo;
|
|
int fMSAASampleCount;
|
|
|
|
Atom fWmDeleteMessage;
|
|
|
|
bool fPendingPaint;
|
|
int fPendingWidth;
|
|
int fPendingHeight;
|
|
bool fPendingResize;
|
|
|
|
BackendType fBackend;
|
|
|
|
std::string fClipboardText;
|
|
|
|
using INHERITED = Window;
|
|
};
|
|
|
|
} // namespace sk_app
|
|
|
|
#endif
|