MCPcopy Create free account
hub / github.com/material-shell/material-shell / kill

Method kill

src/layout/msWorkspace/msWindow.ts:1208–1267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1206 }
1207
1208 async kill() {
1209 const state = this.lifecycleState;
1210
1211 switch (state.type) {
1212 case 'window': {
1213 const dialogPromises = state.dialogs.map((dialog) => {
1214 return new Promise<void>((resolve) => {
1215 // TODO: When can this return false?
1216 if (
1217 dialog.metaWindow.get_compositor_private() as Meta.WindowActor
1218 ) {
1219 dialog.metaWindow.connect('unmanaged', (_) => {
1220 resolve();
1221 });
1222 dialog.metaWindow.delete(global.get_current_time());
1223 } else {
1224 resolve();
1225 }
1226 });
1227 });
1228
1229 const promise = new Promise<void>((resolve) => {
1230 if (
1231 state.metaWindow &&
1232 (state.metaWindow.get_compositor_private() as Meta.WindowActor)
1233 ) {
1234 state.metaWindow.connect('unmanaged', (_) => {
1235 resolve();
1236 });
1237 state.metaWindow.delete(global.get_current_time());
1238 } else {
1239 resolve();
1240 }
1241 });
1242
1243 await Promise.all([...dialogPromises, promise]);
1244 // The above code will call metaWindowUnManaged for all meta windows managed by this MsWindow which will handle all necessary cleanup.
1245 // Note that just because we call `delete` doesn't mean the windows will actually close. For example, some applications
1246 // show 'Do you want to save this document' dialogs which allow the user to cancel closing the window.
1247 break;
1248 }
1249 case 'app-placeholder': {
1250 if (this._persistent) {
1251 // Persistent app placeholders cannot be closed
1252 } else {
1253 // Note: This is here and not in _onDestroy because _onDestroy can sometimes be called when the workspace
1254 // has already been destroyed. TODO: This should be done in a better way.
1255 this.msWorkspace.removeMsWindow(this);
1256 this.destroy();
1257 }
1258 break;
1259 }
1260 case 'waiting-for-destroy':
1261 this.msWorkspace.removeMsWindow(this);
1262 this.destroy();
1263 break;
1264 case 'destroyed':
1265 break;

Callers 1

metaWindowUnManagedMethod · 0.95

Calls 7

removeMsWindowMethod · 0.80
mapMethod · 0.65
connectMethod · 0.65
deleteMethod · 0.65
get_current_timeMethod · 0.65
destroyMethod · 0.65

Tested by

no test coverage detected