File tree Expand file tree Collapse file tree 5 files changed +23
-11
lines changed Expand file tree Collapse file tree 5 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 11import type { Component , DLElement } from "dreamland/core" ;
2+ import { browser } from "./main" ;
23
34export const Menu : Component < {
45 x : number ;
56 y : number ;
67 items : { label : string ; action ?: ( ) => void } [ ] ;
78} > = function ( cx ) {
89 cx . mount = ( ) => {
10+ browser . unfocusframes = true ;
911 document . body . appendChild ( cx . root ) ;
1012 const { top, left, width, height } = cx . root . getBoundingClientRect ( ) ;
1113 let maxX = document . documentElement . clientWidth - width ;
@@ -17,6 +19,7 @@ export const Menu: Component<{
1719 "click" ,
1820 ( ) => {
1921 cx . root . remove ( ) ;
22+ browser . unfocusframes = false ;
2023 } ,
2124 { once : true }
2225 ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import iconShield from "@ktibow/iconset-material-symbols/shield";
1010import iconStar from "@ktibow/iconset-material-symbols/star" ;
1111import iconSearch from "@ktibow/iconset-material-symbols/search" ;
1212import { createMenu } from "./Menu" ;
13- import { client } from "./main" ;
13+ import { browser , client } from "./main" ;
1414
1515export const Spacer : Component = function ( cx ) {
1616 return < div > </ div > ;
@@ -70,8 +70,10 @@ export const UrlInput: Component<
7070 < div
7171 on :click = { ( e : MouseEvent ) => {
7272 this . active = true ;
73+ browser . unfocusframes = true ;
7374 document . body . addEventListener ( "click" , ( e ) => {
7475 this . active = false ;
76+ browser . unfocusframes = false ;
7577 e . stopPropagation ( ) ;
7678 } ) ;
7779 this . input . focus ( ) ;
Original file line number Diff line number Diff line change 11import type { Component } from "dreamland/core" ;
22import type { Tab } from "./tabs" ;
3+ import { browser } from "./main" ;
34
45export let pushTab : ( tab : Tab ) => void ;
56export let popTab : ( tab : Tab ) => void ;
@@ -28,12 +29,15 @@ export const Shell: Component<{
2829 }
2930 } ;
3031
31- return < div > </ div > ;
32+ return < div class : unfocus = { use ( browser . unfocusframes ) } > </ div > ;
3233} ;
3334Shell . css = `
3435 :scope {
3536 flex: 1;
3637 }
38+ .unfocus {
39+ pointer-events: none;
40+ }
3741 .container {
3842 width: 100%;
3943 height: 100%;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { IconButton, Omnibox } from "./Omnibox";
55import { scramjet } from "./main" ;
66import iconAdd from "@ktibow/iconset-material-symbols/add" ;
77import { popTab , pushTab , Shell } from "./Shell" ;
8+ import { createMenu } from "./Menu" ;
89
910// let a = createState({
1011// b: createState({
@@ -29,6 +30,8 @@ export class Browser extends StatefulClass {
2930 tabs : Tab [ ] = [ ] ;
3031 activetab : Tab ;
3132
33+ unfocusframes : boolean = false ;
34+
3235 constructor ( state : Stateful < any > ) {
3336 super ( state ) ;
3437
@@ -68,6 +71,14 @@ export class Browser extends StatefulClass {
6871 } ) ;
6972 frame . addEventListener ( "contextInit" , ( e ) => {
7073 const framedoc = frame . frame . contentDocument ! ;
74+
75+ framedoc . addEventListener ( "contextmenu" , ( e ) => {
76+ createMenu ( e . x , e . y , [
77+ {
78+ label : "??" ,
79+ } ,
80+ ] ) ;
81+ } ) ;
7182 const head = framedoc . querySelector ( "head" ) ! ;
7283 const observer = new MutationObserver ( ( ) => {
7384 const title = framedoc . querySelector ( "title" ) ;
Original file line number Diff line number Diff line change @@ -34,20 +34,12 @@ export const scramjet = new ScramjetController({
3434scramjet . init ( ) ;
3535navigator . serviceWorker . register ( "./sw.js" ) ;
3636
37- let browser = createBrowser ( ) ;
37+ export let browser = createBrowser ( ) ;
3838( self as any ) . browser = browser ;
3939
4040try {
4141 let built = browser . build ( ) ;
4242 built . id = "app" ;
43- built . addEventListener ( "contextmenu" , ( e ) => {
44- createMenu ( e . x , e . y , [
45- {
46- label : "Reload" ,
47- } ,
48- ] ) ;
49- e . preventDefault ( ) ;
50- } ) ;
5143
5244 app . replaceWith ( built ) ;
5345} catch ( e ) {
You can’t perform that action at this time.
0 commit comments