Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix window position on startup #418

Merged
merged 7 commits into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ if shouldQuit
return;

# No more minimizing to tray, just close it
global.forceClose = false;
global.forceClose = false
quit = ->
global.forceClose = true;
global.forceClose = true
app.quit()
return

app.on 'before-quit', ->
global.forceClose = true;
global.forceClose = true
return

# For OSX show window main window if we've hidden it.
Expand All @@ -77,6 +77,9 @@ app.on 'activate', ->

loadAppWindow = ->
mainWindow.loadURL 'file://' + __dirname + '/ui/index.html'
# Only show window when it has some content
mainWindow.once 'ready-to-show', () ->
mainWindow.webContents.send 'ready-to-show'

toggleWindowVisible = ->
if mainWindow.isVisible() then mainWindow.hide() else mainWindow.show()
Expand Down Expand Up @@ -107,9 +110,9 @@ app.on 'ready', ->
"min-width": 620
"min-height": 420
icon: path.join __dirname, 'icons', 'icon.png'
show: true
show: false
titleBarStyle: 'hidden-inset' if process.platform is 'darwin'
autoHideMenuBar : true unless process.platform is 'darwin'
# autoHideMenuBar : true unless process.platform is 'darwin'
}


Expand Down Expand Up @@ -137,6 +140,7 @@ app.on 'ready', ->

loginWindow.on 'closed', quit

global.windowHideWhileCred = true
mainWindow.hide()
loginWindow.focus()
# reinstate app window when login finishes
Expand Down
15 changes: 13 additions & 2 deletions src/ui/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ hr'.split(' '))...

contextmenu = require('./views/contextmenu')
require('./views/menu')(viewstate)
if viewstate.startminimizedtotray
remote.getCurrentWindow().hide()

# tie layout to DOM

# restore last position of window
remote.getCurrentWindow().setPosition viewstate.pos...

document.body.appendChild applayout.el

# intercept every event we listen to
Expand All @@ -40,6 +41,16 @@ do ->
action 'alive', Date.now()
fn as...

# called when window is ready to show
# note: could not use event here, as it must be defined
# before
ipc.on 'ready-to-show', () ->
if viewstate.startminimizedtotray
remote.getCurrentWindow().hide()
else if !remote.getGlobal('windowHideWhileCred')? ||
remote.getGlobal('windowHideWhileCred') != true
remote.getCurrentWindow().show()

# wire up stuff from server
ipc.on 'init', (ev, data) -> dispatcher.init data
# events from hangupsjs
Expand Down
70 changes: 70 additions & 0 deletions src/ui/css/yakyak/applayout.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,79 @@
.spin{
animation: spinnerRotate 2s linear infinite;
}

@-webkit-keyframes sk-bouncedelay {
0%, 80%, 100% { -webkit-transform: scale(0) }
40% { -webkit-transform: scale(1.0) }
}

@keyframes sk-bouncedelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
} 40% {
-webkit-transform: scale(1.0);
transform: scale(1.0);
}
}

.applayout {
display: flex;
height: 100%;
.connecting {
position: absolute;
display: flex;
align-items: center;
width: 100%;
height: 100%;
background-color: rgba(255,255,255, 1);
z-index: 1000;
&.hide {
visibility: hidden;
opacity: 0;
transition: visibility 0s 1s, opacity 1s ease-out;
}
.hide {
display: none;
}
> div {
margin: 0 auto;
align-items: center;
div {
text-align: center;
margin-bottom: 1em;
img {
height: 10em;
}
span.text {
text-align: center;
font-size: 2em;
color: #555;
}
&.spinner {
text-align: center;
> div {
width: 18px;
height: 18px;
background-color: var(--green);

border-radius: 100%;
display: inline-block;
-webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
}
.bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
}
}
}
}
> .controls {
flex: none;
position: fixed;
Expand Down
3 changes: 3 additions & 0 deletions src/ui/dispatcher.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ handle 'addentities', (es, conv_id) ->
(es ? []).forEach (p) -> conv.addParticipant conv_id, p
viewstate.setState viewstate.STATE_NORMAL

# Best place to check if everyone is added
document.querySelector('.connecting').classList.add("hide")

handle 'uploadimage', (files) ->
# this may change during upload
conv_id = viewstate.selectedConv
Expand Down
14 changes: 14 additions & 0 deletions src/ui/views/applayout.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

{throttle, topof} = require '../util'

path = require 'path'

attached = false
attachListeners = ->
return if attached
Expand Down Expand Up @@ -89,6 +91,18 @@ resizers =
module.exports = exp = layout ->
platform = if process.platform is 'darwin' then 'osx' else ''
div class:'applayout dragtarget ' + platform, drag, resize, ->
div class: 'connecting', ->
div ->
div () ->
img src: path.join __dirname, '..', '..', 'icons', 'yakyak-logo.svg'
div ->
span class: 'text state_connecting', 'Connecting'
span class: 'text state_contacts hide', 'Loading contacts'
div class: 'spinner', ->
div class: 'bounce1', ''
div class: 'bounce2', ''
div class: 'bounce3', ''

div class:'left', ->
div class:'listhead', region('listhead')
div class:'list', region('left')
Expand Down
17 changes: 15 additions & 2 deletions src/ui/views/controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ handle 'update:connection', do ->
# draw view
conninfo connection

startupConnEl = document.querySelector('.state_connecting')
startupLoadEl = document.querySelector('.state_contacts')
# place in layout
if connection.state == connection.CONNECTED
el?.hide?()
startupConnEl.classList.add("hide")
startupLoadEl.classList.remove("hide")
el = null
else
el = notr {html:conninfo.el.innerHTML, stay:0, id:'conn'}

startupConnEl.innerHTML = connection.infoText()
# replace three dots
.replace '…',''
# add check connection to "Not Connected"
.replace /(Not connected)/,
'$1 (check connection)'
if document.querySelector('.connecting.hide')?
el = notr {html:conninfo.el.innerHTML, stay:0, id:'conn'}
else
startupConnEl.classList.remove("hide")
startupLoadEl.classList.add("hide")

setLeftSize = (left) ->
document.querySelector('.left').style.width = left + 'px'
Expand Down