-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJuceMurkaBaseComponent.mm
78 lines (62 loc) · 2.13 KB
/
JuceMurkaBaseComponent.mm
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
68
69
70
71
72
73
74
75
76
77
78
#include <juce_opengl/juce_opengl.h>
#include <AppKit/NSOpenGL.h>
#include <AppKit/NSWindow.h>
#include "JuceMurkaBaseComponent.h"
using namespace murka;
void JuceMurkaBaseComponent::makeTransparent()
{
NSView* handle = (NSView*)getWindowHandle();
NSWindow* window = [handle window];
[window setAcceptsMouseMovedEvents: YES];
[window setIgnoresMouseEvents:NO];
[window setOpaque:NO];
/*
[window setLevel:NSMainMenuWindowLevel + 1];
[window setAlphaValue: 1.0];
[window setHasShadow: NO];
[window setMovableByWindowBackground: NO];
[window setCanBecomeKeyWindow: YES];
[window setAcceptsMouseMovedEvents: YES];
setOpaque(false);
*/
NSOpenGLContext* context = (NSOpenGLContext*)openGLContext.getRawContext();
GLint aValue = 0;
[context setValues : &aValue forParameter : NSOpenGLCPSurfaceOpacity];
}
void JuceMurkaBaseComponent::checkMainWindow()
{
bool windowWasFocused = isWindowFocused;
NSView* handle = (NSView*)getWindowHandle();
if(handle) {
NSWindow* window = [handle window];
isWindowFocused = [window isMainWindow];
} else {
isWindowFocused = false;
}
if (windowWasFocused && !isWindowFocused) {
// Just unfocused the window, let's send the key releases.
// Releasing normal keys
for (auto &key: keysPressed) {
keysPressed.erase(key.first);
int k = convertKey(key.first);
m.registerKeyReleased(k >= 0 ? k : juce::KeyPress(key.first).getTextCharacter());
}
// Releasing modifier keys
if (shiftKeyPressed) {
m.registerKeyReleased(murka::MurkaKey::MURKA_KEY_SHIFT);
shiftKeyPressed = false;
}
if (ctrlKeyPressed) {
m.registerKeyReleased(murka::MurkaKey::MURKA_KEY_CONTROL);
ctrlKeyPressed = false;
}
if (altKeyPressed) {
m.registerKeyReleased(murka::MurkaKey::MURKA_KEY_ALT);
altKeyPressed = false;
}
if (commandKeyPressed) {
m.registerKeyReleased(murka::MurkaKey::MURKA_KEY_COMMAND);
commandKeyPressed = false;
}
}
}