aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/libLumina/NativeEmbedWidget.h
blob: 7e129fa3b421a5d0c92168675ea4ba2d39962eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//===========================================
//  Lumina-DE source code
//  Copyright (c) 2017, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
//  This is a container object for embedding a native window into a QWidget
//    and maintaining a 1-to-1 mapping of sizing and other properties
//    while also providing compositing effects between the two windows
//===========================================
#ifndef _LUMINA_NATIVE_EMBED_WIDGET_H
#define _LUMINA_NATIVE_EMBED_WIDGET_H

#include "NativeWindow.h"
#include <QWidget>
#include <QTimer>
#include <QResizeEvent>
#include <QShowEvent>
#include <QHideEvent>
#include <QPaintEvent>

class NativeEmbedWidget : public QWidget{
	Q_OBJECT
private:
	NativeWindow *WIN;
	QSize winSize;
	QImage winImage;
	bool paused;

private slots:
	//Simplification functions
	void syncWinSize(QSize sz = QSize());
	void syncWidgetSize(QSize sz);
	void hideWindow();
	void showWindow();
	QImage windowImage(QRect geom);


public:
	NativeEmbedWidget(QWidget *parent);

	bool embedWindow(NativeWindow *window);
	bool detachWindow();
	bool isEmbedded(); //status of the embed

public slots:
	void raiseWindow();

	//Pause/resume
	void pause();
	void resume();

	void resyncWindow();
	void repaintWindow();
	void reregisterEvents();

protected:
	void resizeEvent(QResizeEvent *ev);
	void showEvent(QShowEvent *ev);
	void hideEvent(QHideEvent *ev);
	void paintEvent(QPaintEvent *ev);
	void enterEvent(QEvent *ev);
	void leaveEvent(QEvent *ev);
	bool nativeEvent(const QByteArray &eventType, void *message, long *result);
};

#endif
bgstack15