Skip to content

Commit

Permalink
fix for window z-index
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Sep 5, 2024
1 parent 521d8b6 commit dc050dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/app/system-apps/window/window.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
position: absolute;
min-width: 25%;
min-height: 10%;
/*max-width: 100%; Set the width of the parent container */
/*max-height: 100%; Set the height of the parent container */
top: 40%;
left: 15%;
/* transform: translate(-50%, -50%); */
/* Move the element back by 50% of its own width and height */
outline: 1px hsl(0deg 0% 20%/70%);
overflow:hidden;
z-index: 2;
/*max-width: 100%; Set the width of the parent container */
/*max-height: 100%; Set the height of the parent container */
/* transform: translate(-50%, -50%); */
/* Move the element back by 50% of its own width and height */
/* z-index: 2; */
}

.header-container{
Expand Down
38 changes: 25 additions & 13 deletions src/app/system-apps/window/window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ import { TaskBarPreviewImage } from 'src/app/system-apps/taskbarpreview/taskbar.
private _focusOnCurrentProcessSub!:Subscription;
private _focusOutOtherProcessSub!:Subscription;

SECONDS_DELAY = 350;
WINDOW_CAPTURE_SECONDS_DELAY = 5000;

readonly SECONDS_DELAY = 350;
readonly WINDOW_CAPTURE_SECONDS_DELAY = 5000;
readonly MIN_Z_INDEX = 1;
readonly MAX_Z_INDEX = 2;

windowHide = false;
windowMaximize = false;
Expand Down Expand Up @@ -122,10 +123,11 @@ import { TaskBarPreviewImage } from 'src/app/system-apps/taskbarpreview/taskbar.
this.defaultHeightOnOpen = this.getDivWindowElement.offsetHeight;
this.defaultWidthOnOpen = this.getDivWindowElement.offsetWidth;

const z_index = this._stateManagmentService.getState(this.z_index) as number;
this.windowTransform = 'translate(0, 0)';
this.windowHeight = `${String(this.defaultHeightOnOpen)}px`;
this.windowWidth = `${String(this.defaultWidthOnOpen)}px`;
this.windowZIndex = '2';
this.windowZIndex = (z_index === undefined)? String(this.MAX_Z_INDEX) : String(z_index);

this._originalWindowsState = {
app_name: this.name,
Expand All @@ -134,7 +136,7 @@ import { TaskBarPreviewImage } from 'src/app/system-apps/taskbarpreview/taskbar.
width: this.defaultWidthOnOpen,
x_axis: 0,
y_axis: 0,
z_index:2,
z_index:(z_index === undefined)? this.MAX_Z_INDEX : z_index,
is_visible:true
}

Expand Down Expand Up @@ -260,13 +262,24 @@ import { TaskBarPreviewImage } from 'src/app/system-apps/taskbarpreview/taskbar.

onHideBtnClick(pid:number):void{
if(this.processId == pid){
this.setHideAndShow()
this.setHideAndShow();
}
}

restoreHiddenWindow(pid:number):void{
if(this.processId == pid){
this.setHideAndShow()
this.setHideAndShow();
}
}

updateWindowZIndex(window: WindowState):void{
if(this.processId == window.pid){
this.currentStyles = {
'z-index':this.MIN_Z_INDEX
};
window.z_index = this.MIN_Z_INDEX;
const uid = `${window.app_name}-${window.pid}`;
this._stateManagmentService.addState(uid, window, StateType.Window);
}
}

Expand Down Expand Up @@ -389,30 +402,29 @@ import { TaskBarPreviewImage } from 'src/app/system-apps/taskbarpreview/taskbar.

if(window != undefined && window.is_visible){
this.setHeaderInActive(window.pid);
this.updateWindowZIndex(window);
}
}
}

setWindowToFocusById(pid:number):void{
let z_index = this._stateManagmentService.getState(this.z_index) as number;

const uid = `${this.name}-${pid}`;
const windowState = this._stateManagmentService.getState(uid,StateType.Window) as WindowState;

if(windowState !== undefined){
if((windowState.pid == pid) && (windowState.z_index != z_index)){
if((windowState.pid == pid) && (!z_index) || (windowState.pid == pid) && (windowState.z_index <= z_index)){
z_index = this.MAX_Z_INDEX;
this._stateManagmentService.addState(this.z_index, z_index);

if (!z_index ? z_index = 1 : z_index = z_index + 1)
this._stateManagmentService.addState(this.z_index,z_index);

windowState.z_index = z_index
this._stateManagmentService.addState(this.uniqueId, windowState, StateType.Window);

this.currentStyles = {
'z-index':z_index
};
this.setHeaderActive(pid);
}
}
}
}

Expand Down

0 comments on commit dc050dc

Please sign in to comment.