Browse Source

Update DGL

tags/2018-04-16
falkTX 10 years ago
parent
commit
c05ee5c2c9
4 changed files with 68 additions and 51 deletions
  1. +14
    -6
      libs/dgl/src/Window.cpp
  2. +20
    -45
      libs/dgl/src/pugl/pugl_osx.m
  3. +1
    -0
      libs/dgl/src/pugl/pugl_osx_extended.h
  4. +33
    -0
      libs/dgl/src/pugl/pugl_osx_extended.m

+ 14
- 6
libs/dgl/src/Window.cpp View File

@@ -80,6 +80,8 @@ public:
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#elif defined(DGL_OS_MAC)
fNeedsIdle(true)
#else
_dummy('\0')
#endif
@@ -102,6 +104,8 @@ public:
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#elif defined(DGL_OS_MAC)
fNeedsIdle(false)
#else
_dummy('\0')
#endif
@@ -129,6 +133,8 @@ public:
#elif defined(DGL_OS_LINUX)
xDisplay(nullptr),
xWindow(0)
#elif defined(DGL_OS_MAC)
fNeedsIdle(false)
#else
_dummy('\0')
#endif
@@ -241,12 +247,7 @@ public:
{
for (; fVisible && fModal.enabled;)
{
// idle()
puglProcessEvents(fView);

if (fModal.parent != nullptr)
fModal.parent->idle();

idle();
msleep(10);
}

@@ -492,6 +493,11 @@ public:
{
puglProcessEvents(fView);

#ifdef DGL_OS_MAC
if (fNeedsIdle)
puglImplIdle(fView);
#endif

if (fModal.enabled && fModal.parent != nullptr)
fModal.parent->idle();
}
@@ -713,6 +719,8 @@ private:
#elif defined(DGL_OS_LINUX)
Display* xDisplay;
::Window xWindow;
#elif defined(DGL_OS_MAC)
bool fNeedsIdle;
#else
char _dummy;
#endif


+ 20
- 45
libs/dgl/src/pugl/pugl_osx.m View File

@@ -36,7 +36,6 @@
defer:(BOOL)flag;
- (void) setPuglview:(PuglView*)view;
- (BOOL) windowShouldClose:(id)sender;
- (BOOL) canBecomeKeyWindow:(id)sender;
@end

@implementation PuglWindow
@@ -56,12 +55,15 @@
[result setLevel: CGShieldingWindowLevel() + 1];

return result;

// unused
(void)aStyle; (void)bufferingType; (void)flag;
}

- (void)setPuglview:(PuglView*)view
{
puglview = view;
[self setContentSize:NSMakeSize(view->width, view->height) ];
[self setContentSize:NSMakeSize(view->width, view->height)];
}

- (BOOL)windowShouldClose:(id)sender
@@ -69,16 +71,14 @@
if (puglview->closeFunc)
puglview->closeFunc(puglview);
return YES;
}

- (BOOL) canBecomeKeyWindow:(id)sender
{
return NO;
// unused
(void)sender;
}

@end

void
static void
puglDisplay(PuglView* view)
{
if (view->displayFunc) {
@@ -182,6 +182,9 @@ puglDisplay(PuglView* view)
puglDisplay(puglview);
glFlush();
glSwapAPPLE();

// unused
return; (void)rect;
}

static unsigned
@@ -191,10 +194,6 @@ getModifiers(PuglView* view, NSEvent* ev)

view->event_timestamp_ms = fmod([ev timestamp] * 1000.0, UINT32_MAX);

double ts = [ev timestamp] * 1000.0;
ts = (uint32)ts % 500000; //ridiculously large vals won't fit
view->event_timestamp_ms = ts;

unsigned mods = 0;
mods |= (modifierFlags & NSShiftKeyMask) ? PUGL_MOD_SHIFT : 0;
mods |= (modifierFlags & NSControlKeyMask) ? PUGL_MOD_CTRL : 0;
@@ -223,10 +222,15 @@ getModifiers(PuglView* view, NSEvent* ev)
- (void)mouseEntered:(NSEvent*)theEvent
{
[self updateTrackingAreas];

// unused
return; (void)theEvent;
}

- (void)mouseExited:(NSEvent*)theEvent
{
// unused
return; (void)theEvent;
}

- (void) mouseMoved:(NSEvent*)event
@@ -345,7 +349,6 @@ getModifiers(PuglView* view, NSEvent* ev)
struct PuglInternalsImpl {
PuglOpenGLView* glview;
id window;
bool isEmbed;
};

PuglView*
@@ -379,9 +382,8 @@ puglCreate(PuglNativeWindow parent,
[window setPuglview:view];
[window setTitle:titleString];

impl->glview = [PuglOpenGLView new];
impl->window = window;
impl->isEmbed = (parent != 0);
impl->glview = [PuglOpenGLView new];
impl->window = window;
impl->glview->puglview = view;

[window setContentView:impl->glview];
@@ -395,6 +397,9 @@ puglCreate(PuglNativeWindow parent,
}

return view;

// unused
(void)parent; (void)resizable;
}

void
@@ -411,36 +416,6 @@ puglDestroy(PuglView* view)
PuglStatus
puglProcessEvents(PuglView* view)
{
if (! view->impl->isEmbed)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSEvent* event;

static const NSUInteger eventMask = (NSLeftMouseDownMask | NSLeftMouseUpMask |
NSRightMouseDownMask | NSRightMouseUpMask |
NSMouseMovedMask |
NSLeftMouseDraggedMask | NSRightMouseDraggedMask |
NSMouseEnteredMask | NSMouseExitedMask |
NSKeyDownMask | NSKeyUpMask |
NSFlagsChangedMask |
NSCursorUpdateMask | NSScrollWheelMask);

for (;;) {
event = [view->impl->window
nextEventMatchingMask:eventMask
untilDate:[NSDate distantPast]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];

if (event == nil)
break;

[view->impl->window sendEvent: event];
}

[pool release];
}

[view->impl->glview setNeedsDisplay: YES];

return PUGL_SUCCESS;


+ 1
- 0
libs/dgl/src/pugl/pugl_osx_extended.h View File

@@ -27,6 +27,7 @@
extern "C" {
#endif

void puglImplIdle(PuglView* view);
void puglImplFocus(PuglView* view);
void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bool forced);
void puglImplSetTitle(PuglView* view, const char* title);


+ 33
- 0
libs/dgl/src/pugl/pugl_osx_extended.m View File

@@ -23,6 +23,36 @@

#include "pugl_osx_extended.h"

void puglImplIdle(PuglView* view)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSEvent* event;

static const NSUInteger eventMask = (NSLeftMouseDownMask | NSLeftMouseUpMask |
NSRightMouseDownMask | NSRightMouseUpMask |
NSMouseMovedMask |
NSLeftMouseDraggedMask | NSRightMouseDraggedMask |
NSMouseEnteredMask | NSMouseExitedMask |
NSKeyDownMask | NSKeyUpMask |
NSFlagsChangedMask |
NSCursorUpdateMask | NSScrollWheelMask);

for (;;) {
event = [view->impl->window
nextEventMatchingMask:eventMask
untilDate:[NSDate distantPast]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];

if (event == nil)
break;

[view->impl->window sendEvent: event];
}

[pool release];
}

void puglImplFocus(PuglView* view)
{
id window = view->impl->window;
@@ -46,6 +76,9 @@ void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bo
// } else {
[window setFrame:frame display:YES animate:NO];
// }

// unused
return; (void)forced;
}

void puglImplSetTitle(PuglView* view, const char* title)


Loading…
Cancel
Save