1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Add native Mac bridge code for window level settings

This commit is contained in:
Dominik Louven 2018-11-27 11:31:00 +01:00
parent 2b3c69c1c6
commit ba7d04c034
2 changed files with 44 additions and 3 deletions

View File

@ -0,0 +1,30 @@
#include "macbridge.h"
#import <Cocoa/Cocoa.h>
#import <objc/runtime.h>
#include <QApplication>
#include <QWindow>
MacBridge * MacBridge::bridge = NULL;
MacBridge::MacBridge()
{
}
MacBridge * MacBridge::instance()
{
if(!bridge)
bridge = new MacBridge;
return bridge;
}
void MacBridge::SetBackgroundLevel(QWindow* window)
{
NSView* view = (NSView *) window->winId();
NSWindow* nsWindow = (NSWindow*)[view window];
[nsWindow setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
[nsWindow setBackgroundColor: [NSColor blackColor]];
[nsWindow setAcceptsMouseMovedEvents: false];
[nsWindow setMovableByWindowBackground: false];
}

View File

@ -1,4 +1,15 @@
#ifndef MACBRIDGE_H
#define MACBRIDGE_H
#pragma once
#endif // MACBRIDGE_H
#include <QApplication>
class MacBridge : public QObject
{
Q_OBJECT
private:
static MacBridge* bridge;
MacBridge();
public:
static MacBridge* instance();
static void SetBackgroundLevel(QWindow* window);
};