[qwaq] Fix window closure

Now the device windows close properly when an input device is removed.
This commit is contained in:
Bill Currie 2021-09-26 10:07:34 +09:00
parent 192b76ddc6
commit ac25d9f1c1
14 changed files with 49 additions and 4 deletions

View file

@ -52,6 +52,7 @@ free_defs (LocalsData *self)
obj_free (data); obj_free (data);
data = nil; data = nil;
} }
[super dealloc];
} }
-setFunction:(unsigned) fnum -setFunction:(unsigned) fnum

View file

@ -57,6 +57,7 @@
} }
obj_free (element_views); obj_free (element_views);
obj_free (element_rows); obj_free (element_rows);
[super dealloc];
} }
-draw -draw

View file

@ -26,6 +26,7 @@
obj_free (ptr_data); obj_free (ptr_data);
} }
[ptr_view release]; [ptr_view release];
[super dealloc];
} }
-draw -draw

View file

@ -64,6 +64,7 @@
} }
obj_free (field_views); obj_free (field_views);
obj_free (field_rows); obj_free (field_rows);
[super dealloc];
} }
-draw -draw

View file

@ -22,7 +22,7 @@
-draw -draw
{ {
[super draw]; [super draw];
[self mvprintf:{0, 0}, "%*.*d", xlen, xlen, axis.value]; [self mvprintf:{0, 0}, "%*d", xlen, axis.value];
return self; return self;
} }

View file

@ -20,6 +20,8 @@
-updateAxis:(int)axis value:(int)value; -updateAxis:(int)axis value:(int)value;
-updateButton:(int)button state:(int)state; -updateButton:(int)button state:(int)state;
-(int)devid; -(int)devid;
-(string)name;
-(string)id;
-redraw; -redraw;
@end @end

View file

@ -43,13 +43,15 @@
-(void)dealloc -(void)dealloc
{ {
[application removeView:window];
[axis_data release];
obj_free (device.axes); obj_free (device.axes);
obj_free (device.buttons); obj_free (device.buttons);
str_free (device.name); str_free (device.name);
str_free (device.id); str_free (device.id);
obj_free (device); obj_free (device);
[super dealloc];
[application removeView:window];
} }
-updateAxis:(int)axis value:(int)value -updateAxis:(int)axis value:(int)value
@ -68,6 +70,16 @@
return devid; return devid;
} }
-(string)name
{
return device.name;
}
-(string)id
{
return device.id;
}
-redraw -redraw
{ {
[axis_view redraw]; [axis_view redraw];

View file

@ -111,6 +111,7 @@ arp_end (void)
Device *device = [Device withDevice:dev id:devid]; Device *device = [Device withDevice:dev id:devid];
[devices addObject:device]; [devices addObject:device];
} }
event.what = qe_none;
break; break;
case qe_dev_rem: case qe_dev_rem:
for (int i = [devices count]; i-- > 0; ) { for (int i = [devices count]; i-- > 0; ) {
@ -120,6 +121,7 @@ arp_end (void)
break; break;
} }
} }
event.what = qe_none;
break; break;
case qe_axis: case qe_axis:
for (int i = [devices count]; i-- > 0; ) { for (int i = [devices count]; i-- > 0; ) {
@ -131,6 +133,7 @@ arp_end (void)
break; break;
} }
} }
event.what = qe_none;
break; break;
case qe_button: case qe_button:
for (int i = [devices count]; i-- > 0; ) { for (int i = [devices count]; i-- > 0; ) {
@ -142,6 +145,7 @@ arp_end (void)
break; break;
} }
} }
event.what = qe_none;
break; break;
} }
if (event.what != qe_none) { if (event.what != qe_none) {

View file

@ -15,6 +15,7 @@
@end @end
@protocol TextContext @protocol TextContext
- (void) release;
- blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect; - blitFromBuffer: (DrawBuffer *) srcBuffer to: (Point) pos from: (Rect) rect;
- clearReact: (Rect) rect; - clearReact: (Rect) rect;
- (Extent) size; - (Extent) size;

View file

@ -71,7 +71,9 @@
{ {
int index = [views indexOfObject: view]; int index = [views indexOfObject: view];
if (index != NotFound) { if (index != NotFound) {
[views removeObjectAtIndex: index];
if (focused == index) { if (focused == index) {
focused--;
[self selectPrev]; [self selectPrev];
if (focused == index) { if (focused == index) {
focused = -1; focused = -1;
@ -79,7 +81,6 @@
} else if (focused > index) { } else if (focused > index) {
focused--; focused--;
} }
[views removeObjectAtIndex: index];
if (mouse_within == view) { if (mouse_within == view) {
mouse_within = nil; mouse_within = nil;
} }

View file

@ -73,6 +73,13 @@ static TextContext *screen;
return self; return self;
} }
-(void)delloc
{
if (window != stdscr) {
destroy_window (window);
}
}
-(window_t) window -(window_t) window
{ {
return window; return window;

View file

@ -12,6 +12,7 @@
+(TitleBar *)withTitle:(string)title; +(TitleBar *)withTitle:(string)title;
-initWithTitle:(string)title; -initWithTitle:(string)title;
-setTitle:(string)newTitle; -setTitle:(string)newTitle;
-(string)title;
@end @end
#endif//__qwaq_ui_titlebar_h #endif//__qwaq_ui_titlebar_h

View file

@ -29,6 +29,11 @@
return self; return self;
} }
-(string)title
{
return title;
}
-setOwner: (Group *) owner -setOwner: (Group *) owner
{ {
[super setOwner: owner]; [super setOwner: owner];

View file

@ -71,6 +71,14 @@
return self; return self;
} }
-(void)dealloc
{
destroy_panel (panel);
[textContext release];
[objects release];
[super dealloc];
}
-updateScreenCursor -updateScreenCursor
{ {
window_t window = [(id)textContext window]; window_t window = [(id)textContext window];