Browse Source

implement WM_DELETE_WINDOW

pull/1639/head
bsp2 6 years ago
parent
commit
81ff8a67b6
1 changed files with 33 additions and 3 deletions
  1. +33
    -3
      other/vst2_debug_host/vst2_debug_host.cpp

+ 33
- 3
other/vst2_debug_host/vst2_debug_host.cpp View File

@@ -217,6 +217,14 @@ void open_and_close(void) {
BlackPixel(d, s), WhitePixel(d, s) BlackPixel(d, s), WhitePixel(d, s)
); );
XSelectInput(d, w, ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | FocusChangeMask); XSelectInput(d, w, ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask | FocusChangeMask);

// see <https://stackoverflow.com/questions/1157364/intercept-wm-delete-window-on-x11>
Atom wm_delete_window;
{
wm_delete_window = XInternAtom(d, "WM_DELETE_WINDOW", False);
XSetWMProtocols(d, w, &wm_delete_window, 1);
}

XMapRaised(d, w); XMapRaised(d, w);
XFlush(d); XFlush(d);
#endif #endif
@@ -248,7 +256,8 @@ void open_and_close(void) {
if(result == 0) if(result == 0)
{ {
printf("xxx no XEventProc found, running effEditIdle instead\n"); printf("xxx no XEventProc found, running effEditIdle instead\n");
for(;;)
bool bRunning = true;
while(bRunning)
{ {
XEvent xev; XEvent xev;
int queued = XPending(d); int queued = XPending(d);
@@ -266,11 +275,25 @@ void open_and_close(void) {


queued = XPending(d); queued = XPending(d);
// printf("xxx checking host queue after effEditIdle (events: %i)\n", queued); // printf("xxx checking host queue after effEditIdle (events: %i)\n", queued);
while(queued)
while((queued > 0) && bRunning)
{ {
XNextEvent(d, &xev); XNextEvent(d, &xev);

// printf("xxx debug_host: xev.type=%d\n", xev.type);

if(ClientMessage == xev.type)
{
printf("xxx debug_host: ClientMessage\n");
if((Atom)xev.xclient.data.l[0] == wm_delete_window)
{
printf("xxx debug_host: ClientMessage<wm_delete_window>\n");
bRunning = false;
}
}

// if(MotionNotify != xev.type) // if(MotionNotify != xev.type)
// printf("xxx event type: %i\n", xev.type); // printf("xxx event type: %i\n", xev.type);

queued--; queued--;
} }


@@ -300,6 +323,8 @@ void open_and_close(void) {
sleep(1); sleep(1);
printf("xxx calling effect->dispatcher<effEditClose>\n"); printf("xxx calling effect->dispatcher<effEditClose>\n");
effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f); effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f);

#if 0
sleep(1); sleep(1);
printf("xxx calling effect->dispatcher<effEditOpen> again\n"); printf("xxx calling effect->dispatcher<effEditOpen> again\n");
#ifdef YAC_WIN32 #ifdef YAC_WIN32
@@ -311,14 +336,19 @@ void open_and_close(void) {
printf("xxx calling effect->dispatcher<effEditIdle>\n"); printf("xxx calling effect->dispatcher<effEditIdle>\n");
effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f); effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
sleep(1); sleep(1);
#endif

printf("xxx call processreplacing\n"); printf("xxx call processreplacing\n");
for(int i = 0; i < 1024; i++) for(int i = 0; i < 1024; i++)
{ {
effect->processReplacing(effect, inputBuffers, outputBuffers, (VstInt32)64); effect->processReplacing(effect, inputBuffers, outputBuffers, (VstInt32)64);
} }

#if 0
printf("xxx calling effect->dispatcher<effEditClose>\n"); printf("xxx calling effect->dispatcher<effEditClose>\n");
effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f); effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f);
sleep(1); sleep(1);
#endif
printf("xxx calling effect->dispatcher<effClose>\n"); printf("xxx calling effect->dispatcher<effClose>\n");
effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f); effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f);
sleep(1); sleep(1);
@@ -355,7 +385,7 @@ void open_and_close(void) {
} }


int main() { int main() {
for(int i = 0; i < 5; i++)
for(int i = 0; i < 2; i++)
{ {
open_and_close(); open_and_close();
} }


Loading…
Cancel
Save