Skip to content

Commit

Permalink
Track and show window focus
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Jan 1, 2020
1 parent 00d873b commit 565178f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
7 changes: 7 additions & 0 deletions classic.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ button.selected {
color: white;
font-family: 'Segoe UI', sans-serif;
font-size: 12px;
font-weight: bold;
}
.window:not(.focused) .window-titlebar {
background: darkgray;
background: linear-gradient(to right, #808080 0%, #b3b3b3 100%);

color: #c0c0c0;
}
.window-title {
padding-left: 2px;
Expand Down
19 changes: 18 additions & 1 deletion src/$Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ function $Window(options){
if($component){
$w.addClass("component-window");
}


$w.on("focusin iframe-focusin pointerdown", function(e){
if (!$w.hasClass("focused")) {
$w.triggerHandler("focus");
}
});
$w.on("focus", function(e){
if ($w.is(e.target)) {
$(".window.focused").triggerHandler("blur");
$w.addClass("focused");
}
});
$w.on("blur", function(e){
if ($w.is(e.target)) {
$w.removeClass("focused");
}
});

$w.attr("touch-action", "none");

$w.$x.on("click", function(){
Expand Down
5 changes: 0 additions & 5 deletions src/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function Task($win){
}
$win.on("focus", function(e){
if ($win.is(e.target)) {
$(".task").removeClass("selected");
$task.addClass("selected");
}
})
Expand All @@ -35,10 +34,6 @@ function Task($win){
$task.removeClass("selected");
}
})
$win.on("focusin iframe-focusin", function(e){
$(".task").removeClass("selected");
$win.triggerHandler("focus");
});
$win.on("close", function(){
$task.remove();
});
Expand Down
1 change: 0 additions & 1 deletion src/programs.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ function openWinamp(file_path){
.then(function(){
console.log("Webamp rendered");
// TODO: handle blurring for taskbar
// also for regular windows - maybe I should do that first!

// TODO: refactor for less hackiness
$fake_win_for_winamp_task = $("#webamp");
Expand Down

0 comments on commit 565178f

Please sign in to comment.