Chatterino
AttachedWindow.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ForwardDecl.hpp"
4 
5 #include <QTimer>
6 #include <QWidget>
7 #include <memory>
8 
9 namespace chatterino {
10 
11 class Split;
12 class Channel;
13 using ChannelPtr = std::shared_ptr<Channel>;
14 
15 class AttachedWindow : public QWidget
16 {
17  AttachedWindow(void *_target, int _yOffset);
18 
19 public:
20  struct GetArgs {
21  QString winId;
22  int yOffset = -1;
23  double x = -1;
24  double pixelRatio = -1;
25  int width = -1;
26  int height = -1;
27  bool fullscreen = false;
28  };
29 
30  virtual ~AttachedWindow() override;
31 
32  static AttachedWindow *get(void *target_, const GetArgs &args);
33  static void detach(const QString &winId);
34 
35  void setChannel(ChannelPtr channel);
36 
37 protected:
38  virtual void showEvent(QShowEvent *) override;
39  // virtual void nativeEvent(const QByteArray &eventType, void *message,
40  // long *result) override;
41 
42 private:
43  struct {
45  } ui_;
46 
47  struct Item {
48  void *hwnd;
49  AttachedWindow *window;
50  QString winId;
51  };
52 
53  static std::vector<Item> items;
54 
55  void attachToHwnd(void *attached);
56  void updateWindowRect(void *attached);
57 
58  void *target_;
59  int yOffset_;
60  int currentYOffset_;
61  double x_ = -1;
62  double pixelRatio_ = -1;
63  int width_ = 360;
64  int height_ = -1;
65  bool fullscreen_ = false;
66 
67 #ifdef USEWINSDK
68  bool validProcessName_ = false;
69  bool attached_ = false;
70 #endif
71  QTimer timer_;
72  QTimer slowTimer_;
73 };
74 
75 } // namespace chatterino
int height
Definition: AttachedWindow.hpp:26
Definition: AttachedWindow.hpp:20
static void detach(const QString &winId)
Definition: AttachedWindow.cpp:136
Definition: Application.cpp:48
Definition: Split.hpp:36
QString winId
Definition: AttachedWindow.hpp:21
virtual void showEvent(QShowEvent *) override
Definition: AttachedWindow.cpp:152
void setChannel(ChannelPtr channel)
Definition: AttachedWindow.cpp:147
bool fullscreen
Definition: AttachedWindow.hpp:27
int yOffset
Definition: AttachedWindow.hpp:22
int width
Definition: AttachedWindow.hpp:25
Split * split
Definition: AttachedWindow.hpp:44
virtual ~AttachedWindow() override
Definition: AttachedWindow.cpp:62
double pixelRatio
Definition: AttachedWindow.hpp:24
std::shared_ptr< Channel > ChannelPtr
Definition: Channel.hpp:125
double x
Definition: AttachedWindow.hpp:23
Definition: AttachedWindow.hpp:15