Skip to content

Commit

Permalink
resolved event reponse doubling
Browse files Browse the repository at this point in the history
  • Loading branch information
chinonso098 committed Nov 4, 2023
1 parent 9db7207 commit 24c0f18
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/shared/system-service/running.process.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class RunningProcessService{
focusOnCurrentProcessNotify: Subject<number> = new Subject<number>();
focusOutOtherProcessNotify: Subject<number> = new Subject<number>();
restoreOrMinimizeWindowNotify: Subject<number> = new Subject<number>();
responseToEventCount = 0;

constructor(){
this._runningProcesses = []
Expand Down
21 changes: 17 additions & 4 deletions src/app/system-apps/desktop/desktop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,26 @@ export class DesktopComponent implements OnInit, OnDestroy, AfterViewInit{
}

showContextMenu(evt:MouseEvent):void{
this._runningProcessService.responseToEventCount++;
const evtRespCount = this._runningProcessService.responseToEventCount;

/**
* There is a doubling of responses to certain events that exist on the
* desktop compoonent and any other component running at the time the event was triggered.
* The desktop will always repond to the event, but other components will only respond when they are in focus.
* If there is a count of 2 or more(highly unlikely) reponses for a given event, then, ignore the desktop's response
*/
if(evtRespCount >= 2){
this._runningProcessService.responseToEventCount = 0
return;
}



const x = evt.clientX;
const y = evt.clientY;

this.cntxtMenuStyle = {
'width': '200px',
'height': 'fit-content',
'transform':`translate(${String(x)}px, ${String(y)}px)`,
'transform':`translate(${String(evt.clientX)}px, ${String(evt.clientY)}px)`,
'z-index': 2,
'opacity':1
}
Expand All @@ -161,6 +173,7 @@ export class DesktopComponent implements OnInit, OnDestroy, AfterViewInit{
// this._renderer.setStyle(this.cntxtMenu.nativeElement,'transform',`translate(${String(x)}px, ${String(y)}px)`);
// //this.showCntxtMenu = !this.showCntxtMenu;

this._runningProcessService.responseToEventCount = 0;
evt.preventDefault();
}

Expand Down
6 changes: 6 additions & 0 deletions src/app/system-apps/taskmanager/taskmanager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ export class TaskmanagerComponent implements BaseComponent,OnInit,OnDestroy,Afte
}

showTableHeaderList(evt:MouseEvent):void{
this._runningProcessService.responseToEventCount++;

const evtRespCount = this._runningProcessService.responseToEventCount;

console.log('evtRespCount-tskMgr:',evtRespCount);

this.showHeaderList = !this.showHeaderList;
evt.preventDefault();
}
Expand Down

0 comments on commit 24c0f18

Please sign in to comment.